09-19-2024, 09:04 PM
(09-19-2024, 08:03 PM)DSMan195276 Wrote:(09-19-2024, 01:07 PM)SMcNeill Wrote: No. The reason is just ease of translating.It's actually a behavior difference Imagine instead of string literals you're printing the results of some functions:
Code: (Select All)Print func1$(1); func2$(20)
Print func1$(1) + func2$(20)
Those two lines don't behave the same if func2$(20) produces an error - with the first one you'll see the result of func1$(1) on the screen, with the second you won't see anything.
The same logic applies if func2$(20) just doesn't return for an extended time (maybe it has a SLEEP or does a long computation). In the first case you'll see the partial output from func1$(1) on screen, in the other you won't see anything until func2$(20) finishes.
PRINT "abc"; "def"; "ghi" <-- this will print in three separate statements like:
PRINT "abc";
PRINT "def";
PRINT "ghi"
Each one will test to see if they fit on the line, or if they need to word wrap, or if they need to perform a screen scroll. (Or, as you point out, if they produce an error along the way.)
PRINT "abc" + "def" + "ghi"
The above will join all those fragments together to make "abcdefghi" and then only perform the word wrap once on that whole joined together line of text. It'll only do the screen scrolling and such that one time as well.
If anyone was thinking that I was saying those two methods are identical, then I apologize. They're not. In many cases, however, one can fairly freely swap between the two styles and not see much difference -- though there are times when BOTH ways might bite you in the butt, if you're not careful. Think about how long your possible strings are, and how they might word wrap, and then go from there.
PRINT CHR$(34); "test"; CHR$(34) <-- as suggested by doppler, this MIGHT end up printing one of those three elements on the top line of text, and drop the others down to the next line.
PRINT CHR$(34) + "test" + CHR$(34) <--- this would make certain that those three elements were combined. Either all three will fit up on the top line, or else all three elements will be printed to the next line.
Now, if you're over on the left side of the line to start with, it's not going to matter as all three elements will fit on that single line to begin with. BUT, if you're only a few characters from the right edge of the screen, the two are going to have much different word wrap actions happen with them.
They're not *exactly* the same, and it's not a case of "This is always better than that." Always remember to use what works best in your own particular use case. All we can really do here is just kind of draw attention to the behavior and hopefully make folks aware of what's going on so they can make informed decisions on what might work and perform best in their particular situations.