Kalevi Newbie
 Joined: 28/09/2021 Location: AustraliaPosts: 9 |
Posted: 03:58am 27 Jun 2023 |
|
|
|
In 1988 I was testing something that required checking all the permutations to be checked. I wrote a program to compute all the permutations of N items in an orderly manner (eg. numbers 1 2 3 4 to 4 3 2 1 in numerical order). I wrote the program using MSX basic. Recently I rewrote the same program using my CMM2 in MM basic. It run without any changes. Now I dedicided to write it again without line numbers. Error message: Error in line 18: Unknown command (line 18 has the IF command).
Section of the original program:
170 IF S>Q THEN 180 ELSE 210 180 C(I)=1 190 A(I)=0 200 GOTO 230 210 C(I)=0 220 A(I)=A(I)+C(I+1) 230 C(N)=1 240 NEXT I
Section of the program without the line numbers
IF S>Q THEN CCC1 ELSE CCC2 CCC1: C(I)=1 A(I)=0 GOTO CCC3 CCC2: (I)=0 A(I)=A(I)+C(I+1) CCC3: C(N)=1 NEXT I
Why the error? NB -Now I notice I could have used: IF <=Q THEN 210 (simpler) Kalevi |