crest Posted October 6, 2006 Share Posted October 6, 2006 Hey guys for some reason "If .. Then" can only handle a single statement after the "Then" like explained in the helpfile Conditionally run a single statement. If <expression> Then statement Is there any way to have two or more statements? in c++ you can simply put as many statements as you want, you just need to bracket them like: if (expression) { statement1; statement2; ...} My own Code looks like this: #include <GUIConstants.au3> Global $amount GUICreate ( "Conjure Water v1.2b", 300, 200) $slider = GUICtrlCreateSlider (10, 30, 280, 20) GuiCtrlSetLimit (-1, 20, 10) $button = GUICtrlCreateButton ( "OK", -1 , 100 , 80, 20) GuiSetState() GuiCtrlSetData ($slider, 0) While 1 $tempvar = GUiGetMsg() If $tempvar = $button Then $amount = GuiCtrlRead ($slider) Wend I actually wanted the "IF ... Then" to save the Slider Position into $amount and then exit the While-Loop Yet i cant think of a way to do this (damn i suck) Link to comment Share on other sites More sharing options...
Helge Posted October 6, 2006 Share Posted October 6, 2006 #include <GUIConstants.au3> Global $amount GUICreate ( "Conjure Water v1.2b", 300, 200) $slider = GUICtrlCreateSlider (10, 30, 280, 20) GuiCtrlSetLimit (-1, 20, 10) $button = GUICtrlCreateButton ( "OK", -1 , 100 , 80, 20) GuiSetState() GuiCtrlSetData ($slider, 0) While 1 $tempvar = GUiGetMsg() If $tempvar = $button Then $amount = GuiCtrlRead ($slider) ExitLoop EndIf Wend Link to comment Share on other sites More sharing options...
crest Posted October 6, 2006 Author Share Posted October 6, 2006 hmpf ive tried that already and it didnt work, some error msg appeared xD now that ive copy / pasted it, it works strange, since i dont see any difference Anyways, thanks for the fast help Link to comment Share on other sites More sharing options...
litlmike Posted October 6, 2006 Share Posted October 6, 2006 (edited) hmpf ive tried that already and it didnt work, some error msg appeared xD now that ive copy / pasted it, it works strange, since i dont see any difference Anyways, thanks for the fast help It was probably a Syntax error. Recreate the script the way you had it and see if it gives you the same error. A syntax error just means that something was not in the correct order or something was misplaced. Its kinda like rearranging a sentence like 'Crest walks the dog'. You can write it this way or 'The dog Crest walks" and both ways communicate the same thing to you, however when scripting, if it is not EXACTLY the way it SHOULD appear, you will just get an error. As a general sytax rule when using If statements in AutoIt put the stuff after Then on the next line, not the same line. This small Change can be the difference in your script working or not. So always make this:If $tempvar = $button Then $amount = GuiCtrlRead ($slider)oÝ÷ غ(X¤zØb±«¢+Ø)%ÀÌØíѵÁÙÈôÀÌØíÕÑѽ¸Q¡¸(ÀÌØíµ½Õ¹ÐôÕ¥ ÑɱI ÀÌØíͱ¥È¤ Edited October 6, 2006 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
dandymcgee Posted October 6, 2006 Share Posted October 6, 2006 (edited) So always make this: If $tempvar = $button Then $amount = GuiCtrlRead ($slider) oÝ÷ غ(X¤zØb±«¢+Ø)%ÀÌØíѵÁÙÈôÀÌØíÕÑѽ¸Q¡¸(ÀÌØíµ½Õ¹ÐôÕ¥ ÑɱI ÀÌØíͱ¥È¤( Edited October 6, 2006 by dandymcgee - Dan [Website] Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 6, 2006 Share Posted October 6, 2006 Hi, you can check those things on your own. Like: #include <GUIConstants.au3> Global $amount GUICreate ( "Conjure Water v1.2b", 300, 200) $slider = GUICtrlCreateSlider (10, 30, 280, 20) GuiCtrlSetLimit (-1, 20, 10) $button = GUICtrlCreateButton ( "OK", -1 , 100 , 80, 20) GuiSetState() GuiCtrlSetData ($slider, 0) While 1 $tempvar = GUiGetMsg() ToolTip(GuiCtrlRead ($slider)) If $tempvar = $button Then $amount = GuiCtrlRead ($slider) ConsoleWrite($amount & @LF) ExitLoop EndIf Wend So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Helge Posted October 6, 2006 Share Posted October 6, 2006 Did I understand you correctly there litlmike ? Are you saying that this code doesn't work :If $tempvar = $button Then $amount = GuiCtrlRead ($slider) If so, you're wrong, as it does work. Link to comment Share on other sites More sharing options...
crest Posted October 6, 2006 Author Share Posted October 6, 2006 Did I understand you correctly there litlmike ? Are you saying that this code doesn't work :If $tempvar = $button Then $amount = GuiCtrlRead ($slider)oÝ÷ Øì£*.ßÚÞº'«"µÚ³ +ú®¢×°zYa{§µçm¢Æ²¶Ê¬¥v{p®+^r^)¶¬jëh×6If $tempvar = $button Then $amount = GuiCtrlRead ($slider)oÝ÷ Ù»¶+×¢¶X¤zØZµ«¢+Ø)%ÀÌØíѵÁÙÈôÀÌØíÕÑѽ¸Q¡¸(ÀÌØíµ½Õ¹ÐôÕ¥ ÑɱI ÀÌØíͱ¥È¤ just to reduce errors and make it more clearly Thx for the advanced help btw Link to comment Share on other sites More sharing options...
Helge Posted October 6, 2006 Share Posted October 6, 2006 (edited) Reduce errors? Shouldn't ? Well, actually that one-liner doesn't produce any errors while the second does, because of a missing EndIf. Personally I always use one-liners when I only need it to execute one statement...oh, well that's me. Edited October 6, 2006 by Helge Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 6, 2006 Share Posted October 6, 2006 Reduce errors? Shouldn't ? Well, actually that one-liner doesn't produce any errors whilethe second does, because of a missing EndIf. Personally I always use one-liners when Ionly need it to execute one statement...oh, well that's me.I agree with you So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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