1

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
John
  • 81
  • 2
  • 5

1 Answers1

1

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Thanks for the swift reply. I was under the impression that a semicolon was used to suppress a carriage return. Do you know if there is a difference in the semantics of 'PRINT x,' as opposed to 'PRINT x;'? – John Dec 07 '11 at 07:37
  • Hmm, now you're really testing my memory. Now that you mention that a semicolon might have that function, I'm not completely sure what a comma at the end of a print statement does. However, I am still certain that the comma does *not* affect the scope of the `if` statement. – Greg Hewgill Dec 07 '11 at 07:39
  • I guess my response isn't critical to the application anyways, it was the scope of the IF statement that is. Thanks for clarifying this problem. – John Dec 07 '11 at 07:42