Sign in to follow this  
Followers 0
Guest Zak

New To This

15 posts in this topic

#1 ·  Posted (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 by Larry

Share this post


Link to post
Share on other sites



I copied your code and it seems to be working.

What's wrong?

Share this post


Link to post
Share on other sites

After a closer look you might be looking for something like this: :D

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

Share this post


Link to post
Share on other sites

The problem is I cant make it go back to the Input Box when retry is pressed. Dunno how to do this?

Share this post


Link to post
Share on other sites

Start()

Func Start()
  
     Start()

EndFunc
never a good idea
what's a better way then?

Share this post


Link to post
Share on other sites

OK, but your code didn't show the error correctly.

I think this will work fine. :D

$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

Share this post


Link to post
Share on other sites

Is there a difference in function with these two operators

If $Ret = "test"...

and

If $Ret == "test"...

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

There is a difference:

If "a" = "A" then ; is true

If "a" == "A" then ; is False

== Tests if two values are equal (case sensitive if used with strings)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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 Nuttall
Nuttall 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...

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

$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
Wend
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.


David Nuttall
Nuttall 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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 Nuttall
Nuttall 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...

Share this post


Link to post
Share on other sites

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.....

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0