Multiline define pattern - 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: Multiline define pattern (
/showthread.php?tid=364948)
Multiline define pattern -
Misiur - 01.08.2012
Hello - this time I need help. I'm using something like:
pawn Код:
#define merge(%0,%1) \
format(%0, sizeof(%0), %1)
Yup, I'm lazy. Anyway: it works fine for something like:
pawn Код:
new str[32];
merge(str, "%s: %s", "Pancakes are", "AWESOME");
But sometimes in my script I have something like:
pawn Код:
new str[499+1];
merge(str, "%s, %d, %s, %s, %s, %d, $%d, $%d",
UData[playerid][uname], UData[playerid][age], UData[playerid][sex], "Something", UData[playerid][strength], UData[playerid][uid], UData[playerid][cash], UData[playerid][bank_cash]);
Format accepted my multline syntax, but define didn't and I get
Quote:
error 017: undefined symbol "merge"
|
Can I somehow make define to respect multiline syntax too?
Re: Multiline define pattern -
Vince - 01.08.2012
Know when to use functions and when to use definitions! You need a function that can take a variable number of parameters. But honestly, don't be lazy and just type that shit out. A function will also be slower.
Re: Multiline define pattern -
Misiur - 01.08.2012
Well, as you can read in wiki
Quote:
One interesting fact about the parameters is that if you have too many, the last one is all the extra ones.
|
I don't want a function, I just want silent substitution