Jump to content
Sign in to follow this  
bobheart

error

Recommended Posts

bobheart

Conditionally run statements.

Related

If...Then, If...Else...EndIf

Example

Select
    Case $var = 1
        MsgBox(0, "", "First Case exp[b][/b]ression was true")
    Case $var2 = "test"
        MsgBox(0, "", "Second Case exp[b][/b]ression was true")
    Case Else
        MsgBox(0, "", "No preceding case was true!")
EndSelect

---------------------------

AutoIt Error

---------------------------

Line 2 (File "E:\Programs\AutoIt3\Examples\june4\game_command4.au3"):

Case $var = 1

Case ^ ERROR

Error: Variable used without being declared.

Share this post


Link to post
Share on other sites
jpm

Your select is OK if you set $var to somevalue before execution of the select.

just add before $var= whatever the value should be :D

Share this post


Link to post
Share on other sites
bobheart

Thats right out of the help file . I didn't make it or change it .

Should it not run if it is an example ?

Share this post


Link to post
Share on other sites
jpm

Thats right out of the help file . I didn't make it or change it .

Should it not run if it is anĀ  example ?

All example in this section you are refering are to illustrate coding not to be run as is.

Usually the ones in the Function reference run except doc error.

Share this post


Link to post
Share on other sites
cowsmanaut

if you'd like to try something that would actually run based on that.. I did something here for you..

$var = InputBox("Computer Yesman", "do you like Apples?", "", "")

Select
   Case $var = "no"
       MsgBox(0, "", "I don't like them either")
   Case $var = "yes"
       MsgBox(0, "", "Oh yeah.. aren't they awesome?")
   Case Else
       MsgBox(0, "", "make up your mind!")
EndSelect

it should illustrate how cases are being used.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.