MattW
17-01-2013, 13:00
Hi,
I'm still in the transitional period between QBASIC and TB, so please bear with me here.
I always research things like this before posting, I've found some threads regarding the GOTO command but I did not understand the conclusion of how to structure this instead of using GOTO and GOSUB
FOR a=1 to 20
GOSUB displayinfo
NEXT a
' maybe the gosub command is needed elsewhere...
FOR a=1 to 50
GOSUB displayinfo
NEXT a
STOP
displayinfo
PRINT "The counter is currently at ";a
RETURN
Also, I used to GOTO command almost everywhere in QBASIC, like...
IF a<>0 THEN GOTO jumpover1:
PRINT "ahhh! A is not Zero!!"
GOSUB dosomethingwhenaisnotzero
jumpover1:
PRINT "So now I will continue..."
---------
Could I please ask for someone to show me an alternative to the above?
From what I've read, I would adapt my coding to use the FUNCTION commands. These were in QBASIC also, but I think I only used it once (about 20 years ago!!) and I do not know how this will 'replace' my GOTO method.
Many thanks,
Matt
I'm still in the transitional period between QBASIC and TB, so please bear with me here.
I always research things like this before posting, I've found some threads regarding the GOTO command but I did not understand the conclusion of how to structure this instead of using GOTO and GOSUB
FOR a=1 to 20
GOSUB displayinfo
NEXT a
' maybe the gosub command is needed elsewhere...
FOR a=1 to 50
GOSUB displayinfo
NEXT a
STOP
displayinfo
PRINT "The counter is currently at ";a
RETURN
Also, I used to GOTO command almost everywhere in QBASIC, like...
IF a<>0 THEN GOTO jumpover1:
PRINT "ahhh! A is not Zero!!"
GOSUB dosomethingwhenaisnotzero
jumpover1:
PRINT "So now I will continue..."
---------
Could I please ask for someone to show me an alternative to the above?
From what I've read, I would adapt my coding to use the FUNCTION commands. These were in QBASIC also, but I think I only used it once (about 20 years ago!!) and I do not know how this will 'replace' my GOTO method.
Many thanks,
Matt