OPL programming noob questions

An alternative to the 'Software' section for larger program based threads and those that the author put up for discussion or comments.
toml12953
Posts: 31
Joined: Mon Dec 20, 2021 4:55 am

Re: OPL programming noob questions

Post 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
Post Reply