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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)