AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Max and Min as built-in math functions?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
jonny



Joined: 13 Nov 2004
Posts: 2952
Location: Minnesota

PostPosted: Sat Mar 17, 2007 5:43 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2446

PostPosted: Sat Mar 17, 2007 6:02 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 2952
Location: Minnesota

PostPosted: Sat Mar 17, 2007 6:15 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2446

PostPosted: Sat Mar 17, 2007 6:24 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6712
Location: France (near Paris)

PostPosted: Sun Mar 18, 2007 10:46 am    Post subject: Reply with quote

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
staid



Joined: 08 May 2006
Posts: 10
Location: QLD Australia

PostPosted: Tue Oct 14, 2008 2:57 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 679
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Tue Oct 14, 2008 12:53 pm    Post subject: Reply with quote

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
_________________
    Code:
    /* no comment */


Last edited by DerRaphael on Wed Oct 15, 2008 11:10 am; edited 1 time in total
Back to top
View user's profile Send private message
staid



Joined: 08 May 2006
Posts: 10
Location: QLD Australia

PostPosted: Tue Oct 14, 2008 10:02 pm    Post subject: Reply with quote

Hi DerRaphael,

That was great advice thanks. Now I can manage it without rexx.
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 679
Location: % ( RegExMatch( A_AppData, "^(?P<_Home>.*)\\", A ) ? A_Home : "" )

PostPosted: Wed Oct 15, 2008 11:11 am    Post subject: Reply with quote

hi i fixed a lil bug in the function - so it works as expected with delimiters other than comma.

greets
dR
_________________
    Code:
    /* no comment */
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group