GetIntArg Function (Macro)

args.h

unsigned long GetIntArg (CESI &ap);

Returns the current argument of integer type.

GetIntArg is a macro which returns the current integer argument (pointed to by ap) and modifies ap to point to the next argument in the argument list. So, each successive time GetIntArg is used, it returns the next argument in the argument list. If the argument is a negative number (check the sign using GetArgType), GetIntArg returns its absolute value. See InitArgPtr for an example of usage. Note that GetIntArg assumes that the current argument IS an integer, either positive or negative (this may be checked using GetArgType). If this is not true, the result of GetIntArg is unpredictable.

If the current argument type is a fraction, do the following to pick it:

numerator = GetIntArg (ap);
ap++;
denominator = GetIntArg (ap);
i.e. pick two integers, with increasing argument pointer between two picks.

Note: It is not recommended to do something like
a = GetIntArg (top_estack);
It works fine sometimes, but not always. GetIntArg is a function-looking macro, with changes the value of its actual argument. So, if you write the statement mentioned above, you will also change the value of TIOS system variable top_estack, which is not always a good idea. So, I strictly recommend using an auxiliary variable, like in the following example:
ESI argptr = top_estack;
...
a = GetIntArg (argptr);
Using this method, you will avoid unexpected changes of top_estack.


See also: GetLongLongArg