String interpolation
#1

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");
Reply
#2

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

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

";" 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
Reply
#4

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"); 
Reply
#5

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.
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)