1

I am converting GW-BASIC code to C# and have very limited experience in BASIC languages in general. I am trying to understand how IF...THEN...GOTO statements behave. For example, I have the following statement:

85 IF M(3,1)>M(2,1) THEN 95
90 M(3,1)=M(3,1)+P2
95 Z1=R1*(90.567-41.685/M(2,3))

My question is this: if the condition at line 85 is not met, will it still execute code at line 95, or does it skip it?

Any direction would be greatly appreciated...

Tom Miller
  • 536
  • 1
  • 4
  • 14
  • This is primitive code in an older basic than QBASIC. It runs in QBASIC just fine though. – Joshua Dec 20 '11 at 02:36
  • If you have an functioning QBasic environment, why don't you setup a little test using the above logic and some print statements? – BenSwayne Dec 20 '11 at 02:43
  • @Joshua yeah, I realized that after digging into it...I updated the question to reflect that... – Tom Miller Dec 22 '11 at 15:19

4 Answers4

4

Yes, regardless of the evaluation of the Boolean condition at line 85, line 95 will be executed BUT if 85 evaluates to true, then line 90 will be jumped and thus won't be executed.

Wilmer
  • 1,025
  • 5
  • 9
2

It will execute the code at line 95. The then statement cause the program to jump to line 95 and execute that line.

It's equivalent to this:

if ( M[3,1] <= M[2,1] ) {
   M[3,1] = M[3,1] + P2
}
Z1=R1*(90.567-41.685/M[2,3])
shf301
  • 31,086
  • 2
  • 52
  • 86
1

Apparently the code snippet has a pseudo IF/ELSE structure, the logic seems like:

If the condition of line 85 is not meet then QBasic continues with 90 and then 95. If the condition of line 85 is meet then QBasic continues with 95 and forward.

Ernesto Campohermoso
  • 7,213
  • 1
  • 40
  • 51
0

THEN 95 is short for THEN GOTO 95, which jumps the execution pointer to line 95.

REMLINE.BAS is a program to remove line numbers from Microsoft Basic Programs. It removes only those line numbers that are not the object of one of the following statements: GOSUB, RETURN, GOTO, THEN, ELSE, RESUME, RESTORE, or RUN.

BaCon and BCX can turn your BASIC into C.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124