Guest Zak Posted June 17, 2004 Share Posted June 17, 2004 (edited) Hi, I'm new to this and I was trying to write a simple program, but dont know where I am going wrong. Please can someone correct my code for me, and explain to me what it is i wasnt doing or something. Thanks $ret = InputBox("Input Value","Please enter the word specified: test") If $ret = "test" Then MsgBox(0,"Correct!","Hopefully this has worked! And you are now reading this") ElseIf $ret = 0 Then MsgBox(5,"Wrong","Do you want to try again?") EndIf If @error = 4 Then $ret ElseIf @error = 2 Then Exit EndIf Edited June 17, 2004 by Larry Link to comment Share on other sites More sharing options...
DaLiMan Posted June 17, 2004 Share Posted June 17, 2004 I copied your code and it seems to be working. What's wrong? Link to comment Share on other sites More sharing options...
DaLiMan Posted June 17, 2004 Share Posted June 17, 2004 After a closer look you might be looking for something like this: Start() Func Start() $ret = InputBox("Input Value","Please enter the word specified: test") If $ret = "test" Then MsgBox(0,"Correct!","Hopefully this has worked! And you are now reading this") ElseIf $ret = 0 Then $String = MsgBox(5,"Wrong","Do you want to try again?") If $String = "2" then Exit Else Start() EndIf EndIf EndFunc Link to comment Share on other sites More sharing options...
Guest Zak Posted June 17, 2004 Share Posted June 17, 2004 The problem is I cant make it go back to the Input Box when retry is pressed. Dunno how to do this? Link to comment Share on other sites More sharing options...
DaLiMan Posted June 17, 2004 Share Posted June 17, 2004 Start() Func Start() Start() EndFuncnever a good ideawhat's a better way then? Link to comment Share on other sites More sharing options...
DaLiMan Posted June 17, 2004 Share Posted June 17, 2004 OK, but your code didn't show the error correctly. I think this will work fine. $bOK = 0 While $bOK = 0 $ret = InputBox("Input Value","Please enter the word specified: test") If $ret = "test" Then MsgBox(0,"Correct!","Hopefully this has worked!") $bOK = 1 Else $msg = MsgBox(5,"Wrong","Do you want to try again?") If $msg = 2 Then Exit EndIf Wend Link to comment Share on other sites More sharing options...
Guest sbducker Posted June 17, 2004 Share Posted June 17, 2004 Is there a difference in function with these two operators If $Ret = "test"... and If $Ret == "test"... Link to comment Share on other sites More sharing options...
Developers Jos Posted June 17, 2004 Developers Share Posted June 17, 2004 (edited) There is a difference:If "a" = "A" then ; is trueIf "a" == "A" then ; is False== Tests if two values are equal (case sensitive if used with strings) Edited June 17, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nutster Posted June 17, 2004 Share Posted June 17, 2004 From Help File - Language Reference - Operators= Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5) == Tests if two values are equal (case sensitive if used with strings) David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Developers Jos Posted June 17, 2004 Developers Share Posted June 17, 2004 (edited) Looks like you are using the same helpfile as me... Edited June 17, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
pekster Posted June 17, 2004 Share Posted June 17, 2004 @Zak: You shouldn't be testing @error after a MsgBox command. Only use @error if the helpfile says it sets it for a function, and be sure to check what it means. Some functions will use it, and others wont. Often times, you'll get back both a return value and the @error flag will be set. They usually mean different things. However, the most common case when the @error flag is set is an indication of the function's failure of success. The return value is usually what you wish to get data out of (such as the click, some text, etc.) [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Nutster Posted June 18, 2004 Share Posted June 18, 2004 $bOK = 0 While $bOK = 0 $ret = InputBox("Input Value","Please enter the word specified: test") If $ret == "test" Then MsgBox(0,"Correct!","Hopefully this has worked!") $bOK = 1 ElseIf $ret == "" Then $msg = MsgBox(5,"Wrong","Do you want to try again?") If $msg = 2 Then Exit EndIf WendThere is a flag (undocumented for now) that will reject the Ok button, unless text appears in the text box. To use it, use "M" as the second character for the password string. To not do password character substituting, use a space as the first character. i.e. " M" will require at least one character needed for the return value before allowing the OK to be pressed. As you can tell, I have to figure out a better way to say this. This feature is in the current unstable and I will submit the updated docs for this one of these days. Hey documentation team, do you want to figure out how to document this feature? I may do more with the password string as I figure out more things to get InputBox to do. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
SlimShady Posted June 18, 2004 Share Posted June 18, 2004 There is a flag (undocumented for now) that will reject the Ok button, unless text appears in the text box. To use it, use "M" as the second character for the password string. To not do password character substituting, use a space as the first character. i.e. " M" will require at least one character needed for the return value before allowing the OK to be pressed. As you can tell, I have to figure out a better way to say this.This feature is in the current unstable and I will submit the updated docs for this one of these days. Hey documentation team, do you want to figure out how to document this feature? I may do more with the password string as I figure out more things to get InputBox to do.I can't use the bullet character, Chr(149), as a password character. Link to comment Share on other sites More sharing options...
Nutster Posted June 18, 2004 Share Posted June 18, 2004 That character is not defined for the font (Arial, I think) being used in the text box. Use the star ("*") for something like that. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
SlimShady Posted June 18, 2004 Share Posted June 18, 2004 That character is not defined for the font (Arial, I think) being used in the text box. Use the star ("*") for something like that.That's too common, I like the Windows XP bullet...Never mind, it doesn't matter..... 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