• Welcome to Jose's Read Only Forum 2023.
 

Console print statement question

Started by Ed Davis, July 19, 2022, 02:33:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ed Davis

Using 040, console.inc.

This works:
  print "limit: " & limit & " tmp: " & tmp & " mod(tmp, limit): " & mod(tmp, limit) & cr

But this won't compile. 
  print "limit: " limit " tmp: " tmp " mod(tmp, limit): " mod(tmp, limit) cr


Gives:

ERROR:  unexpected comma in array index
WORD:   tmp
IN:     rnd
LINE:   366
FILE:   "main source"


This (leaving out the mod()) works:

  print "limit: " limit " tmp: " tmp " mod(tmp, limit): " cr


Is it better to always use "&" when concatenating things?

Charles Pegge

Put the whole print expression between  brackets,  including the cr. The cr must be part of the expression

Ed Davis

Quote from: Charles Pegge on July 19, 2022, 03:31:02 PM
Put the whole print expression between  brackets,  including the cr. The cr must be part of the expression

I tried:
print("limit: " limit " tmp: " tmp " mod(tmp, limit): " mod(tmp, limit) cr)

And got:

ERROR:  unexpected comma in array index
WORD:   tmp
IN:     rnd
LINE:   366
FILE:   "main source"


But this is no biggie, as the "&" version works fine.

By the way, I really, really appreciate the "-m" switch!