Macros: # doesn't work inside strings

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Macros: # doesn't work inside strings

Post by Trond »

Code: Select all

Macro LocalizedFile(Name)
  "File#Name"
EndMacro
LocalizedFile(Test)
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Nothing inside a literal string is replaced. This is the intended behaviour.
Putting only "Name" inside will not have it replaced either.

There are a number of ways to get this done. Like this one:

Code: Select all

Macro _QUOTE
"
EndMacro

Macro _STRING(s)
_QUOTE#s#_QUOTE
EndMacro

Macro LocalizedFile(Name)
  _STRING(File#Name)
EndMacro
LocalizedFile(Test)
quidquid Latine dictum sit altum videtur
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Thank you, I didn't think it was possible to do it.
Post Reply