AutoHotkey Community

It is currently May 26th, 2012, 9:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 

Deprecate some commands?
Yes
No
You may select 1 option

View results
Author Message
PostPosted: July 25th, 2008, 3:44 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I think it would help reduce confusion to mark a bunch of commands as deprecated in the manual. Many exist only to support auto0it 2 scripts. most are better written in some expression format.

if others agree or disagree with particular commands, or want to add to the list, please reply/vote

Commands (strong desire to deprecate, IMHO):
- EnvSub
- EnvAdd
- EnvMult
- EnvDiv
- SetEnv (keep EnvSet, EnvGet and EnvUpdate)
- IfInString
- IfExist
- IfLess,
- IfGreater
and similar

Commands (lesser desire to deprecate, IMHO):
- IfWinExist
- IfWinActive
and similar

Commands I would like to deprecate, but have no useful Expression equivalent (in fact it would be nice to see some functions for these):
- If var is type
- IfMsgBox

Comments appreciated

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 4:10 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Agreed.

Although I use IfWinExist and IfWinActive.... :roll:

For "If var is type" I use:

Code:
IfIs(ByRef var, type) {
   If var is %type%
      Return, true
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 4:49 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
you could replace with If WinExist() and If WinActive()

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 4:56 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Yeah I know, and I do that in some places... But for whatever reason I use IfWinExist and IfWinActive. I hate all the other If___ commands >.> Especially IfMsgBox... which is why I almost never use AHK message boxes anymore when I need input. There's some MsgBox() script around this forum somewhere that's very customizable and returns the answer, so it works great for me—although it doesn't look quite as nice =\


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 9:26 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
I agree, though I am of the opinion that the term 'deprecated' be acompanied by its definition.

I occasionally use some of those commands... though typically only for readability considerations.

I think that msgbox should use the errorlevel to mark user selections so that it shares more of the conventions used by other user input commands.

'If var is type' and 'If _ between _ and _' can be replaced with some easy functions
Code:
Is_Int(var)
{
   return !InStr(var, ".") && (var+0 != "")
}

Is_Num(var)
{
   return var+0 != ""
}

Is_Hex(var)
{
   return InStr(var, "0x") && (var+0 != "")
}

Is_Float(var)
{
   return InStr(var, ".") && (var+0 != "")
}

Is_Digit(var)
{
   Loop, parse, var
      If !InStr("1234567890", A_Loopfield)
         return 0
   return 1
}

Is_XDigit(var)
{
   Loop, parse, var
      If !InStr("1234567890abcdef", A_Loopfield)
         return 0
   return 1
}

Is_Alpha(var)
{
   Loop, parse, var
      If !InStr("qwertyuiopasdfghjklzxcvbnm", A_LoopField)
         return 0
   return 1
}

Is_Lower(var)
{
   Loop, parse, var
      If !InStr("qwertyuiopasdfghjklzxcvbnm", A_LoopField, 1)
         return 0
   return 1
}

Is_Upper(var)
{
   Loop, parse, var
      If !InStr("QWERTYUIOPASDFGHJKLZXCVBNM", A_LoopField, 1)
         return 0
   return 1
}

Is_Alnum(var)
{
   Loop, parse, var
      If !InStr("1234567890qwertyuiopasdfghjklzxcvbnm", A_LoopField)
         return 0
   return 1
}

Between_In( low, var, high ) ; inclusive
{
   If (low > high)
      return high <= var && var <= low
   return low <= var && var <= high
}

Between_Ex( low, var, high ) ; exclusive
{
   If (low > high)
      return high < var && var < low
   return low < var && var < high
}

Between_EL( low, var, high ) ; between high and low or equal to low
{ ; for example, Between_EL( 0, var, 1 ) would be false if var = 1
   If (low > high)
      return high <= var && var < high
   return low <= var && var < high
}

untested :P (and I think krogdor's way is more elegant)

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 9:38 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
[VxE] wrote:
(and I think krogdor's way is more elegant)


Not quite my way... Found it somewhere on the forum (I think? o_O )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 10:44 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Krogdor wrote:
Found it somewhere on the forum (I think? o_O )
Seem familiar... hmm :P

[VxE] wrote:
'If var is type' and 'If _ between _ and _' can be replaced with some easy functions
Those Ifs are important; I'm not obsessed with expressions/OTB because traditional syntax is fast and simple.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 5:06 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I didn't nominate If __ between for that reason. A few of them are useful and readable. It things like EnvMult and IfGreater that bug me.

Agree that definition or link to a new help page called deprecated with definition and such would be required. It took me a while to understand what deprecated meant until I put it in terms of electronic components, where the closest term is "End of Life", where the components are available, but not recommended for new designs because you never know when the parts will run out.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 5:30 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
i actually use IfMsgBox quite a bit

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 5:32 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I do too. I would rather see MsgBox affect Errorlevel, as suggested by [VxE], so that you can use if (errorlevel) instead of IfMsgBox.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 7:03 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
i dispise that process as it actually conviludes the functionality
for instance i sometimesuse an expression in msgbox
what if the error elvel is set by said expresion
no i think there needs to be some return value for msgbox that is separate

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 7:11 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
how about an outputVar in the options field?
Code:
Msgbox, 4 vOutputVar, Title, Text, Timeout

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 8:13 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
then i agree with it in that scenerio

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2008, 8:15 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
as far as the if var is type
wow i think the oposite that needs to be expanded heavily
but this would required datatypes better defined in ahk

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2008, 7:20 am 
Offline

Joined: December 19th, 2006, 2:14 pm
Posts: 72
Location: France
OK to mark older commands as deprecated, but each time one is marked as such, it would be fine to give a suggested (fully compatible) replacement, because these deprecated are still present in existing scripts


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group