Check if a program is in the macro space

[Autolink] Menu

 
/* check if this program is executed from within the macrospace       */
/* (see also LoadMac.cmd)                                             */

  if InMacroSpace() = 1 then
    say "This program is executed from within the macro space"
  else
    say "This program is NOT executed from within the macro space"

exit 0

/* ------------------------------------------------------------------ */
/* function: Check if the program is in the macrospace                */
/*                                                                    */
/* call:     InMacroSpace                                             */
/*                                                                    */
/* returns:  1 - yes                                                  */
/*           0 - no                                                   */
/*                                                                    */
InMacroSpace: PROCEDURE

  SIGNAL ON SYNTAX   NAME NotInMacroSpace
  inMacroSpace = 1

  dummy = sourceLine( 1 )
  inMacroSpace = 0

NotInMacroSpace:

  if inMacroSpace = 1 then
  do
                        /* program seems to be in the macro space     */
                        /* do a second check to be sure               */
    parse source . . thisFile
    if fileSpec( "drive", thisFile ) <> '' then
      inMacroSpace = 0  /* Oops, we are not in the macro space        */
  end /* if inMacroSpace = 1 */

RETURN inMacroSpace


[Back: Simulate the INCLUDE command]
[Next: Get a line number at runtime - 1 -]