View Single Post
Old 19 August 2015, 23:24   #254
Registered User

Dunny's Avatar
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 661
Originally Posted by Megol View Post

Alternatively you can join strings and use them as one argument, again, just like with any other command:
Print "Hello "+name$+" and welcome!"
a$ = "Hello "+name$+" and welcome!"
Yes. If the BASIC one uses support it. And if one doesn't need the code to be portable to other BASICs which probably uses a different mechanism.
Can you name a BASIC that doesn't support string concatenation with the "+" operator?

In the original Dartmouth BASIC (and indeed any BASIC), the PRINT command requires one of two things as a print-item - either a print separator or an expression. If your BASIC supports such things as

LET a$=b$+c$

Then PRINT will handle inline string concatenation as part of its expression evaluator.

Furthermore, I'd like to see how Blitz, using its commas to separate print items, manages to output a newline or tab? I suspect (I've not investigated though!) that it must use special characters inline in the string arguments?

Dartmouth used the semicolon for concatenation of items (both strings and numerics which by their nature cannot be concatenated using an operator without a conversion function on one of the terms), the comma for tabulation and the apostrophe for newline/carriage return. It's not a "hack", but I agree that it's the only command that uses these conventions - using them with a string variable assignment wouldn't work and would break delineation of the two datatypes.

Dunny is offline  
Page generated in 0.05136 seconds with 9 queries