LoginLogin

gosub

Root / Programming Questions / [.]

funcooldudes101Created:
How do i stop a gosub after a certain amount of time? I would like to do that and then it continues the script

Do you know how to 'stop a gosub'? Do you know how to measure elapsed time?

Do you know how to 'stop a gosub'? Do you know how to measure elapsed time?
no. not in sb... is there a certain script for doing so?

Do you even know what the word 'script' means? Please stop posting nonsense, and read http://smilebasic.com/en/reference/

Do you even know what the word 'script' means? Please stop posting nonsense, and read http://smilebasic.com/en/reference/
well excuse me... i didn't get any knowledge from that

Do you even know what the word 'script' means? Please stop posting nonsense, and read http://smilebasic.com/en/reference/
well excuse me... i didn't get any knowledge from that
If you don't find it worth your effort to learn how to return from a subroutine, when it's quite plainly shown in the reference documentation, don't expect that others will find it worth their effort.

Do you even know what the word 'script' means? Please stop posting nonsense, and read http://smilebasic.com/en/reference/
well excuse me... i didn't get any knowledge from that
If you don't find it worth your effort to learn how to return from a subroutine, when it's quite plainly shown in the reference documentation, don't expect that others will find it worth their effort.
but can you continue script under the go sub??

Load [SYS] -> EX7ALIEN and look at the code, specifically from Line 38. As long as you have RETURN in each labeled subroutine, you can continue whatever code you want.

Load [SYS] -> EX7ALIEN and look at the code, specifically from Line 38. As long as you have RETURN in each labeled subroutine, you can continue whatever code you want.
thanks

This excerpt is descriptive too. It is the script to read the keyboard buttons as string K$ Dim N$ are instantly checked At the start of the script I is set as a timer counter And then I is given a Bouliean condition of Recursing or UnRecursing(i.e resetting the timer/counter)
K$ = INKEY$()
IF K$=="" GOTO @LOOP
I=0
@KLOOP
	IF K$==N$[I] GOTO @PLAY
	I=I+1
	IF I<KCNT GOTO @KLOOP
	GOTO @LOOP
a rewrite could make use of GOSUB
@KLOOP I = 0 @NLOOP @LOOP              @STRINGIFY
	K$ = INKEY$()
	IF K$=="" GOSUB @PLAY GOTO @KLOOP
	ELSE GOSUB @INC GOTO @NLOOP ENDIF
	GOTO @LOOP
	@INC I=I+1:IF I<KCNT THEN RETURN ELSE GOTO STRINGIFY ENDIF:
@PLAY
	K$==N$[I]
	P=F*I
	BEEP V,P
	RETURN
!??!?!?!??!? I have no idea, the program faults @STRINGIFY because goto as gosub it is like the 1+2+3+4 into infinity forever thing something to do with bytestrings... and the memory usage of gosubs 5 words or its unlucky or something nobody knows.

Stop a GOSUB after a certain amount of time? Try doing this..
VAR N=120 'Can be any number
@LOOP
T=T+1
IF T<=N THEN
   GOSUB @LOOP2
ENDIF
VSYNC V
GOTO @LOOP

@LOOP2
BEEP
RETURN
This will repeat the loop until T is greater than or equal to N.

Try doing this..
Have you tried doing this?

Try doing this..
Have you tried doing this?
Uh no. Not at the moment. I've used this in the past plenty of times to know it works.

Try doing this..
Have you tried doing this?
Uh no. Not at the moment. I've used this in the past plenty of times to know it works.
Ah, I think I understand. Your code will stop repeatedly executing GOSUB. I had interpreted the original question, how to stop "a gosub", differently (a run-time instance, rather than a textual instance). Perhaps I misunderstood.