13.04.2013, 15:40
Today I (FINALLY) learned how to detect spaces in macro patterns! Because spaces are used to separate the pattern from the replacement, it was documented in pawn-lang.pdf that should you ever need to detect a space you could use "\32;" instead but I could never get it to work! Doing this:
Will NOT detect spaces before the brackets and remove them. Similarly this will not work:
That will NOT detect a call like "TEST2( 42)" - I'm still not sure why or what the exact rules governing how the macros work are, but this will work:
In that case, even just a leading space like in "TEST3( 42)" can be detected and removed. This lack of space detection has been the bane of my code for literally YEARS (if you don't believe me, that's what the point of this topic was). It is why this works:
But this gives multiple cryptic errors:
I knew the documentation claimed it could be done, but my repeated failed attempts led me to believe that maybe the SA:MP compiler version couldn't until I started really digging about in its code. Anyway, i am very happy about this and will be retrofitting certain bits of code to find any errors caused by bad spacing that I can now fix!
pawn Код:
#define TEST1\32;(%1) TEST1(%1)
pawn Код:
#define TEST2(\32;%1) %1
pawn Код:
#define TEST3(%0\32;%1) %1
pawn Код:
foreach (new i : Player)
pawn Код:
foreach ( new i : Player )