Using Optional Arguments and Return Parameters

Optional arguments can be useful when there are some situations where you want the macro to take a default action rather than accepting a value.  In fact it will save code in the final assembled program since, by not providing an argument, the code which loads the argument doesn’t have to be implemented in that instance.

 

An example of a macro generated using optional arguments and built using the wizard is shown in Enhanced Alpha Clear Screen.

 

Optional Return parameters could be used for Macros which perform a function which does not require a return value – e.g. AddParam (Param), Status might add a parameter into an array if the array had space and the value wasn’t already in the array.  The return parameter could be used to return the status of the function e.g. 0 for OK, 1 for Array Full, 2 for Already there etc….  If the calling routine didn’t need to know whether the function succeeded it could leave out the return part of the syntax.

 

Note – for Macros that return a parameter there may be restrictions on the use of an optional return parameter.  When using the “last parameter” method as the return value (Return dropdown set to “Last Param”) you are permitted the following:

 

Mandatory arguments and a mandatory return

Optional arguments and a mandatory return

            Mandatory arguments and an optional return

 

This restriction does not apply to the Inline method.