Again, trying to work out if my logic is the simplest or if there's an easier, more logical way that I'm missing.
I have a program which uses program constants (not Windows), which are used as references to array elements, but are not necessarily consecutive. However, several of them need to be accessed alongside each other. A simple example is this:
Code: Select all
REM program constants
OPT_A = 0
OPT_B = 2
OPT_C = 5
REM others...
DIM opt%(9), result%(2)
REM test data
FOR I% = 0 TO 9
opt%(I%) = RND(2) = 1
NEXT
REM main routine
pos% = -1
IF opt%(OPT_A) THEN
pos% += 1
result%(pos%) = RND(10)
ENDIF
IF opt%(OPT_B) THEN
pos% += 1
result%(pos%) = RND(10)
ENDIF
IF opt%(OPT_C) THEN
pos% += 1
result%(pos%) = RND(10)
ENDIF
REM printout
IF pos% >= 0 THEN
FOR I% = 0 TO pos%
PRINT result%(I%)
NEXT
ENDIF
Code: Select all
REM program constants
OPT_A = 0
OPT_B = 2
OPT_C = 5
REM others...
DIM opt%(9), result%(2), optconst%(2)
REM test data
FOR I% = 0 TO 9
opt%(I%) = RND(2) = 1
NEXT
REM main routine
optconst%() = OPT_A, OPT_B, OPT_C
pos% = -1
FOR I% = 0 TO 2
IF opt%(optconst%(I%)) THEN
pos% += 1
result%(pos%) = RND(10)
ENDIF
NEXT
REM printout
IF pos% >= 0 THEN
FOR I% = 0 TO pos%
PRINT result%(I%)
NEXT
ENDIF
Matt