Arclite86 Posted September 25, 2014 Share Posted September 25, 2014 I would like to create multiple function for example something like this ;I have a number = $number Funcion1 Funcion2 Funcion3 Funcion4 Funcion5 Funcion6 If $number = Bellow 100 then Funcion1 If $number = Bellow 200 then Funcion2 If $number = Bellow 300 then Funcion3 If $number = Bellow 400 then Funcion4 If $number = Bellow 500 then Funcion5 If $number = Above 600 then Funcion6 I think this is pretty easy and im very close but im not familiar with this so could somebody please help me. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2014 Moderators Share Posted September 25, 2014 Arclite86,Look at Switch or Select - these conditional structures can do what you want. M23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MikahS Posted September 25, 2014 Share Posted September 25, 2014 (edited) expandcollapse popupLocal $number = 10 Select Case $number <= 100 Function1() Case $number <= 200 > 100 Function2() Case $number <= 300 > 200 Function3() Case $number <= 400 > 300 Function4() Case $number <= 500 > 400 Function5() Case $number >= 600 Function6() EndSelect Func Function1() ; do stuff EndFunc Func Function2() ; do stuff EndFunc Func Function3() ; do stuff EndFunc Func Function4() ; do stuff EndFunc Func Function5() ; do stuff EndFunc Func Function6() ; do stuff EndFunc something like this? EDIT: see, you still have it Edited September 25, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Arclite86 Posted September 25, 2014 Author Share Posted September 25, 2014 expandcollapse popupLocal $number = 10 Select Case $number <= 100 Function1() Case $number <= 200 > 100 Function2() Case $number <= 300 > 200 Function3() Case $number <= 400 > 300 Function4() Case $number <= 500 > 400 Function5() Case $number >= 600 Function6() EndSelect Func Function1() ; do stuff EndFunc Func Function2() ; do stuff EndFunc Func Function3() ; do stuff EndFunc Func Function4() ; do stuff EndFunc Func Function5() ; do stuff EndFunc Func Function6() ; do stuff EndFunc something like this? EDIT: see, you still have it thank you that looks what i want but i have a question I want to use this in a function Func counter() Local $number = 10 Select Case $number <= 100 ; do stuff Case $number <= 200 > 100 ; do stuff Case $number <= 300 > 200 ; do stuff Case $number <= 400 > 300 ; do stuff Case $number <= 500 > 400 ; do stuff Case $number >= 600 ; do stuff EndSelect Endfunc So is this also possible? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 25, 2014 Moderators Share Posted September 25, 2014 Arclite86 - try it "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MikahS Posted September 25, 2014 Share Posted September 25, 2014 Arclite86 - try it Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
mikell Posted September 25, 2014 Share Posted September 25, 2014 (edited) @MikahS works nice Local $number = 250 Select Case $number <= 100 Function1() Case $number <= 200 > 100 Function2() Case $number <= 300 > 200 Function3() Case $number <= 400 > 300 Function4() Case Else Function5() EndSelect Func Function1() msgbox(0,"", "func1") EndFunc Func Function2() msgbox(0,"", "func2") EndFunc Func Function3() msgbox(0,"", "func3") EndFunc Func Function4() msgbox(0,"", "func4") EndFunc Func Function5() msgbox(0,"", "check your syntax") EndFunc Edited September 25, 2014 by mikell Link to comment Share on other sites More sharing options...
MikahS Posted September 26, 2014 Share Posted September 26, 2014 @MikahS works nice Local $number = 250 Select Case $number <= 100 Function1() Case $number <= 200 > 100 Function2() Case $number <= 300 > 200 Function3() Case $number <= 400 > 300 Function4() Case Else Function5() EndSelect Func Function1() msgbox(0,"", "func1") EndFunc Func Function2() msgbox(0,"", "func2") EndFunc Func Function3() msgbox(0,"", "func3") EndFunc Func Function4() msgbox(0,"", "func4") EndFunc Func Function5() msgbox(0,"", "check your syntax") EndFunc Except your not looking for a number below 500, and your case else will catch this and tell you check your syntax even when its still a number Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
kylomas Posted September 26, 2014 Share Posted September 26, 2014 Another way to express this... expandcollapse popupLocal $number = 938 Switch $number Case 100 to 199 Function1() Case 200 to 299 Function2() Case 300 to 399 Function3() Case 400 to 499 Function4() Case 500 to 599 Function5() Case 600 to 699 Function6() case else ConsoleWrite('no function for number' & @CRLF) Endswitch Func Function1() ConsoleWrite('Func 1' & @CRLF) EndFunc Func Function2() ConsoleWrite('Func 2' & @CRLF) EndFunc Func Function3() ConsoleWrite('Func 3' & @CRLF) EndFunc Func Function4() ConsoleWrite('Func 4' & @CRLF) EndFunc Func Function5() ConsoleWrite('Func 5' & @CRLF) EndFunc Func Function6() ConsoleWrite('Func 6' & @CRLF) EndFunc Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted September 26, 2014 Share Posted September 26, 2014 Or reverse thedirection. expandcollapse popupLocal $number = 938 Select Case $number > 599 Function1() Case $number > 499 Function2() Case $number > 399 Function3() Case $number > 299 Function4() Case $number > 199 Function5() Case $number > 99 Function6() Case else ConsoleWrite('no function for number' & @CRLF) EndSelect Func Function1() ConsoleWrite('Func 1' & @CRLF) EndFunc Func Function2() ConsoleWrite('Func 2' & @CRLF) EndFunc Func Function3() ConsoleWrite('Func 3' & @CRLF) EndFunc Func Function4() ConsoleWrite('Func 4' & @CRLF) EndFunc Func Function5() ConsoleWrite('Func 5' & @CRLF) EndFunc Func Function6() ConsoleWrite('Func 6' & @CRLF) EndFunc AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted September 26, 2014 Share Posted September 26, 2014 True masochist would do it like this: #AutoIt3Wrapper_Run_AU3Check=n ; if you use AutoIt3Wrapper Local $number = 251 $number <= 100 ? _ Function1() : _ $number <= 200 ? _ Function2() : _ $number <= 300 ? _ Function3() : _ $number <= 400 ? _ Function4() : _ Function5() Func Function1() MsgBox(0, "", "func1") EndFunc Func Function2() MsgBox(0, "", "func2") EndFunc Func Function3() MsgBox(0, "", "func3") EndFunc Func Function4() MsgBox(0, "", "func4") EndFunc Func Function5() MsgBox(0, "", "func5") EndFunc kylomas and MikahS 2 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted September 26, 2014 Share Posted September 26, 2014 Here another variant: $iNumber = 500 For $i = 100 To 700 Step 100 If ($iNumber / $i) <= 1 Then Call("Func" & $i / 100) ExitLoop EndIf Next Func Func1() MsgBox(0, "Function1", "< 100") EndFunc Func Func2() MsgBox(0, "Function2", "> 100 to <= 200") EndFunc Func Func3() MsgBox(0, "Function3", "> 200 to <= 300") EndFunc Func Func4() MsgBox(0, "Function4", "> 300 to <= 400") EndFunc Func Func5() MsgBox(0, "Function5", "> 400 to <= 500") EndFunc Func Func6() MsgBox(0, "Function5", "> 500 to <= 600") EndFunc Func Func7() MsgBox(0, "Function6", ">= 600") EndFunc Br, UEZ Xandy 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
JohnOne Posted September 26, 2014 Share Posted September 26, 2014 variant of trancexx' Local $number = 251 Local $aFunc = [Function1, Function2, Function3, Function4, Function5] $val = $number <= 100 ? 0 : $number <= 200 ? 1 : $number <= 300 ? 2 : $number <= 400 ? 3 : 4 $aFunc[$val]() Func Function1() MsgBox(0, "", "func1") EndFunc Func Function2() MsgBox(0, "", "func2") EndFunc Func Function3() MsgBox(0, "", "func3") EndFunc Func Function4() MsgBox(0, "", "func4") EndFunc Func Function5() MsgBox(0, "", "func5") EndFunc MikahS 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mikell Posted September 26, 2014 Share Posted September 26, 2014 variant of UEZ' variant $number = 500 $number < 700 ? Call("Func" & Ceiling($number / 100)) : Msgbox(0,"", "off limit") Func Func1() MsgBox(0, "Function1", "< 100") EndFunc Func Func2() MsgBox(0, "Function2", "> 100 to <= 200") EndFunc Func Func3() MsgBox(0, "Function3", "> 200 to <= 300") EndFunc Func Func4() MsgBox(0, "Function4", "> 300 to <= 400") EndFunc Func Func5() MsgBox(0, "Function5", "> 400 to <= 500") EndFunc Func Func6() MsgBox(0, "Function5", "> 500 to <= 600") EndFunc Func Func7() MsgBox(0, "Function6", ">= 600") EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted September 26, 2014 Share Posted September 26, 2014 @mikell: even shorter Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
junkew Posted September 26, 2014 Share Posted September 26, 2014 $number = 500 execute("Func" & ($number >= 600 ? 6 : Ceiling($number / 100) ) & "()") ;$number < 700 ? Call("Func" & Ceiling($number / 100)) : Msgbox(0,"", "off limit") whats the subtle difference between call, eval, execute? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Arclite86 Posted September 28, 2014 Author Share Posted September 28, 2014 $i7b = number(14) Select Case $i7b == 1 MsgBox("Title", "test","not good" ,5000) Case $i7b == 2 MsgBox("Title", "test","not good" ,5000) Case $i7b == 3 MsgBox("Title", "test","Good!!!" ,5000) Case $i7b == 14 MsgBox("Title", "test","not good" ,5000) Case $i7b == 26 MsgBox("Title", "test","not good" ,5000) Case $i7b == 80 MsgBox("Title", "test","not good" ,5000) EndSelect I want something like this: if $i7b is equal to (for example) 14 then MsgBox("Title", "test","Good!!!" ,5000) Link to comment Share on other sites More sharing options...
jchd Posted September 28, 2014 Share Posted September 28, 2014 Nobody seems to have frown on this: Local $number = 250 ... Case $number <= 300 > 200 While this is valid syntax, the outcome differs from what the author intends. This will evaluate as: ($number <= 300) > 200 that is True > 200 giving False Xandy 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Arclite86 Posted September 28, 2014 Author Share Posted September 28, 2014 $i7b = number(14) Select Case $i7b == 1 MsgBox("Title", "test","not good" ,5000) Case $i7b == 2 MsgBox("Title", "test","not good" ,5000) Case $i7b == 3 MsgBox("Title", "test","Good!!!" ,5000) Case $i7b == 14 MsgBox("Title", "test","not good" ,5000) Case $i7b == 26 MsgBox("Title", "test","not good" ,5000) Case $i7b == 80 MsgBox("Title", "test","not good" ,5000) EndSelect I want something like this: if $i7b is equal to (for example) 14 then MsgBox("Title", "test","Good!!!" ,5000) im sorry i placed the MsgBox("Title", "test","Good!!!" ,5000) bellow he wrong case It works Link to comment Share on other sites More sharing options...
JohnOne Posted September 28, 2014 Share Posted September 28, 2014 That is not what you asked for at the start. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now