BinaryBrother Posted September 20, 2010 Share Posted September 20, 2010 (edited) While 1 $Action = _MakeChoice() If $Action = "Username" Then ConsoleWrite("BinaryBrother" & @CRLF) ElseIf $Action = "Password" Then ConsoleWrite("********" & @CRLF) ElseIf $Action = "Done" Then ConsoleWrite("FirstCommand" & @CRLF) EndIf WEnd Func _MakeChoice() EndFunc ;==>_MakeChoiceIn cases where the function returns nothing, the first IF statement is triggered as true... o.0Is this actually a bug or am I misunderstanding how the engine is suppose to work?Summery:The above code should not ConsoleWrite anything, and instead writes "BinaryBrother".Details:AutoIt Version: AutoIt V3.3.6.1OS: Windows 7 Ultimate x64Install Dir: Default - same as OS (Nothing funky)Other: I'm running and compiling from a DropBox synced DIR. Edited September 20, 2010 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
xPloit Posted September 20, 2010 Share Posted September 20, 2010 I think you would need to include an Else statement. I'm surprised that it doesn't just crash if you return nothing. You have: if (this) then elseif (this) then elseif (this) then but no fallback... if (this) then elseif (this) then elseif (this) then else... but i'm still pretty new to AuI so I may be totally wrong haha 00101101011110000101000001101100011011110110100101110100 Link to comment Share on other sites More sharing options...
DaleHohm Posted September 20, 2010 Share Posted September 20, 2010 Not a bug, but not an uncommon misunderstanding. It is caused by AutoIt using variants instead of being strongly typed. AutoIt does not know whether $Action is intended to hold a string or a numeric and tried to imply this based on what it sees... your function is retuning a numeric 0, you are then comparing a numeric to a string... in a numeric comparison, a string evaluates as a numeric 0 and thus your first comparison returns True. You need to force the type of comparison that you desire: If String($Action) = "Username" Then will work as you expect. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
xPloit Posted September 20, 2010 Share Posted September 20, 2010 i think -- If GUICtrlRead($Action) = "Username" Then -- would work as well 00101101011110000101000001101100011011110110100101110100 Link to comment Share on other sites More sharing options...
BinaryBrother Posted September 20, 2010 Author Share Posted September 20, 2010 (edited) @DaleDoh! ... Thanks Dale. I specifically remember writing a few things a while back that actually relied on the function returning non-zero for errors. 0 for success. I have no idea why I forgot that with no specified return value, custom functions actually return 0.Gah, this little mishap had me debugging for a half day before I narrowed it down to this loop! lol@xPloitThanks to you as well for pointing that out (the bit about else), I had completely forgot... As far as Guictrlread() I don't even have a GUI so I think you missed something... Maybe I should give it a few days rest, when any of my scripts get around 600+ lines, I start getting confused... Edited September 20, 2010 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
xPloit Posted September 20, 2010 Share Posted September 20, 2010 haha, yeah. Taking a break and not thinking about it will help. Then you can usually find the bugs and even shorten your code to it's easier to read and less confusing, haha 00101101011110000101000001101100011011110110100101110100 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