SA-MP Forums Archive
Is this macro possible? - 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: Is this macro possible? (/showthread.php?tid=280069)



Is this macro possible? - CaHbKo - 30.08.2011

I've been wondering if it's possible to make this
pawn Код:
if(var == 3 ... 5)
be read by compiler like this
pawn Код:
if(3 <= var <= 5)
I tried to make a macro for that but I'm not very familiar with macros. Any ideas?


Re: Is this macro possible? - CaHbKo - 30.08.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, but the only way to do it as you want is to name the macro "if", which isn't that nice (as you're redefining a keyword):

pawn Код:
#define if%0(%1==%2...%3) if(%2<=%1<=%3)
Note that, although it isn't used, "%0" is important to account for different spacing styles (for example you wrote "if(", whereas I write "if (" - this macro will cover both cases).
Thanks. But would it work if I do something more complex like this
pawn Код:
if(Function() == true && (var1 > 10 || var2 == 1...3) || var3 != 100...999)