Re: GOSUB stack


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]

Posted by Grant Foraker on September 28, 2015 at 14:04:25: Uploaded files: 1

In Reply to: Re: GOSUB stack posted by Grant Foraker on September 18, 2015 at 14:02:53:

POPALL doesn't work consistently. Mostly got "GOSUB STACK UNDERFLOW" errors.

Based on Comet Woman's suggestion, I took a look at PROCTEST.IBS and NUMTEST.IBS.

I managed to pull stuff out of PROCTEST.IBS to make my own Subroutine program.
==============================================================================

! Declare Subroutines And Functions

Subroutine Subr(A$,C$)

Length 80 & Local A$, B$, C$
Length 32.5 & Local Z, A1

clear
Print (Et)
print 'TSUBR Subroutine test program'
print ''
print 'term$=';term$
print 'date$ =';date$
print 'day$=';day$
print 'partition$=';partition$
print 'numeric date = ';date
print 'version$ = ';version$
print ''

! Test Subroutine Call
Z = 9999
B$ = 'aaaaaaa'
let c$ = 'ccccccc'
print 'Before the call our argument, B$, has a value of ';B$
print 'and a1 has a value of ';a1
PRINT 'C$ is ';C$
Call Subr(B$,C$)
print 'After returning, b$ is ';b$
Print 'a1 is now "';a1;'"'
Print 'c$ is now ';C$
GOTO Exit
!------------------- DOESN'T WORK ----------------------------------------------
!!!!!DisplayMSGBOX:
!!!!! MSGBOX 'GOSUB in Subroutine'
!!!!! RETURN
!-------------------------------------------------------------------------------

Exit:
print 'done'
wait
RUN 'QMONITOR'
End

Subroutine Subr(A$,C$) ! Subroutine With A Local Numeric Var And A Global String Var

Length 5.0 & Local I ! Referenced, but address 0

GOSUB DisplayMSGBOX

Print 'Now in Subr... argument passed is '; A$
A$ = 'Subr Was Here ' + A$
Print 'We changed it to "';A$;'"'
i = len(a$)
Print "It's length is ";I
a1 = 12345
let c$ = 'xxxxx'
GOTO ExitProc

!------------------- DOES WORK -------------------------------------------------
DisplayMSGBOX:
MSGBOX 'GOSUB in Subroutine'
RETURN
!-------------------------------------------------------------------------------

ExitProc:
Procreturn
End
===================================================================

Had to throw out some junk to get down to the gist :(

And have some questions.

Subroutine Subr(A$,C$)
Call Subr(B$,C$)
Subroutine Subr(A$,C$)

I added C$ while testing. The original A$ then B$ back to A$ is original. What's important, what's junk?

Length 5.0 & Local I ! Referenced, but address 0

What does the comment mean? In the original, there was another I in the global area.
What would "IF I NE I" mean?

Also found that you can't GOSUB from a PROC back into the main program.


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

What is the name of the main Signature System's Product?  

Comments:

Optional Link URL:
Link Title:
Optional Image URL:

You may attach up to 5 files to your followup (see below):





Each file can be a maximum of 1MB in length Uploaded files will be purged from the server on a regular basis.


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]