Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simplistic misunderstanding about ; + "" in a print
#2
(09-19-2024, 01:37 AM)doppler Wrote: I may have a simplistic misunderstand about the use of semicolon, strings, plus sign and quotes in print statements.

1 q$=chr$(34)
2 print q$; "test"; q$
3 print q$ + "test" + q$

Output is "test" and "test" on separate lines.  I assumed ? q$; "test"; q$ would be an improper use of concatenation in a print statement.  I thought line 3 was the right way. But it works.
If I try to type q$"" the line changes to q$; "".  Auto corrects and makes me wonder.  I checked this output in the mother tongue "qb45".  Works like qb64.

If the +'s are not needed, do they take cycles and code unnecessary ?  Again wondering.
I know PRINT is most code producing and time wasting part of the source in qb64.

Thanks

When you use the + sign your creating another string var in memory that the print statement is then outputting.     So in 3 print only has 1 argument.        print can take multiple arguments in MOST BASIC's (and does in QB64PE) so the + construction is allowed but not necessary.    Your instincts are correct in that it does use a little extra CPU time to do the concatenation, though that's probably far outweighed by the CPU time it takes to do the actual output.
Reply


Messages In This Thread
RE: simplistic misunderstanding about ; + "" in a print - by ahenry3068 - 09-19-2024, 01:45 AM



Users browsing this thread: 7 Guest(s)