SA-MP Forums Archive
String interpolation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: String interpolation (/showthread.php?tid=602977)



String interpolation - Misiur - 16.03.2016

Hi guys, I forgot how to use string interpolation. Is there some post about it somewhere? Example of what I remembered (but isn't working of course)

pawn Код:
#define MAX_CUSTOM (5);
//...
print("I like " #MAX_CUSTOM " cakes");



Re: String interpolation - jlalt - 16.03.2016

Instead of ( ) use " " and you don't need ; in it example:
PHP код:
#define MAX_CUSTOM "5"

//...
print("I like " #MAX_CUSTOM " cakes"); 



Re: String interpolation - Misiur - 16.03.2016

";" was a typo, sorry about that.
I know about inserting quoted defines, but I need the value to be a number, and that's the thing I can't remember


Re: String interpolation - jlalt - 16.03.2016

Quote:
Originally Posted by Misiur
Посмотреть сообщение
";" was a typo, sorry about that.
I know about inserting quoted defines, but I need the value to be a number, and that's the thing I can't remember
do you mean something like that :3?
PHP код:
#define MAX_CUSTOM 5
//...
print("I like "#MAX_CUSTOM" cakes"); 



Re: String interpolation - Gammix - 16.03.2016

Its because Macros are just text replacements, you cannot have this:
Quote:

print("I like "#MAX_CUSTOM" cakes");
I like "#(5)" cakes

You need to remove those brackets where you declare it.


Re: String interpolation - Misiur - 16.03.2016

Ah, missed that one. Thought # wouldn't care bout parentheses. Thanks!