06-18-2003, 09:04 AM
you want, for example, to call a subroutine MYSUB and pass variables A and B to it or from it, your SUB statement might look like
SUB MYSUB(A, B)
You would then pass variables to MYSUB via
CALL MYSUB(A, B)
or
CALL MYSUB(C, D)
In the latter case, when MYSUB gets called, C will go into MYSUB as what it calls "A" and D will go into MYSUB as what it calls "B". (You don't have to use the same variable names in the CALL statement as you used in the SUB statement. But they have to be of the same type.) Or if MYSUB defines or modifies A and B they will be passed back to the calling routine in the same way. As an example,
C = 5
D = 10
PRINT C, D, " Before call."
CALL MYSUB(C, D)
PRINT C, D, " After call."
END
SUB MYSUB(A, B)
A = 2 * A
B = 3 * B
END SUB
Before calling MYSUB, C and D had one set of values. After calling it, they have another set.
SUB MYSUB(A, B)
You would then pass variables to MYSUB via
CALL MYSUB(A, B)
or
CALL MYSUB(C, D)
In the latter case, when MYSUB gets called, C will go into MYSUB as what it calls "A" and D will go into MYSUB as what it calls "B". (You don't have to use the same variable names in the CALL statement as you used in the SUB statement. But they have to be of the same type.) Or if MYSUB defines or modifies A and B they will be passed back to the calling routine in the same way. As an example,
C = 5
D = 10
PRINT C, D, " Before call."
CALL MYSUB(C, D)
PRINT C, D, " After call."
END
SUB MYSUB(A, B)
A = 2 * A
B = 3 * B
END SUB
Before calling MYSUB, C and D had one set of values. After calling it, they have another set.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.