An extrinsic special variable is a user-written M subroutine that another M routine can invoke to return a value.
The format for extrinsic special variables is:
The optional label and optional routinename make up the formallabel, which specifies the name of the subroutine performing the extrinsic function. The formallabel must contain at least one of its optional component.
An extrinsic special variable can be thought of as an extrinsic function without input parameters. $$x is equivalent in operation to $$x(). Extrinsic special variables are the only case where invocation of a formallabel does not require an actuallist. M stacks $TEST for extrinsic special variables.
M requires that a routine that implements an extrinsic special variable terminate with an explicit QUIT command which has an argument. M returns the value of the QUIT command argument as the value of the extrinsic special variable.
GTM>ZPRINT ^DAYOWEEK DAYOWEEK();extrinsic special variable to ;provide the day of the week QUIT $ZD($H,"DAY") GTM>WRITE $$DAYOWEEK^DAYOWEEK MON