Jump to content

Recommended Posts

Posted

receive error:

Too many Else for If

WinActivate("")
sleep(1000)
If Random() < 0.7 Then  ; Too many else, to If. How should I do this? :S
    Send("{m}")
    Send("{m}")
Else
    Send("{l}")
    Send("{l}")
Else
    Send("{R}")
    Send("{Enter}")
Else
    Send("{Space}")
Else
    Send("{I}")
    Send("{I}")
Else
    Send("{W}")
Else
    Send("{S}")
Else
    Send("{Q}")
Else
    Send("{E}")
Else
    Send("{N}")
    Send("{N}")
Else
    Send("{l}")
    Send("{l}")
Else
    Send("{A}")
    Send("{E}")
Else
    Send("{X}")
Else
    Send("{z}") 
Else
    Send("{B}")
    Send("{B}")
Endif
Posted

April Fools day came early this year...you can't have multiple "Else" in an If/Else condition. You can have multiple "ElseIf".

Posted (edited)

There can only be one "Else"

WinActivate("")
Sleep(1000)

$Random = Random(3)

If $Random < 0.7 Then  ; Too many else, to If. How should I do this? :S
    Send("{m}")
    Send("{m}")
ElseIf $Random < 0.8 Then
    Send("{l}")
    Send("{l}")
ElseIf $Random < 0.9 Then
    Send("{R}")
    Send("{Enter}")
ElseIf $Random < 1.0 Then
    Send("{Space}")
ElseIf $Random < 1.2 Then
    Send("{I}")
    Send("{I}")
ElseIf $Random < 1.3 Then
    Send("{W}")
ElseIf $Random < 1.4 Then
    Send("{S}")
ElseIf $Random < 1.5 Then
    Send("{Q}")
ElseIf $Random < 1.6 Then
    Send("{E}")
ElseIf $Random < 1.7 Then
    Send("{N}")
    Send("{N}")
ElseIf $Random < 1.8 Then
    Send("{l}")
    Send("{l}")
ElseIf $Random < 1.9 Then
    Send("{A}")
    Send("{E}")
ElseIf $Random < 2.0 Then
    Send("{X}")
ElseIf $Random < 2.1 Then
    Send("{z}")
Else ; there can only be one else
    Send("{B}")
    Send("{B}")
EndIf

8)

.....Too slow.... :)

... fixed ridiculous code...

Edited by Valuater

NEWHeader1.png

Posted

Valuater, calling Random() on every ElseIf defeats the purpose of having a condition at all. I'm not sure what this is doing.

Posted (edited)

I dont know what youre planning with this code, but it looks to me the situation that calls for a Switch(), not a huge If, ElseIf, ElseIf.......

WinActivate("")
Switch Random() 
    Case 0.1 To 0.7
        Send("{m}")
        Send("{m}")
    Case 0.7 To 0.9
        Send("{l}")
        Send("{l}")
    Case 1 To 3
        Send("{R}")
        Send("{Enter}")
    Case 420
        Send("Smoke More")
EndSwitch
; etc etc etc

Edit: If you want to look into more on the Switch() function, make sure you also look at ContinueCase. The example in that help file is more useful than in the Switch() one.

Edited by murdock

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
×
×
  • Create New...