Sign in to follow this  
Followers 0
vickerps

Different Paths

8 posts in this topic

Ok i am guilty of use the goto command

I agree that it shouldn't be used any more but I am wondering how right to different path

for example if you choose yes to a text box you are a ask and the script goes in a completely different direction to if you choose no

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$answer = MsgBox(3,"So?","Do you want to do the thing?")
Select
 Case $answer = 6 
 GoSub,ansno
 Case $answer = 7
 GoSub,anscan
 Case $answer = 2
 GoSub,ansyes
EndSelect

exit

Func ansno()
;--------The user pressed no
EndFunc

Func ansyes()
;--------The user pressed yes
EndFunc

Func anscanc()
;--------The user pressed cancel
EndFunc

Edited by ezzetabi

Share this post


Link to post
Share on other sites

Thanks for the quick reply

What do you do if there a sub paths ?

$answer = MsgBox(3,"So?","Do you want to do the thing?")

Select

Case $answer = 6

GoSub,ansno

Case $answer = 7

GoSub,anscan

Case $answer = 2

GoSub,ansyes

EndSelect

exit

Func ansno()

;--------The user pressed no

$answer = MsgBox(3,"So?","Do you want to do another thing?")

EndFunc

Func ansyes()

;--------The user pressed yes

EndFunc

Func anscanc()

;--------The user pressed cancel

EndFunc

Share this post


Link to post
Share on other sites

Or

$answer = MsgBox ( 3, "Hmm?", "Yes or No?" )

if     $answer = 6 then
   MsgBox ( 0, "", "You said Yes." )
elseif $answer = 7 then
   MsgBox ( 0, "", "You said No." )
elseif $answer = 2 then
   MsgBox ( 0, "", "You said Maybe." )
endif

Share this post


Link to post
Share on other sites

just nest ...

Every func is a separate program..

Share this post


Link to post
Share on other sites

Is there any more example of "Gosub" anywhere because when i try i keep getting a error Do you have to declare Func or something

example of script.

GoSub, terminal

Func terminal()

;----does something

Error created

GoSub, terminal

ERROR

Error:unknown function name

Share this post


Link to post
Share on other sites

V3 does not contain a GoSub command. What you do is write the function name with round brackets after it, e.g.

terminal()

Func terminal()
   ;----does something
EndFunc ; Don't forget this!

GrahamS

Share this post


Link to post
Share on other sites

figure it out via the examples

Thankyou Thou

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