Macro for detecting single argument, removing prefix - 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: Macro for detecting single argument, removing prefix (
/showthread.php?tid=563371)
Macro for detecting single argument, removing prefix -
Misiur - 15.02.2015
I almost managed to detect 0, 1, or multiple arguments:
pawn Код:
#define Foo(%0) @d:@c:@a:@b:Bar(%0)
#define @c:@a:@b:Bar() No arguments
#define @a:@b:Bar(%0,%1) More than one argument
#define @b:Bar(%0) Single argument
Foo(Hai)
Foo(Hai, Hello)
Foo(Hai, Hello, Dickbutt)
Foo()
pawn Код:
#pragma ctrlchar 0x5c
#pragma pack false
#pragma semicolon true
#pragma tabsize 8
#file test.pwn
#line 5
@d:@c:@a:Single argument
@d:@c:More than one argument
@d:@c:More than one argument
@d:No arguments
Now, I completely have no idea how to remove leftover detector tags, as @d macro is already defined. Is there a clear way to do this? With some second compiler pass dark magic?
Re: Macro for detecting single argument, removing prefix -
Vince - 15.02.2015
Or you could just use, you know,
numargs()? Where are you heading with this?
Re: Macro for detecting single argument, removing prefix -
Misiur - 15.02.2015
Of course, but I'm simply curious.