In most computing environments, symbols may be defined to stand for character
strings. Because this capability can greatly ease your use of the program,
PERCY provides a symbol substitution capability. You can define a symbol to
stand for any string of up to 128 characters. The string may may include full
or partial commands, body ID codes, file names, queries, and other symbols.
Percy maintains a table of up to 1000 symbol definitions. Each entry in the
table consists of two elements:
This means that symbol definitions can be nested. For example, given the definitions
DEFINE SPA SET POINTING AT; DEFINE SPAI SET POINTING AT IO; DEFINE IO 501;the command
SPAI;expands to
SET POINTING AT 501;Note that definitions are not expanded as they are stored. Thus, it doesn't matter whether the definition for IO appears before or after the definition for SPAI.
There are a couple of important points to remember when defining symbols. First, recursive definitions are not allowed. The following example results an error.
PERCY > DEFINE SYMBOLS SYMBOL; PERCY > DEFINE SYMBOL SYMBOLS; -Oops!- RECURSIVE_SYMBOL--The definition of 'SYMBOL' is recursive. Recursively defined symbol definitions are not allowed.Also, if a symbol appears more than once in a command, it will be translated every time it appears, as illustrated in the following example.
PERCY > DEFINE GANYMEDE 503; PERCY > FIND GANYMEDE SEPARATION OF GANYMEDE JUPITER FROM EARTH LESS THAN 60 ARCSECONDS STEP SIZE 1 HOUR; ;;; FIND 503 SEPARATION OF 503 JUPITER FROM EARTH LESS THAN 60 ;++ ARCSECONDS STEP SIZE 1 HOUR ;;; FIND 503 SEPARATION OF 503 JUPITER FROM EARTH LESS THAN ;++ 1.6666666666667E-02 STEP SIZE 3.6E+03 -Oops!- I was expecting to see a word of letters and digits starting with a letter when I encountered the word "503" in the input string. FIND ...503... SEPARATION OF 503 JUPITER FROM EARTH LESS THAN 1.6666666666667E-02 STEP SIZE 3.6E+03You can exempt any part of a command from normal symbol substitution by surrounding it with the '@' character:
PERCY > DEFINE GANYMEDE 503; PERCY > FIND @GANYMEDE@ SEPARATION OF GANYMEDE JUPITER FROM EARTH LESS THAN 60 ARCSECONDS; ;;; FIND GANYMEDE SEPARATION OF 501 JUPITER FROM EARTH LESS THAN 60 ;++ ARCSECONDS STEP SIZE 1 HOUR ;;; FIND GANYMEDE SEPARATION OF 501 JUPITER FROM EARTH LESS THAN ;++ 1.6666666666667E-02 STEP SIZE 3.6E+03You can also use the `@' character to avoid recursive definitions. Whereas the definition
DEFINE FIND FIND TEMP;is recursive, the definition
DEFINE FIND @FIND TEMP@;works exactly the way you want it to.
The DEFINE command enters a symbol definition into the symbol table. The
syntax of the DEFINE command is
DEFINE @name (1:)@wordThe first word following the DEFINE keyword is taken to be the symbol name. (If the symbol name is longer than 32 characters, it is truncated.) The rest of the command is taken to be the definition. (If the definition is longer than 128 characters, beginning with the first non-blank character, it is truncated.) The rules governing symbol names and definitions are discussed in the preceding section.
If the symbol name is already in the symbol table, the corresponding definition is replaced by the new definition.
Symbols may be removed from the symbol table with the UNDEFINE command. The syntax of the UNDEFINE command is
UNDEFINE @nameThe first word following the UNDEFINE keyword is taken to be the symbol name. Any characters following the symbol name are ignored.
There is one other way to alter the contents of the symbol table. The INQUIRE
command causes the program to prompt the user to supply a definition for a
symbol. The symbol and definition are then inserted into the symbol table.
The syntax of the INQUIRE command is:
INQUIRE @nameThe command and response
PERCY > INQUIRE TARGET; PERCY > Enter definition for TARGET > EUROPA;are equivalent to the command
PERCY > DEFINE TARGET EUROPA;In either case, the symbol TARGET and the definition `EUROPA' are inserted into the symbol table.
The INQUIRE command is used primarily for defining global symbols at the beginning of a procedure. For example, a user who wishes to be able to find all of the times that a given satellite is visible (not occulted, eclipsed, or in transit) from the Earth could create the following procedure:
INQUIRE BEGIN; INQUIRE END; INQUIRE TARGET; INQUIRE PLANET; INQUIRE FILE; DEFINE EARTH @EARTH@ STEP SIZE 30 MINUTES; DEFINE DROP FORGET SCHEDULE; SET BOUNDS FROM BEGIN TO END; FIND OCC OCCULTATION OF TARGET BY PLANET FROM EARTH; FIND ECL ECLIPSE OF TARGET BY PLANET FROM EARTH; FIND TRN TRANSIT OF TARGET ACROSS PLANET FROM EARTH; LET INVISIBLE = OCC + ECL; LET INVISIBLE = TRN + INVISIBLE; LET VISIBLE = INVISIBLE COMPLEMENT; ANNOTATE VISIBLE Intervals when TARGET is not occulted, eclipsed, or in transit." EXPORT VISIBLE TO FILE; DROP OCC; DROP ECL; DROP TRN; DROP INVISIBLE; DROP VISIBLE; UNDEFINE BEGIN; UNDEFINE END; UNDEFINE TARGET; UNDEFINE PLANET; UNDEFINE FILE;The file could be used for any satellite of any planet, over any interval, provided that the symbols BEGIN, END, TARGET, PLANET, and FILE are properly defined. The command file, when executed, would ask the user to supply definitions for these symbols.
PERCY > ECHO; PERCY > START FILE.PRO; Enter definition for BEGIN : 1 OCT 1984; Enter definition for END : 1 MAR 1985; Enter definition for TARGET : IO; Enter definition for PLANET : JUPITER; Enter definition for FILE : IO.DAT; ;;; SET BOUNDS FROM 1 OCT 1984 TO 1 MAR 1984 ;;; FIND OCC OCCULTATION OF IO BY JUPITER FROM EARTH ;++ STEP SIZE 1.8E+03; ;;; FIND ECL ECLIPSE OF IO BY JUPITER FROM EARTH) ;++ STEP SIZE 1.8E+03; ;;; FIND TRN TRANSIT OF IO BY JUPITER FROM EARTH) ;++ STEP SIZE 1.8E+03; ;;; ANNOTATE VISIBLE Intervals when IO is not ;++ occulted, eclipsed, or in transit." ;;; EXPORT VISIBLE TO IO.DAT
The appearance of a query in a command causes the program to ask the user to
supply a value for the query before continuing. The value supplied by the
user is then substituted for the query itself. The use of queries does not
affect the contents of the symbol table.
A query is any string of up to 32 consecutive non-blank characters ending with a question mark. Any number of queries may be placed in a command. The command and responses
PERCY > LET RESULT? = FIRST_SCHEDULE? * SECOND_SCHEDULE? ; Enter value for RESULT > IO_REAL_TIME; Enter value for FIRST_SCHEDULE : IO_VISIBLE; Enter value for SECOND_SCHEDULE : COMLINK_AVAILABLE;are equivalent to the command
PERCY > LET IO_REAL_TIME = IO_VISIBLE * COMLINK_AVAILABLE;Queries are used primarily to prompt for default bounds at the beginning of a procedure, and to remind the user of the syntax of infrequently used commands. (That is, in situations where an answer is required once, and no need exists for a symbol definition.)
Symbols may be entered in response to queries. These symbols may in turn contain further queries, and so on. The program will continue to evaluate queries until none remain before processing a command.