AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 17th, 2007, 6:43 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
My point isn't that it would be a bad part of the language (except for what it would add to the docs), but that it isn't worth adding.

And that's a pretty silly analogy, for reasons I don't have to expound on.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2007, 7:02 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
jonny wrote:
My point isn't that it would be a bad part of the language (except for what it would add to the docs), but that it isn't worth adding.

And that's a pretty silly analogy, for reasons I don't have to expound on.
It's just as silly as your reasons for not adding it. Again, you also use the extremely lame excuse of having to modify the docs... Has AutoHotkey development completely ceased? Is this now to be considered a Final release? If not, then the docs will need to be updated. Do you really think that anyone that uses AHK considers that adding another couple lines to the doumentation should prevent an additional feature being added? Is the documentation really that much of a burden that it restricts development of the language?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2007, 7:15 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
It is a pretty lame excuse. But it's enough. I don't actively oppose this change, I just want to know why it's so necessary.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2007, 7:24 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
jonny wrote:
It is a pretty lame excuse. But it's enough.
Well, the point there was that it isn't enough of an excuse. I'm willing to bet that you are in the extreme minority in thinking that it is.

Quote:
I don't actively oppose this change, I just want to know why it's so necessary.
Understood. Simple answer... Users have stated that they would find it useful. Surprisingly, that rarely seems to be enough justification these days...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2007, 11:46 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
corrupt wrote:
Maybe we should get rid of built-in multiplication. How often is it really used when creating a simple script that uses a couple hotkeys for automation?
That's AutoIt2, the base of the original AutoHotkey... Doing arithmetic beyond the four operations needed external programs.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2008, 3:57 am 
Offline

Joined: May 8th, 2006, 10:24 pm
Posts: 10
Location: QLD Australia
I found this thread because I have an ooRexx script that I want to convert to ahk.

Part of the script involves getting the max of a series of variables. I couldn't exactly understand the example by lazlo on page 1, so I figured that the easiest way for me to do this is to use the native MAX function in ooRexx, but calling it from ahk.

EG:
AHK script.ahk
Code:
run , rexx call_rex_from_ahk.rex 1`,5`,23`,12`,11`,56`,74`,22`,11`,22`,33`,44`,55`,228


rexx script = call_rex_from_ahk.rex
Code:
parse arg a1 ',' a2 ',' a3 ',' a4 ',' a5 ',' a6 ',' a7 ',' a8 ',' a9 ',' a10 ',' a11 ',' a12 ',' a13 ',' a14
daymax = max(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
say 'Max is ' daymax '!!!!!'
pause      /* added so you can actually see it */


Now I just have to put the daymax somewhere (from the rexx script) that I can use it... maybe in an ini/tmp or try to fileappend it straight to the sql file I want it for.

Feel free to let me know if max was added since then but I can't see it in the autohotkey.chm file.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2008, 1:53 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
i somehow felt this is the place for this lil script:

min aswell as max accept three lists of values (each can use seperators such as ,| , %A_Tab% or CRLF) or simple values and it either returns min or max of those given values (lists or values)

Code:
l1 := "12,45,3,1,2,3,4"
l2 := "0"
l3 := "a,b"

MsgBox % min(l1,l2,l3) "/" max(l1,l2,l3)

min(listValue1,ListValue2="",ListValue3=""){
   return sortMMlist(listValue1,listValue2,listValue3,1)
}

max(listValue1,ListValue2="",ListValue3=""){
   return sortMMlist(listValue1,listValue2,listValue3,0)
}

sortMMlist(m1,m2,m3,m4){
   loop,3 {
      m:= RegExReplace(m%A_Index%,"[^\d,\|\r\n\t]"),m:= RegExReplace(m,"\||\t|,|\r?\n","`n")
      Loop,Parse,m,`n
         if StrLen(A_LoopField)
            o .= A_LoopField "`n"
   }
   sort,o,% "N" ((m4=1) ? "" : "R")
   StringSplit,o,o,`n
   return o1
}


dR

edit fixed a lil bug

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Last edited by derRaphael on October 15th, 2008, 12:10 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2008, 11:02 pm 
Offline

Joined: May 8th, 2006, 10:24 pm
Posts: 10
Location: QLD Australia
Hi DerRaphael,

That was great advice thanks. Now I can manage it without rexx.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2008, 12:11 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
hi i fixed a lil bug in the function - so it works as expected with delimiters other than comma.

greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Max / Min
PostPosted: May 5th, 2010, 2:47 am 
Offline

Joined: August 8th, 2009, 2:25 am
Posts: 14
Hi guys

I just found out that there's no these functions in Autohotkey (which is funny, since bunch of stuff like Abs, Round, Sincos etc. does exist).
So as I needed it for my script, I had to write it myself. Maybe somebody will find it useful.

It can be used in two ways - passing actual numeric parameters (up to 31, but can be extended of course), or passing a string(s) containing any number of comma-delimited values (non-numeric values are ignored).

Code:
Min(param1, param2  = "-", param3  = "-", param4  = "-", param5  = "-", param6  = "-", param7  = "-", param8  = "-", param9  = "-", param10 = "-", param11 = "-"
          , param12 = "-", param13 = "-", param14 = "-", param15 = "-", param16 = "-", param17 = "-", param18 = "-", param19 = "-", param20 = "-", param21 = "-"
          , param22 = "-", param23 = "-", param24 = "-", param25 = "-", param26 = "-", param27 = "-", param28 = "-", param29 = "-", param30 = "-", param31 = "-")
{
    min    := 4294967295                                        ; starting value
    params := 0
    Loop , 31                                                   ; go through all parameters
    {
        CurrentParam := param%A_Index%
       
        ; parse each parameter in case it has several items separated with commas
       
        Loop, parse, CurrentParam, `,, %A_Space%%A_Tab%
        {
            if A_LoopField is not number
                continue
            else
            {
                values++
                value%values% := A_LoopField
            }
        }
    }
   
    Loop , %values%
    {
        CurrentValue := value%A_Index%
        min          := (min < CurrentValue) ? min : CurrentValue
    }   
   
    return min
}




Max(param1, param2  = "-", param3  = "-", param4  = "-", param5  = "-", param6  = "-", param7  = "-", param8  = "-", param9  = "-", param10 = "-", param11 = "-"
          , param12 = "-", param13 = "-", param14 = "-", param15 = "-", param16 = "-", param17 = "-", param18 = "-", param19 = "-", param20 = "-", param21 = "-"
          , param22 = "-", param23 = "-", param24 = "-", param25 = "-", param26 = "-", param27 = "-", param28 = "-", param29 = "-", param30 = "-", param31 = "-")
{
    max    := -2147483648                                       ; starting value
    values := 0
    Loop , 31                                                   ; go through all parameters
    {
        CurrentParam := param%A_Index%
       
        ; parse each parameter in case it has several items separated with commas
       
        Loop, parse, CurrentParam, `,, %A_Space%%A_Tab%
        {
            if A_LoopField is not number
                continue
            else
            {
                values++
                value%values% := A_LoopField
            }
        }
    }
   
    Loop , %values%
    {
        CurrentValue := value%A_Index%
        max          := (max > CurrentValue) ? max : CurrentValue
    }   
   
    return max
}


I tested it with different values, but if there are any bugs I missed, please tell me.

In case you're wondering why I need weird "-"'s - those are default value for the parameters, so that you can pass as few parameters as you want. Couldn't use 0 as it's also possible value.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 12 guests


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