John
John

Reputation: 81

Comma at the end of True Basic if statement

I've been working on translating a simulation written in True Basic to C, and eventually into CUDA. Considering I have never worked with True Basic, let alone basic, everything has been going smooth. One item that I would like some clarification on is how the comma at the end of line 3 will affect the applications behavior.

Basically what I'm wondering is: Does line 4 execute only when the IF statement is evaluated to true (i.e. part of the if statement) or is the IF statement's evaluation (true or false) arbitrary in regards to the execution of line 4?

True Basic code snippet;

1. FOR i=1 to n
2.   FOR j=1 to anumber-1
3.     IF j = 1 or j > 4 then PRINT g(i,j),
4.     LET tg(j) = tg(j) + g(i,j)
5.   NEXT j
6. NEXT i

Upvotes: 1

Views: 201

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993611

From what I know about other BASIC dialects, the comma at the end of a print statement suppresses the automatic newline output after the printed data. The comma does not affect the scope of the if statement, so the let statement on line 4 executes regardless of the preceding condition.

Upvotes: 1

Related Questions