Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ OverviewNo.1No.2No.3No.4No.5No.6No.7No.8No.9No.11No.12No.13No.14No.15
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureProgress ReportsPDP15 Notes
ACLLiteratureProgress ReportsPDP15 Notes
ACL ACD C&A INF CCD CISD Archives
Further reading

Overview
No.1
No.2
No.3
No.4
No.5
No.6
No.7
No.8
No.9
No.11
No.12
No.13
No.14
No.15

PDP15 User Note No 12: PIGLET - a simple Command Processor (1906A version)

I Buchanan

28 November 1975

PIGLET is a set of FORTRAN and PLASYD subroutines which accept as input a sequence of free format commands and pass control and arguments to matching applications procedures. Command syntax and argument retrieving procedures are identical to those used in the PDP15 Interactive Graphics System (PIGS). The PICS manual should be regarded as the major reference for this paper. Command names are associated with application procedures at run time using special FORTRAN subroutines.

1. PIGLET EXAMPLE

Section 9 of this paper contains an example program (PIGTST) using PIGLET which has two commands:

      PRINT,I,J         /PRINT OUT VALUES OF ARRAY LOCATIONS I TO J
      SCALE,FACTOR,I,J  /SCALE ARRAY LOCATIONS I TO J BY FACTOR 

As a test, these commands are subsequently redefined so that PRINT scales and SCALE prints. Main program PIGTST sets up the commands and later redefines them. Subroutines PRINT and SCALE are the two applications procedures.

2. OPERATING AN APPLICATIONS PROGRAM USING PIGLET

