Macros for literal strings

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Macros for literal strings

Post by Kaeru Gaman »

it is NOT easier to read, it is NOT BASIC, it is NOT the default settings.

so what?
oh... and have a nice day.
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Macros for literal strings

Post by Blue »

Kaeru Gaman wrote:it is NOT easier to read, it is NOT BASIC, it is NOT the default settings.

so what?
But , as Trond put it in his original suggestion,
(1) it wouldn't break any existing code and it's a very familiar way of building strings for many with experience in other languages.
(2) it's a very flexible way of building strings
(3) it's already familiar to many with experience in other languages
(4) some features of PureBasic already are not traditional BASIC. This would be a minor, but useful, detail, to speed coding along.

Finally, the example you provided displayed very clearly and readably in the IDE, with or without the +, thanks to syntax highlighting.

From my perspective, It would definitely be a plus (excuse the pun...) in PureBasic.
I see no cons at all here. Only gravy :D
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Macros for literal strings

Post by STARGÅTE »

Please let the macros as they are, because I use something heir:

Code: Select all

Macro Int(Value) :_DQ_+Str(Value)+_DQ_
EndMacro 
Macro Float(Value) :_DQ_+StrF(Value)+_DQ_
EndMacro 
Macro String(Value) :_DQ_+Value+_DQ_
EndMacro 
Macro _DQ_:"
EndMacro 


Long.l = 128 
Debug "Long = Int(Long) :-)" 

Pi.f = #PI 
Value$ = "PI is Float(Pi), nice?" 
Debug Value$
Debug "Any String is: String(Value$) ."
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Re: Macros for literal strings

Post by AND51 »

Sorry, I only read the first page. But when I read this:
PB wrote:

Code: Select all

; Pseudo-code.
StringMacro PB
  PureBasic
EndStringMacro

MessageRequester("","This PB example was coded in PB")
When run, the above code would output this:
Image
It seems to my like an attempt to get string interpolation like you have in Perl or PHP:

Code: Select all

# Perl Code

$variable="PureBasic"
print "I love $variable!"
Outputs "I love PureBasic!"


// Edit:
Well, and there is no String Interpolation in PureBasic.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply