Is this macro possible?
#1

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

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)