SA-MP Forums Archive
Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #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: Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) (/showthread.php?tid=440473)



Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) - [KHK]Khalid - 29.05.2013

Hello there, I was trying to do some trick with #define but failed. I wanted to make this code

pawn Code:
tData[0].a = 0;
work as same as this

pawn Code:
tData[0][a] = 0;
So I went for #define and wrote my code:
pawn Code:
#include <a_samp>

#define tData[%0].%1 \
    tData[%0][%1]
   
enum data {
    a,
    b
}

new tData[50][data];

public OnFilterScriptInit()
{
    tData[0].a = 0; // line 15
    return 1;
}
But, unfortunately it gave these errors/warnings:

Code:
(15) : warning 236: unknown parameter in substitution (incorrect #define pattern)
(15) : error 029: invalid expression, assumed zero
(15) : warning 215: expression has no effect
(15) : error 001: expected token: ";", but found "]"
(15) : error 029: invalid expression, assumed zero
(15) : fatal error 107: too many error messages on one line
I'll be graceful, if you help me fix this code or tell if this can be done in another way (maybe with some text editor?).

P.S. What I'm doing may sound pointless to some people, however this is so useful for me as I'm converting some script of mine from C++ to PAWN.


Re: Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) - SuperViper - 30.05.2013

I'm pretty sure you can't use special characters in defines that are used for other PAWN operations. The decimal point is used for float numbers.


Re: Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) - [KHK]Khalid - 30.05.2013

Uh, okay. I think using Find And Replace with regular expresssions is the only option, but I don't know crap about this.


Re: Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) - [KHK]Khalid - 30.05.2013

Uhm I see. So, how can I achieve what I want? I tried to put a space or an underscore but this wasn't a solution.


Re: Trying something using #define but failed - Warning: unknown parameter in substitution (incorrect #define pattern) - [KHK]Khalid - 30.05.2013

Absolutely brilliant! I like the way it's done, thank you.