Sign in to follow this  
Followers 0
complex

Case Statment Problems

6 posts in this topic

Hello, Im new but I really like this program, and I plan to do a lot with it. I have been working on a script but I have run into a problem or twenty. I have looked at the help guide, and the FAQ, I have also searched for the question, but I did not find anything that I could use. So here is the issue.

I want to nest a few things into a case statement. This is what I have at the moment.

Select
    case $Duration[0] <= 0 ; this case should never happen, just in case
        Send("{$Spells[0][0]}")
            Sleep($spells[0][1])
            $Mana += $Spells[0][2] ; this is the only time mana can go neg, and it
                if $Mana < 0 Then  ; never should
                    $Mana = 0
            $Duration[0]=$Spells[0][3] ; spell is insta. duration is affect by cool down
            Call cooldows($Spells[0][1])

    case $Duration[1] <= 0
        Send("{$Spells[1][0]}")
            Sleep($spells[1][1])
            $Mana += $Spells[1][2]
            Call cooldows($Spells[1][1])
            $Duration[1]=$Spells[1][3] ; spell is not insta. duration is NOT affected by cool down

    case $Duration[2] <= 0
        Send("{$Spells[2][0]}")
            Sleep($spells[2][1])
            $Mana += $Spells[2][2]
            $Duration[2]=$Spells[2][3]
            Call cooldows($Spells[2][1])

    case $Duration[3] <= 0
        Send("{$Spells[3][0]}")
            Sleep($spells[3][1])
            $Mana += $Spells[3][2]
            Call cooldows($Spells[3][1])
            $Duration[3]=$Spells[3][3]

    case $Duration[4] <= 0
        Send("{$Spells[4][0]}")
            Sleep($spells[4][1])
            $Mana += $Spells[4][2]
            $Duration[4]=$Spells[4][3]
            Call cooldows($Spells[4][1])

    case $Duration[5] <= 0
        Send("{$Spells[5][0]}")
            Sleep($spells[5][1])
            $Mana += $Spells[5][2]
            Call cooldows($Spells[5][1])
            $Duration[5]=$Spells[5][3]

EndSelect

The problem here is that when I try to run the script it simply says that the case statement on line 62 does not match a select?

Does that mean I can only have one command after entering a case, or am I just missing something.

Share this post


Link to post
Share on other sites



The problem here is that when I try to run the script it simply says that the case statement on line 62 does not match a select?

Does that mean I can only have one command after entering a case, or am I just missing something.

There is no line 62 in the above script.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

There is no line 62 in the above script.

I should have been more clear, I understand that there is no line 62 above, I only posted a small portion of the script. The error (line 62) in my code is the second case in the list.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well, does this work ?

Select
    case $Duration[0] <= 0
        MsgBox (0,"test","0")

    case $Duration[1] <= 0
        MsgBox (0,"test","1")

    case $Duration[2] <= 0
        MsgBox (0,"test","2")

    case $Duration[3] <= 0
        MsgBox (0,"test","3")

    case $Duration[4] <= 0
        MsgBox (0,"test","4")

    case $Duration[5] <= 0
        MsgBox (0,"test","5")

EndSelect
Edited by Inverted

Share this post


Link to post
Share on other sites

I think so, since the duration is zero for all of the cells at this point msg box just keeps saying 0,test. But it compiles and runs.

Share this post


Link to post
Share on other sites

Well I don't know why it did not work before, but now the code works.

Here is the working snippet.

While 1
    Select
    case $Duration[0] <= 0
        send("{t}")
        $Mana += $Spells[0][2]
            If $Mana < 0 Then $Mana = 0;
        $Duration[0] = $Spells[0][3]
        CoolDonws($Spells[0][1])
        Sleep($Spells[0][1])

    case $Duration[1] <= 0
        send("{1}")
        $Mana += $Spells[1][2]
        $Duration[1] = $Spells[1][3]
        CoolDonws($Spells[1][1])
        Sleep($Spells[0][1])

    case $Duration[2] <= 0
        send("{2}")
        $Mana += $Spells[2][2]
        $Duration[2] = $Spells[2][3]
        CoolDonws($Spells[2][1])
        Sleep($Spells[0][1])

    case $Duration[3] <= 0
        send("{3}")
        $Mana += $Spells[3][2]
        $Duration[3] = $Spells[3][3]
        CoolDonws($Spells[3][1])
        Sleep($Spells[0][1])

    case $Duration[4] <= 0
        send("{4}")
        $Mana += $Spells[4][2]
        $Duration[4] = $Spells[4][3]
        CoolDonws($Spells[4][1])
        Sleep($Spells[0][1])

    case $Duration[5] <= 0
        send("{5}")
        $Mana += $Spells[5][2]
        $Duration[5] = $Spells[5][3]
        CoolDonws($Spells[5][1])
        Sleep($Spells[0][1])

EndSelect

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