SA-MP Forums Archive
From function to Macro - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: From function to Macro (/showthread.php?tid=140829)



From function to Macro - UsaBoy91 - 10.04.2010

I made a function , but i need it as a macro ...

pawn Код:
Checkx(string[])
{
    if(!strcmp(string,"Drive",true) || !strcmp(string,"Fly",true)) return 1;
    return 0;
}
This is good , but if i try to make it macro ... :

pawn Код:
#define Checkx(%0) if(!strcmp(%0,"Drive",true) || !strcmp(%0,"Fly",true)) return 1; else return 0;
I get errors ...


Re: From function to Macro - ¤Adas¤ - 10.04.2010

pawn Код:
#define Checkx(%0) return !strcmp(%0, "Drive", true) || !strcmp(%0, "Fly", true);
Try this, maybe it will work


Re: From function to Macro - UsaBoy91 - 10.04.2010

somebody else ?


Re: From function to Macro - Jefff - 10.04.2010

Try this
Код:
#define Checkx(%0) (!strcmp(%0, "Drive", true) || !strcmp(%0, "Fly", true)) ? 1 : 0;



Re: From function to Macro - ¤Adas¤ - 10.04.2010

Quote:
Originally Posted by Jefff
Try this
Код:
#define Checkx(%0) (!strcmp(%0, "Drive", true) || !strcmp(%0, "Fly", true)) ? 1 : 0;
It depends on this func. usage.


Re: From function to Macro - IownU - 10.11.2010

Use #

#%0

I recommend starting from %1 in defines though.


EDIT: Oh, so that wasn't the problem. Uhm, defines can only use one " if() something; "
Why don't you just keep the function and make it like this then:

Код:
#define Checkx(%1); FunctionCheckx(#%1);

Checkx(noob);
Well you get the idea..


Re: From function to Macro - rs.pect - 10.11.2010

pawn Код:
#define Checkx(%0) (!strcmp(%0, "Drive", true) || !strcmp(%0, "Fly", true))



Re: From function to Macro - legodude - 10.11.2010

cant use spaces in a define do:

#define funcx \
funcwhatitdoes


Re: From function to Macro - rs.pect - 10.11.2010

Can't use spaces in the pattern - Checkx(%0), but can in the replacement part - check it.


Re: From function to Macro - The_Moddler - 10.11.2010

pawn Код:
#define Checkx(%0) \
    (!strcmp((%0),"Drive",true)) || (!strcmp((%0),"Fly",true))
Try it out.