Page 2 of 2

Re: OPL programming noob questions

Posted: Thu Nov 24, 2022 3:23 am
by toml12953
Daren wrote: Wed Nov 23, 2022 8:34 pm Thanks for the answer @toml12953 It is structure and program flow aspects which I can’t seem to find a lot of info/examples to do a lot of what I want, without using GOTO, for example multiple choice GET/KEY/INPUT branches, which functions were you alluding to that can approximate GOSUB functionality?
You can create user-defined functions which can be called like subroutines. Any shared variables could be put in the parameter list or, to be more like an actual GOSUB, you can declare the variables as GLOBAL.

Code: Select all

PROC one:
GLOBAL a%
PRINT a%
two:
GET
ENDP
PROC two:
a%=2 REM Sees a% declared in one:
PRINT a%
ENDP
This is like the BASIC code:

Code: Select all

10 PRINT a
20 GOSUB 100
30 A$=INPUT$(1)
40 STOP
100 A=2
110 PRINT A
120 RETURN