PIGLET accepts command input from channel 3 (#CR0) in PIGS command syntax (see Section 1.3 of the PIGS manual for a full description). Briefly, commands usually consist of a command name followed by arguments separated from the command name and each other by commas, for example:

      SCALE,3.0,4,10 
      PRINT,5,49 

The set of commands available at a given time is determined by the application program.

3. OPERATION OF PIGLET

PIGLET consists of procedures to define, poll for and execute commands plus the PIGS free format command parsing subroutines. Eight-character command names are matched to application procedure entry addresses in a PIGLET internal table. A command set of 127 commands may be defined at any one time using PIGLET procedures. Commands may be redefined or erased as desired.

4. WRITING AN APPLICATIONS PROGRAM USING PIGLET

Three functions must be carried out by an application using PIGLET:

(1) Initialise PIGLET data base

(2) Define or redefine the available command set by matching command names to applications procedures

(3) Poll for a command and execute its related application procedure

Steps (1), (2) and (3) may be repeated as many times as desired. The four procedures below perform these functions and constitute the application program interface to PIGLET.

(1)        SUBROUTINE NEWJMP 

This procedure should be called before any other PIGLET procedure, otherwise an error message will result. It defines PIGLET constants, erases the current command set and defines permanent command 128, 'RET.' (See (3), below). After initialisation, NEWJP may be used to clear the entire current command set for redefinition.

(2)        FUNCTION JMPDEF (CNAM, ISNAM) 
           EXTERNAL ISNAM

This procedure defines (or redefines) a command name and matching application procedure entry point. CNAME is a 8 character (or shorter) command name. ISNAM, declared EXTERNAL by the calling program, is the name of the application procedure. On return, JMPDEF is the index of the command in the current command set (0-127). If JMPDEF=O, the command was not defined because the command set was full, If CNAM as already defined in the current command set, the previously associated application procedure is replaced by entry point ISNAM.

(3)        FUNCTION JMPCOM (LEXEC, IRET) 
           LOGICAL LEXEC,LRET 
           

JMPCOM sends error diagnostics channel 4 and reads commands from channel 3. If LEXEC is .TRUE. the associated application procedure is subsequently executed by JNPCOM using JUMP (see(4) below). If LEXEC is .FALSE. the applications procedure is not executed. Next, if LRET is .TRUE., control returns to the caller. If LRET is .FALSE., JMPCOM polls for another command until the special command:

      RET. <cr>

is read. At this point control returns to the calling routine. On return, the value of JNPCOM will be an integer between 0 and 128:

  0        Error 32, no commands defined,
  1-127    Index of command selected, This index is also 
           returned by JMPDEF.
  128      Special command RET. was selected.
(4)        SUBROUTINE JUMP (ICNDEX)

If subroutine JMPCOM is called with LEXEC and LRET = .FALSE., control will return to the calling routine when a command is selected. The associated command procedure may then be executed, if desired, using subroutine JUMP. Parameter ICNDEX is the index of the selected command (1≤ICNDEX≤127). The calling program should take care that ICNDEX has a value in the proper range (not 0 or 128). Control will return to the calling routine directly from the application procedure.

5. PIGLET ARGUMENT - GETTING FUNCTIONS

      GETCH 
      GETDP 
      GETSI 
      GETSR
      
SUBROUTINE       ARGUMENTS   FILE        DESCRIPTION
  NAME                       NAME
  
 GETCH                       GETCH2      Get character string, 
                                         left justified, blank filled.
                 NOARG                   Integer index of argument
                             
                 STRING                  First element of real array to 
                                         hold returned string
                 NOCHAR                  Returns number of characters 
                                         in string argument
                 MAXCH                   Maximum number of characters 
                                         before overflow
 GETDP                       GETDP2      Get double precision number
 
                NOARG                    Integer index of argument
                
                DUBPRE                   Returns double precision 
                                         argument value
GETSI                        GETSI2      Get single integer number
                NOARG                    Integer index of number
                
                INTEGER                  Returns double precision 
                                         argument value
GETSR                        GETSR2      Get single real number
                NOARG                    Integer index of argument
                REALNO                   Returns real argument value

6. ERROR MESSAGES

Error messages in PIGLET derive from the PIGS system and, therefore, some of the messages listed below are not applicable in PIGLET:

ERROR
NUMBER
DESCRIPTION ACTION
TAKEN
PRTE OR MENDEL SOURCE
901 Keyboard input buffer overflow. Too many characters typed Command ignored KEYIN
902 Format error in command string Command ignored TARGS
903 Index of argument to be retrieved is .LT. 0 .GT. 14 Default argument returned GETDP, GETCH
904 Number argument to be retrieved, but string argument input Default argument returned GETDP
905 Number argument to be retrieved would overflow integer variable Default argument returned GETSI
906 Command index in Command Table out of range Command ignored PIGS
907 Menu block number out of range New menu not actuated PIGS
908 Command name not recognised Command ignored PIGS,PIGLET
909 String argument to be retrieved, but number argument input Command ignored GETCH
910 Index of argument to be put is .LT. 0 or .GT. 14 Argument is type omitted PUTDP,PUTCH
911 A necessary argument to this command was omitted Command ignored YYCRE,YYDSAB,YYEDI,YYMEN,YYMXD,YYSBD
912 String argument would overflow buffer if retrieved Default argument returned GETCH
913 All menu blocks allocated are full Command ignored YYOUT
914 Reference to an undeclared application procedure name Command ignored YYCOM
915 Reference to an undeclared menu name Command ignored YYCOM,YYEND,YYXEN
916 Unrecognised or illegal argument for this command Command ignored YYCOM,YYDSAB,YYKEY,YYSTY
917 Argument value out of range Command ignored YYLOCL,YYPUSH
918 Menu block full, command not entered Command ignored YYCOM
919 Illegal command for this MENDEL context Command ignored YYCERR,YYNCX
920 Command name not found Command ignored YYPOS
921 Would position cursor off last menu block. Cursor unchanged Command ignored YYGTB,YYPOS
922 Command illegal in MENDEL edit mode Command ignored YYBIG
923 Command illegal in MENDEL create mode Command ignored YYNED
924 End of block reached by DEL command, cursor unchanged Command ignored YYDEL
925 File not found MENDEL - Retype option string, PRTE - Ignore read request
926 File read error MENDEL - Abort assembly or edit, PRTE - Ignore read request
927 Unexpected EOF on input file MENDEL - Abort assembly or edit, PRTE - Ignore read request
928 File write error MENDEL - Abort assembly or edit, PRTE - Ignore write request YYOUT,WTMNU
929 MNB file size error Ignore file request OPMNB
930 Clock schedule full or time interval too large Command not scheduled SCHDEL
931 Command set full Command not defined PIGLET (JMPDEF)
932 POLLING requested, no commands defined Return to caller PIGLET (JMPCOM)

7. LOADING PIGLET WITH THE APPLICATION

The PIGLET subroutines exist as a NULLIB library :GSIN08.PIGLIB and is trapped to all users for READ and EXECUTE access. A list of all the FORTRAN and PLASYD subroutine names is given below:

  ABORT    GETSI   NEWJMP   PUTCH   
  ADPUTP   GETSR   NXTCHR   PUTDP   
  BLANKS   JMPCOM  PARG     PUTSI   
  DUMPARG  JPDEF   PINT     PUTSR   
  ERRMES   JUMP    PMORTM   TARGS   
  GETCH    JUMPP   PNUMB    TERMIN   
  GETDP    MVC     PSTRING  YYCARG  
  

8. CHANNEL USAGE BY PIGLET

      
  Channel     Use           
     3     Command input     
     4     Error messages

9. EXAMPLE PIGTST

(1) PROGRAM

      MASTER PIGTST 
C 
C TEST PIGLET CN ICL 1906A AXO DEMONSRATE ITS USE 
C 
C HAVING SET UP AN ARRAY OF NUMBERS, USE PIGLET TO PRINT OUT A 
C SELECTEO SECTION OR MULTIPLY A SECTION OF THAT ARRAY BY A CONSTANT 
C 
      LOGICAL LEXEC,LRET 
C 
C APPLICATION PROCEDURES MUST 8E OECLAREO EXTERNAL 
C 
      EXTERNAL PRINT,SCALE 
      COMMON /ARRAY/ RARR(50) 
C 
C INITIALISE ARRAY FOR TEST 
C 
      DO 10 I=1,50
      RARR(I)=I
   10 CONTINUE
C 
C TEST 1
C 
C INITIALISE PIGLET, CLEAR COMMAND SET 
C 
      WRITE (4,1012) 
 1012 FORMAT (//1X,'     TEST 1',/)
      CALL NEWJMP 
C
C DEFINE COMMANDS IN THIS SET 
C 
      CALL JMPDEF (8HPRINT   ,PRINT)
      CALL JMPDEF (8HSCALE   ,SCALE)
C 
C POLL UNTIL CCMMAND SELECTED, EXECUTE THEN RETURN 
C EXIT FROM TEST USING RET, COMMANO 
C 
      LEXEC=.TRUE.
      LRET=.FALSE. 
      I=JMPC0M (LEXEC,LRET) 
C 
C 
C                 TEST 2 
C 
C REDEFINE SCALE COMMAND ONLY, POLL, AND RETURN INDEX WITHOUT EXECUTING 
C COMMAND, WRITE COMMAND INDEX ON CHANNEL 4 
C 
      WRITE (4,1018) 
 1018 FORMAT(//1X,'   TEST 2',/ )
      CALL JMPDEF (8HSCALE   ,PRINT) 
   20 I=JMPCOM (.FALSE.,.TRUE.) 
      WRITE (4,1020) I 
 1020 FORMAT (1X,'COMMAND INOEX=',I6) 
C 
C RET, COMMAND INDEX IS 128 
C 
      IF (I.NE.128) GOTO 20 
C 
C 
C                TEST  3 
C 
C REDEFINE ENTIRE CCMMAND SET, EXECUTE COMMANDS FROM USER PROGRAM. 
C 
      WRITE (4,1028) 
 1028 FORMAT (//1X,'    TEST 3',/) 
      CALL NEWJMP 
      CALL JMPDEF (8HSCALE    ,PRINT) 
      CALL JMPDEF (8HPRINT    ,SCALE) 
C 
C   I IS INDEX OF COMMAND SELECTEO 
C 
  30  I=JMPCOM (.FALSE.,.TRUE.) 
C 
C   DON'T ALLOW JUMP(I) WHERE I IS OUT OF RANGE 
C 
      IF (I.LE.0).OR.(I.GE.128)) GOTO 40 
      CALL JUMP (I) 
C 
C END OF .RET COMMAND 
C 
      IF (I.EQ.128) GOTO 40 
      GOTO 30 
C 
C END OF TEST SEQUENCE 
C 
 40   WRITE (4,1040) 
 1040 FORMNAT (/1X,'END OF PIGLET TEST SEQUENCE') 
C 
      STOP 
      END

(2) TEST DATA

      PRINT,1,10 
      SCALE ,3,4,20,30 
      PRINT,  25,20 
        PRINT,20,20
      RET,
       PRINT  ,30,40
      'SCALE',-10,20
      SCALE,30,40
      RET,
      PRINT, 0,1 ,   40  ,  50
      SCALE,40,45
      PRINT,10,45,50
      SCALE,1,50
        RET.

(3) RESULTS

      TEST 1
     1.0000    2.0000    3.0000    4.0000
     6.0000    7.0000    8.0000    9.0000
PRINT ARGUMENTS INCORRECT=  25    20
    68.0000 
      TEST 2
COMMAND INDEX-       1
COMMAND INDEX-       2
COMMAND INDEX-       2
COMMAND INDEX-     128
      
      TEST 3
     4.0000    4.1000    4.2000    4.3000    4.4000
     4.5000
     1.0000    2.0000    3.0000    4.0000    5.0000
     6.0000    7.0000    8.0000    9.0000   10.0000
    11.0000   12.0000   13.0000   14.0000   15.0000
    16.0000   17.0000   18.0000   19.0000   68.0000
    71.4000   74.8000   78.2000   81.6000   85.0000
    88.4000   91.8000   95.2000   98.6000  102.0000
    31.0000   32.0000   33.0000   34.0000   35.0000
    36.0000   37.0000   38.0000   39.0000    4.0000
     4.1000    4.2000    4.3000    4.4000   45.0000
    46.0000   47.0000   48.0000   49.0000   50.0000
 END OF PIGLET TEST SEQUENCES
⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site