<< LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION>>               00000001
$CONTROL MAIN=RECOVER5,LINES=120,PRIVILEGED,MAP,USLINIT,CODE            00012000
! RECOVER5                                                              00014000
! HP32002C MPE SOURCE G.01.00                                           00016000
$COPYRIGHT     "(C) COPYRIGHT HEWLETT-PACKARD CO. 1976. ",            & 00018000
$     "THIS PROGRAM MAY BE USED WITH ONE COMPUTER SYSTEM AT A ",      & 00020000
$     "TIME AND SHALL NOT OTHERWISE BE RECORDED, TRANSMITTED OR ",    & 00022000
$     "STORED IN A RETRIEVAL SYSTEM.  COPYING OR OTHER REPRODUCTION ",& 00024000
$     "OF THIS PROGRAM EXCEPT FOR ARCHIVAL PURPOSES IS PROHIBITED ",  & 00026000
$     "WITHOUT THE PRIOR WRITTEN CONSENT OF HEWLETT-PACKARD COMPANY."   00028000
BEGIN                                                                   00030000
                                                                        00032000
EQUATE VUUFF'COL = 9;                                                   00034000
$INCLUDE INCLVUF                                                        00036000
                                                                        00038000
EQUATE                                                                  00040000
   FISIR               = 37,       ! File integrity SIR                 00042000
   MAX'LIST            = 10,                                            00044000
   JIT'ACCOUNT         = 16,       ! Offset into JIT of account name    00046000
   JIT'LOGON'GROUP     = 24,       ! Offset into JIT of logon group name00048000
   EXITN               = %31400,   ! Exit instruction                   00050000
   CR                  = %15,      ! Carrage return                     00052000
   NOCRLF              = %320,     ! CCTL for no CR line feed.          00054000
   FORWARD'SPACE'FILE  = 7,        ! FCONTROL functions                 00056000
   REWIND'UNLOAD       = 9,                                             00058000
   DISABLE'BREAK       = 14,                                            00060000
   ENABLE'BREAK        = 15,                                            00062000
   READ                = 0,        ! FLABIO function codes              00064000
   WRITE               = 1,                                             00066000
   CONT'SIZE           = 12,       ! Size of record for continuation    00068000
   TAPE'REC'SIZE       = 4096;     ! Size of SADUTIL tape records.      00070000
                                                                        00072000
INTEGER ARRAY                                                           00074000
   QARRAY(*)=Q+0,                                                       00076000
   LOGON'ACCOUNT(0:3),             ! Save current group and account     00078000
   LOGON'GROUP  (0:3),                                                  00080000
   TAPE'BUFFER(0:TAPE'REC'SIZE-1), ! Tape read buffer                   00082000
   IO'BUFFER(0:49),                ! Used for terminal I/O              00084000
   FLAB(0:127);                    ! Store FLAB of current file         00086000
                                                                        00088000
DOUBLE ARRAY                                                            00090000
   FLABDBL(*) = FLAB;                                                   00092000
                                                                        00094000
BYTE ARRAY TAPE'NAME(0:7)      := "RECOVTP*";                           00096000
BYTE ARRAY LIST'NAME(0:7)      := "LIST*";                              00098000
BYTE ARRAY DEFAULT'DEVICE(0:7) := "TAPE*";                              00100000
BYTE ARRAY                                                              00102000
   FLAB'B (*) = FLAB;                                                   00104000
                                                                        00106000
BYTE ARRAY                                                              00108000
   IO'BUFFER'B(*)=IO'BUFFER,       ! Byte terminal I/O buffer           00110000
   FILE'NAME(0:26),                ! Store file name for message        00112000
   FORMDES(0:36),                  ! Used for FOPEN                     00114000
   OUT'LIST (0:830),                                                    00116000
   FILE'LIST(0:360),                                                    00118000
   STND'FORM(0:80);                                                     00120000
                                                                        00122000
BYTE POINTER                                                            00124000
   LIST'PT            := @FILE'LIST,                                    00126000
   OUT'PT             := @OUT'LIST,                                     00128000
   FORMDES'PTR        := @FORMDES,                                      00130000
   FORMDES'STD'PTR    := @STND'FORM,                                    00132000
   END'OF'LIST        := @FILE'LIST,                                    00134000
   START;                                                               00136000
                                                                        00138000
LOGICAL                                                                 00140000
   CONTROL'Y'DETECTED := FALSE,    ! Was CONTROL-Y entered?             00142000
   NOTKEEP            := FALSE,    ! Keep existing copies of file?      00144000
   KEEP'SOME          := FALSE,    ! Have we kept any files yet?        00146000
   GOT'WILD           := FALSE,                                         00148000
   CONTINUATION;                   ! Does current file span reels?      00150000
                                                                        00152000
DEFINE                                                                  00154000
   DBL                 = DOUBLE#,                                       00156000
   CONTINUATION'RECORD = "CONTINUE"#,                                   00158000
   FAILED              = FALSE#,                                        00160000
   GOOD                = TRUE#,                                         00162000
   NO                  = FALSE#,   ! For GET'YES'NO                     00164000
   YES                 = TRUE#,                                         00166000
   KEEPING'FILES       = NOT NOTKEEP#,                                  00168000
                                                                        00170000
   DEF'MOVETODSEG =                                                     00172000
      MOVETODSEG (DSTN, DSTOFFSET, DBSOURCE, WORD'COUNT);               00174000
         VALUE   DSTN, DSTOFFSET, DBSOURCE, WORD'COUNT;                 00176000
         LOGICAL DSTN, DSTOFFSET, DBSOURCE, WORD'COUNT;                 00178000
      BEGIN                                                             00180000
      X := TOS;                                                         00182000
      ASSEMBLE (MTDS 0);                                                00184000
      TOS := X;                                                         00186000
      END #;                                                            00188000
                                                                        00190000
INTEGER                                                                 00192000
   X = X,                          ! The X register                     00194000
   S0 = S-0,                       ! Top of stack register, don't delete00196000
   LEN,                            ! General purpose length var         00198000
   ERROR,                          ! General purpose ERROR var          00200000
   JIT'DST,                        ! The JIT DST number of current job  00202000
   NUM'STRICT := 0,                ! Strictly # of files, no wild cards.00204000
   CHAR'INX,                                                            00206000
   KOUNT,                                                               00208000
   NUM'ULABS,                      ! Number of user labels yet to write.00210000
   TAPE'FNUM,                      ! Tape file number                   00212000
   LIST'FNUM,                      ! File number of "LIST" file         00214000
   STDIN'FNUM,                     ! $STDIN reopen file number          00216000
   DISC'FNUM,                      ! Current disc file number           00218000
   SECT'OFFSET'DATA,               ! Number of sectors from FLAB to data00220000
   DUMMY;                                                               00222000
$PAGE "DEFINES & EQUATES for pattern routines"                          00224000
!-----------------------------------------------------------------------00226000
!  PATTERN...a pattern matcher that implements a fairly simple          00228000
!  pattern matching scheme.  It matches a pattern versus a string       00230000
!  of up to 8 characters.  Wildcards, and their meanings, are:          00232000
!        @        Match from 0 to 8 characters.                         00234000
!        ?        Match any single character.                           00236000
!        #        Match any single digit (0..9).                        00238000
!                                                                       00240000
!-----------------------------------------------------------------------00242000
                                                                        00244000
DEFINE                                                                  00246000
                                                                        00248000
   PAT'MAX'FIRM      = 8 #,    <<max number of firm chars>>             00250000
   PAT'MAX'PART      = 8 #,    <<max number of pattern parts>>          00252000
   PATCHARf          = (8:8) #,                                         00254000
   PATLENf           = (2:6) #,                                         00256000
   PATTYPEf          = (0:2) #;                                         00258000
                                                                        00260000
EQUATE                                                                  00262000
                                                                        00264000
      <<values found in the PATTYPEf field...>>                         00266000
                                                                        00268000
   ANYONECHARACTERp  = 0,     <<a CASE statement in SUB'MATCH >>        00270000
   ANYCHARACTERSp    = 1,     <<depends                       >>        00272000
   DIGITONLYp        = 2,     <<        on this               >>        00274000
   EXACTp            = 3,     <<                ordering!     >>        00276000
                                                                        00278000
      <<PATTERN'BUILD errors...>>                                       00280000
                                                                        00282000
   PB'ERR'MANY'FIRM  = 1,     <<more than 8 'firm' chars were found>>   00284000
   PB'ERR'MANY'PARTS = 2;     <<more than 8 parts were found>>          00286000
                                                                        00288000
!-----------------------------------------------------------------------00290000
!                                                                       00292000
!  STANDARD'TO'DISPLAY  and  DISPLAY'TO'STANDARD                        00294000
!                                                                       00296000
!-----------------------------------------------------------------------00298000
                                                                        00300000
EQUATE                                                                  00302000
   MAX'STD'LEN    = ( 10  <<overhead>> <<max len of std-form title>>    00304000
                     + 2 + 8           <<file part>>                    00306000
                     + 1 + 8           <<lock part>>                    00308000
                     + 1 + 8           <<group part>>                   00310000
                     + 1 + 8           <<acct part>>                    00312000
                     + 1 + 8           <<family part>>                  00314000
                     + 1 + 8           <<host part>>                    00316000
                     + 10     ),       <<expansion!>>                   00318000
   MAX'TITLE'LEN  = (  1 + 8           <<"*" & file part length>>       00320000
                     + 1 + 8           <</lockword>>                    00322000
                     + 1 + 8           <<.group>>                       00324000
                     + 1 + 8           <<.account>>                     00326000
                     + 1 ),            <<trailing blank>>               00328000
   MAX'TITLE'LEN2 = (MAX'TITLE'LEN                                      00330000
                     + 1 + 8           <<-file>>                        00332000
                     + 1 + 8           <<.group     ...no lockword!>>   00334000
                     + 1 + 8           <<.account>>                     00336000
                     + 0 );            <<trailing blank added above>>   00338000
                                                                        00340000
!-----------------------------------------------------------------------00342000
DEFINE                                                                  00344000
         <<standard form title defines...>>                             00346000
                                                                        00348000
   STD'LEN'TOTAL  = ISTD (00) #, <<integer: length in bytes, inclu>>    00350000
   STD'VERSION    = PSTD (02) #,       <<std-form version id (=1) >>    00352000
   STD'INFO       = PSTD (03) #,       <<info bits:               >>    00354000
   STD'BACK       = STD'INFO.(13:1) #, <<  1 = back referenced    >>    00356000
   STD'DOLLAR     = STD'INFO.(14:1) #, <<  1 = dollar sign        >>    00358000
   STD'WILD       = STD'INFO.(15:1) #, <<  1 = wildcards in title >>    00360000
   STD'FILE'INX   = PSTD (04) #,       <<byte index of file part  >>    00362000
   STD'LOCK'INX   = PSTD (05) #,       <<byte index of lock part  >>    00364000
   STD'GROUP'INX  = PSTD (06) #,       <<byte index of group part >>    00366000
   STD'ACCT'INX   = PSTD (07) #,       <<byte index of acct part  >>    00368000
   STD'FAMILY'INX = PSTD (08) #,       <<byte index of family part>>    00370000
   STD'HOST'INX   = PSTD (09) #,       <<byte index of host part  >>    00372000
                                                                        00374000
   STD'FILE'PARTS = PSTD (STD'FILE'INX-1)#,  <<# file parts  (:=1)>>    00376000
   STD'FILE'INFO  = PSTD (STD'FILE'INX) #,   <<file info bits:    >>    00378000
   STD'FILE'WILD  = STD'FILE'INFO.(8:1) #,   << 1 = wildcards     >>    00380000
   STD'FILE'LEN   = STD'FILE'INFO.(9:7) #,   << length (0 to 8)   >>    00382000
   STD'PART'LENf  = (9:7) #,                                            00384000
   STD'FILE'      = PSTD (STD'FILE'INX+1) #, <<pointer to file txt>>    00386000
                                                                        00388000
   STD'LOCK'INFO  = PSTD (STD'LOCK'INX) #,   <<lock info bits:    >>    00390000
   STD'LOCK'WILD  = STD'LOCK'INFO.(8:1) #,   << 1 = wildcards     >>    00392000
   STD'LOCK'LEN   = STD'LOCK'INFO.(9:7) #,   << length (0 to 8)   >>    00394000
   STD'LOCK'      = PSTD (STD'LOCK'INX+1) #, <<pointer to lock txt>>    00396000
                                                                        00398000
   STD'GROUP'INFO = PSTD (STD'GROUP'INX) #,  <<group info bits:    >>   00400000
   STD'GROUP'WILD = STD'GROUP'INFO.(8:1) #,  << 1 = wildcards     >>    00402000
   STD'GROUP'LEN  = STD'GROUP'INFO.(9:7) #,  << length (0 to 8)   >>    00404000
   STD'GROUP'     = PSTD (STD'GROUP'INX+1) #,<<pointer to group txt>>   00406000
                                                                        00408000
   STD'ACCT'INFO  = PSTD (STD'ACCT'INX) #,   <<acct info bits:    >>    00410000
   STD'ACCT'WILD  = STD'ACCT'INFO.(8:1) #,   << 1 = wildcards     >>    00412000
   STD'ACCT'LEN   = STD'ACCT'INFO.(9:7) #,   << length (0 to 8)   >>    00414000
   STD'ACCT'      = PSTD (STD'ACCT'INX+1) #, <<pointer to acct txt>>    00416000
                                                                        00418000
   STD'FAMILY'INFO= PSTD (STD'FAMILY'INX) #, <<family info bits:  >>    00420000
   STD'FAMILY'WILD= STD'FAMILY'INFO.(8:1) #, << 1 = wildcards     >>    00422000
   STD'FAMILY'LEN = STD'FAMILY'INFO.(9:7) #, << length (0 to 8)   >>    00424000
   STD'FAMILY'    = PSTD (STD'FAMILY'INX+1)#,<<pntr to family txt >>    00426000
                                                                        00428000
   STD'HOST'INFO  = PSTD (STD'HOST'INX) #,   <<host info bits:    >>    00430000
   STD'HOST'WILD  = STD'HOST'INFO.(8:1) #,   << 1 = wildcards     >>    00432000
   STD'HOST'LEN   = STD'HOST'INFO.(9:7) #,   << length (0 to 8)   >>    00434000
   STD'HOST'      = PSTD (STD'HOST'INX+1) #; <<pointer to host txt>>    00436000
!-----------------------------------------------------------------------00438000
EQUATE                                                                  00440000
                                                                        00442000
      <<error numbers for standard form conversion...>>                 00444000
                                                                        00446000
         <<from standard to display...>>                                00448000
                                                                        00450000
   DE'STANDARD'TOO'LONG =  1, <<resultant display title too long>>      00452000
   DE'STANDARD'EMPTY    =  2, <<zero length file part in std title>>    00454000
                                                                        00456000
         <<from display to standard...>>                                00458000
                                                                        00460000
   SE'PART'TOO'LONG     =  1, <<part too long>>                         00462000
   SE'ZERO'PART         =  2, <<zero length part>>                      00464000
   SE'WILD'D'OR'B       =  3, <<wild and either $ or *>>                00466000
   SE'FIRST'IS'DIGIT    =  4, <<first char cant be digit>>              00468000
   SE'LOCKWORD'LOC      =  5, <<bad place for lockword>>                00470000
   SE'TOO'MANY'PERIODS  =  6, <<too many periods>>                      00472000
   SE'STAR'NOT'FIRST    =  7, <<"*" must be first character>>           00474000
   SE'STAR'AND'DOLLAR   =  8, <<dollar and backref true>>               00476000
   SE'DOLLAR'NOT'FIRST  =  9, <<"$" must be first character>>           00478000
   SE'ILLEGAL'CHARACTER = 10, <<invalid title character>>               00480000
   SE'MISSING'PARAMETERS= 11; <<needed parameters were omitted>>        00482000
$PAGE "ERROR MESSAGE EQUATES"                                           00484000
EQUATE                                                                  00486000
   ! These error message are printed as is.                             00488000
                                                                        00490000
   TAPE'FSF'ERROR            = 1,                                       00492000
   ANSWER'YES'NO             = 2,                                       00494000
   LIST'FCLOSE'ERROR         = 3,                                       00496000
   TAPE'FCLOSE'ERROR         = 4,                                       00498000
   NOT'A'RECOVER5'TAPE       = 5,                                       00500000
   TAPE'REWIND'UNLOAD'ERROR  = 6,                                       00502000
   MOUNT'NEW'TAPE            = 7,                                       00504000
   TAPE'READ'ERROR           = 8,                                       00506000
   CATASTROPHIC'TAPE'ERROR   = 9,                                       00508000
   ENTER'FILESET             = 10,                                      00510000
   TERMINATE'LIST            = 11,                                      00512000
   PROMPT                    = 12,                                      00514000
   BLANK'LINE                = 13,                                      00516000
   KEEP'FILES                = 14,                                      00518000
   BANNER                    = 15,                                      00520000
   INVALID'MPE'VERSION       = 16,                                      00522000
   LISTFILE'FOPEN'ERROR      = 17,                                      00524000
   STDIN'FOPEN'ERROR         = 18,                                      00526000
   USER'LACKS'SM'CAP         = 19,                                      00528000
   TAPE'FOPEN'ERROR          = 20,                                      00530000
   CONTROL'Y'CONTINUE        = 21,                                      00532000
   ASK'ANOTHER'TAPE          = 22,                                      00534000
   ASK'CONTINUATION'TAPE     = 23,                                      00536000
   CONTROLY'DETECTED         = 24,                                      00538000
   NAME'PATTERN'ERROR        = 25,                                      00540000
   GROUP'PATTERN'ERROR       = 26,                                      00542000
   ACCOUNT'PATTERN'ERROR     = 27,                                      00544000
   EXCESSIVE'FILESETS        = 28,                                      00546000
   PART'TOO'LONG             = 29,                                      00548000
   ZERO'LEN                  = 30,                                      00550000
   INVALID'WILD              = 31,                                      00552000
   NUMERIC'ILLEGAL           = 32,                                      00554000
   INVALID'LOCKWORD          = 33,                                      00556000
   TOO'MANY'PERIODS          = 34,                                      00558000
   INVALID'STAR              = 35,                                      00560000
   INVALID'SPECIAL'CHARS     = 36,                                      00562000
   INVALID'DOLLAR            = 37,                                      00564000
   ILLEGAL'CHAR              = 38,                                      00566000
   PARMS'MISSING             = 39,                                      00568000
   REENTER'FILESETS          = 40,                                      00570000
   FWRITE'LIST'ERROR         = 41,                                      00572000
   OPEN'TAPE'FILE            = 42,                                      00574000
   TAPE'CONTINUATION'ERROR   = 43,                                      00576000
                                                                        00578000
   !--------------------------------------------------------------------00580000
   ! These errors have the current disc file name attached to the begin-00582000
   ! ing of the message.  If 100 <= MESSAGE'NUM >= 199 then the error is00584000
   ! outputed  to the  file "LIST".  If MESSAGE'NUM >= 200 then the err-00586000
   ! or is outputed to $STDLIST.                                        00588000
   !--------------------------------------------------------------------00590000
                                                                        00592000
   DUPLICATE'FILE'ERROR      = 100,                                     00594000
   FOPEN'EXISTING'FILE'ERROR = 101,                                     00596000
   PURGE'ERROR               = 102,                                     00598000
   FCLOSE'ERROR              = 103,                                     00600000
   FILE'SHORT'ERROR          = 104,                                     00602000
   SUCCESSFUL'RECOVERY       = 105,                                     00604000
   FLAB'IO'ERROR             = 106,                                     00606000
   TOO'MANY'ULABS            = 107,                                     00608000
   ULAB'WRITE'ERROR          = 108,                                     00610000
   DATA'WRITE'ERROR          = 109,                                     00612000
   TOO'MANY'DATA'RECORDS     = 110,                                     00614000
   DISC'FOPEN'ERROR          = 111,                                     00616000
   FFILEINFO'ERROR           = 112,                                     00618000
   TAPE'DATA'READ'ERROR      = 113,                                     00620000
   FILE'CONTINUATION         = 214;                                     00622000
                                                                        00624000
$INCLUDE INCLFLAB                                                       00626000
$PAGE "PCB GLOBAL INCLUDE FILE"                                         00628000
$INCLUDE INCLPXG                                                        00630000
$PAGE "EXTERNAL DECLARATIONS"                                           00632000
INTRINSIC                                                               00634000
                                                                        00636000
FCONTROL,FOPEN,FCLOSE,FCHECK,FGETINFO,FREAD,FWRITE,WHO,XCONTRAP,        00638000
RESETCONTROL,TERMINATE,FWRITELABEL,FFILEINFO,FERRMSG,PRINT;             00640000
                                                                        00642000
INTEGER PROCEDURE GETSIR(SIR);                                          00644000
VALUE SIR;                                                              00646000
INTEGER SIR;                                                            00648000
OPTION EXTERNAL;                                                        00650000
                                                                        00652000
PROCEDURE RELSIR(SIR,RETURNV);                                          00654000
VALUE SIR,RETURNV;                                                      00656000
INTEGER SIR,RETURNV;                                                    00658000
OPTION EXTERNAL;                                                        00660000
                                                                        00662000
PROCEDURE PUT'ACB'INFO(FNUM,ITEM'NUM,ITEM);                             00664000
VALUE FNUM,ITEM'NUM,ITEM;                                               00666000
INTEGER FNUM,ITEM'NUM,ITEM;                                             00668000
OPTION EXTERNAL;                                                        00670000
                                                                        00672000
INTEGER PROCEDURE FLABIO(LDEV,DISC'ADDRESS,FUNCTION,TARGET);            00674000
VALUE LDEV,DISC'ADDRESS,FUNCTION;                                       00676000
INTEGER LDEV,FUNCTION;                                                  00678000
DOUBLE DISC'ADDRESS;                                                    00680000
ARRAY TARGET;                                                           00682000
OPTION EXTERNAL;                                                        00684000
                                                                        00686000
INTEGER PROCEDURE ROPEN(FD,FO,AO,RS,DV,FM,UL,BF,NB,FS,NE,IA,FC);        00688000
VALUE   FO,AO,RS,UL,BF,NB,FS,NE,IA,FC;                                  00690000
INTEGER RS,UL,BF,NB,NE,IA,FC;                                           00692000
LOGICAL FO,AO;                                                          00694000
DOUBLE  FS;                                                             00696000
BYTE ARRAY FD,DV,FM;                                                    00698000
OPTION EXTERNAL,VARIABLE;                                               00700000
                                                                        00702000
PROCEDURE PRINT'MESSAGE(MSG'NUM,FNUM,CCTL);                             00704000
VALUE MSG'NUM,FNUM,CCTL;                                                00706000
INTEGER MSG'NUM,FNUM,CCTL;                                              00708000
OPTION FORWARD,VARIABLE;                                                00710000
                                                                        00712000
LOGICAL PROCEDURE SUB'MATCH (PTEXT, ACTUALLEN, PATTERN, STARTPART);     00714000
VALUE PTEXT, ACTUALLEN, STARTPART;                                      00716000
INTEGER ACTUALLEN, STARTPART;                                           00718000
BYTE POINTER PTEXT;                                                     00720000
INTEGER ARRAY PATTERN;                                                  00722000
OPTION FORWARD;                                                         00724000
                                                                        00726000
PROCEDURE EXIT'PROGRAM;                                                 00728000
OPTION FORWARD;                                                         00730000
                                                                        00732000
$PAGE "DISPLAY'TO'STANDARD"                                             00734000
LOGICAL PROCEDURE DISPLAY'TO'STANDARD (PDIS, PSTD, ERROR, CHAR'INX,     00736000
                                       DELIMS);                         00738000
            VALUE PDIS, PSTD, DELIMS;                                   00740000
            INTEGER ERROR, CHAR'INX;                                    00742000
            BYTE POINTER PDIS, PSTD, DELIMS;                            00744000
            OPTION VARIABLE;                                            00746000
   <<This routine converts a display form file title into               00748000
     a standard form file title.  If an error occurs, the error         00750000
     number is reported in ERROR.                                       00752000
     Parameters:                                                        00754000
                                                                        00756000
      PDIS:  byte pointer, points to a file title (with or              00758000
         without wildcards or group or account.  Terminated by          00760000
         a blank!                                                       00762000
         May not be omitted.                                            00764000
                                                                        00766000
      PSTD:  byte pointer, will hold standard form title.  As           00768000
         such, must hold at least MAX'STD'LEN characters!               00770000
         This will be filled with zeroes at start of routine.           00772000
         May not be omitted.                                            00774000
                                                                        00776000
      ERROR: integer, call by reference.                                00778000
         This is initialized to zero at entry.                          00780000
         May not be omitted.                                            00782000
                                                                        00784000
      CHAR'INX: integer, call by reference.                             00786000
         In the event of an error, this is the index of the             00788000
         offending character in PDIS.                                   00790000
         In the event of a successful conversion, this is the           00792000
         index of the first character AFTER the file title,             00794000
         presumably the blank that trails it.  It therefore             00796000
         is equivalent to the length of the display form title.         00798000
         May not be omitted.                                            00800000
                                                                        00802000
      DELIMS: byte pointer, call by value.                              00804000
         Contains a sequence of characters that are valid to            00806000
         terminate a file title with.  DELIMS (0) is the count of       00808000
         the number of valid delimiters.  Thus, to allow a file title   00810000
         to be delimited by blank, comma, semicolon, or minus, one      00812000
         would use:  MOVE DELIMS:=(%4, " ,;-");   or                    00814000
         (%4, "-; ,").                                                  00816000
         Note: this cannot be used to prevent letters/digits/wildcards  00818000
         from being part of a title!                                    00820000
         Defaults to:   (%4, "-; ,").                                   00822000
                                                                        00824000
   Result:                                                              00826000
      FAILED if an error occurs,                                        00828000
      GOOD if no error.   (GOOD <==> NOT FAILED)                        00830000
   -----------------------------------------------------------          00832000
                                                                        00834000
   Standard form file title layout:                                     00836000
                                                                        00838000
   Byte array:           #Bytes  Byte index    Define to access:        00840000
                                             (using byte pointer        00842000
      +------------------+                    PSTD)                     00844000
      ! total length     !    2     0             STD'LEN'TOTAL         00846000
      ! (self inclusive) !                                              00848000
      !(NOTE: 2 bytes!)  !                                              00850000
      +------------------+                                              00852000
      ! standard-form    !    1     2             STD'VERSION           00854000
      ! version          !                                              00856000
      ! (usually = 1)    !                                              00858000
      +------------------+                                              00860000
      ! information byte !    1     3             STD'INFO              00862000
      ! bits: (8..15)    !                                              00864000
      ! 8 = r e s e r v e!  \                                           00866000
      ! 9 = r e s e r v e!   \                                          00868000
      !10 = r e s e r v e!    >   set to 0.                             00870000
      !11 = r e s e r v e!   /                                          00872000
      !12 = r e s e r v e!  /                                           00874000
      !13 = backreference!                        STD'BACK              00876000
      !14 = dollar       !                        STD'DOLLAR            00878000
      !15 = wildcards    !                        STD'WILD              00880000
      +------------------+                                              00882000
      !index of file part!    1     4             STD'FILE'INX          00884000
      ! in this array    !                                              00886000
      !(if zero, part was!                                              00888000
      !not found)        !                                              00890000
      +------------------+                                              00892000
      !index of lockword !    1     5             STD'LOCK'INX          00894000
      !part in this array!                                              00896000
      +------------------+                                              00898000
      !index of group    !    1     6             STD'GROUP'INX         00900000
      !part in this array!                                              00902000
      +------------------+                                              00904000
      !index of acct part!    1     7             STD'ACCT'INX          00906000
      !in this array     !                                              00908000
      +------------------+                                              00910000
      !reserved, := 0    !    1     8             STD'HOST'INX          00912000
      !  (host name)     !                                              00914000
      +------------------+                                              00916000
      !reserved, := 0    !    1     9             STD'PV'INX            00918000
      !(private volume   !                                              00920000
      ! (family) name    !                                              00922000
      +------------------+                                              00924000
              ...                                                       00926000
      +------------------+                                              00928000
      ~ dont count on the~                                              00930000
      ~ next part being  ~                                              00932000
      ~ right after the  ~                                              00934000
      ~ above info!!!!   ~                                              00936000
      +------------------+                                              00938000
              ...                                                       00940000
      +------------------+                                              00942000
      ! reserved, := 1   !    1     STD'FILE'INX-1                      00944000
      ! (number of parts !                        STD'FILE'PARTS        00946000
      ! in file name)    !                                              00948000
      +------------------+                                              00950000
      !file part info:   !    1     STD'FILE'INX  STD'FILE'INFO         00952000
      !bit 8 = wildcards !                        STD'FILE'WILD         00954000
      !bit 9..15= length !                        STD'FILE'LEN          00956000
      +------------------+                                              00958000
      !file part text... !    0..8  STD'FILE'INX+1                      00960000
      !up to 8 characters!                        STD'FILE'             00962000
      !in length, no fill!                                              00964000
      !characters at end.!                                              00966000
      +------------------+                                              00968000
              ...                                                       00970000
      +------------------+                                              00972000
      ! (second, third...!    0..???                                    00974000
      ! 'nth' file parts !                                              00976000
      ! will follow this !                                              00978000
      ! someday).        !                                              00980000
      +------------------+                                              00982000
              ...                                                       00984000
      +------------------+                                              00986000
      !lock part info:   !    1     STD'LOCK'INX  STD'LOCK'INFO         00988000
      !bit 8 = wildcards !                        STD'LOCK'WILD         00990000
      !bit 9..15= length !                        STD'LOCK'LEN          00992000
      +------------------+                                              00994000
      !lock part text... !    0..8  STD'LOCK'INX+1                      00996000
      !up to 8 characters!                        STD'LOCK'             00998000
      !in length, no fill!                                              01000000
      !characters at end.!                                              01002000
      +------------------+                                              01004000
              ...                                                       01006000
      +------------------+                                              01008000
      !group part info:  !    1     STD'GROUP'INX STD'GROUP'INFO        01010000
      !bit 8 = wildcards !                        STD'GROUP'WILD        01012000
      !bit 9..15= length !                        STD'GROUP'LEN         01014000
      +------------------+                                              01016000
      !group part text...!    0..8  STD'GROUP'INX+1                     01018000
      !up to 8 characters!                        STD'GROUP'            01020000
      !in length, no fill!                                              01022000
      !characters at end.!                                              01024000
      +------------------+                                              01026000
              ...                                                       01028000
      +------------------+                                              01030000
      !acct part info:   !    1     STD'ACCT'INX  STD'ACCT'INFO         01032000
      !bit 8 = wildcards !                        STD'ACCT'WILD         01034000
      !bit 9..15= length !                        STD'ACCT'LEN          01036000
      +------------------+                                              01038000
      !acct part text... !    0..8  STD'ACCT'INX+1                      01040000
      !up to 8 characters!                        STD'ACCT'             01042000
      !in length, no fill!                                              01044000
      !characters at end.!                                              01046000
      +------------------+                                              01048000
              ...                                                       01050000
      ~~~~~~~~~~~~~~~~~~~~                                              01052000
      ~ The following    ~                                              01054000
      ~ two parts are not~                                              01056000
      ~ yet implemented, ~                                              01058000
      ~ but have been    ~                                              01060000
      ~ defined to allow ~                                              01062000
      ~later enhancements~                                              01064000
      ~~~~~~~~~~~~~~~~~~~~                                              01066000
              ...                                                       01068000
      +------------------+                                              01070000
      !family part info: !    1     STD'FAMILY'INX STD'FAMILY'INFO      01072000
      !bit 8 = wildcards !                        STD'FAMILY'WILD       01074000
      !bit 9..15= length !                        STD'FAMILY'LEN        01076000
      +------------------+                                              01078000
      !family part text..!    0..8  STD'FAMILY'INX+1                    01080000
      !up to 8 characters!                        STD'FAMILY'           01082000
      !in length, no fill!                                              01084000
      !characters at end.!                                              01086000
      +------------------+                                              01088000
              ...                                                       01090000
      +------------------+                                              01092000
      !host part info:   !    1     STD'HOST'INX  STD'HOST'INFO         01094000
      !bit 8 = wildcards !                        STD'HOST'WILD         01096000
      !bit 9..15= length !                        STD'HOST'LEN          01098000
      +------------------+                                              01100000
      !host part text... !    0..8  STD'HOST'INX+1                      01102000
      !up to 8 characters!                        STD'HOST'             01104000
      !in length, no fill!                                              01106000
      !characters at end.!                                              01108000
      +------------------+                                              01110000
                                                                        01112000
   ----------------------------------------------------------->>        01114000
   BEGIN                                                                01116000
                                                                        01118000
   LABEL                                                                01120000
      XIT;                                                              01122000
                                                                        01124000
   BYTE ARRAY                                                           01126000
      DEFAULT'DELIMS (0:4);                                             01128000
                                                                        01130000
   LOGICAL                                                              01132000
      BITMASK     = Q - 4,                                              01134000
      CHAR'TYPE   := FALSE,                                             01136000
      DIGIT       := FALSE,                                             01138000
      DONE        := FALSE,                                             01140000
      LETTER      := FALSE,                                             01142000
      WILD        := FALSE,                                             01144000
      WILD'PART   := FALSE;                                             01146000
                                                                        01148000
   INTEGER                                                              01150000
      DELIM'INX   := 0,   <<used to index through DELIMS>>              01152000
      PART'INX    := 0,   <<index of info for current part>>            01154000
      PART'LEN    := 0,   <<length of current part>>                    01156000
      STATE       := 0,   <<0, 1, 2, 3: file, lock, group, acct>>       01158000
      TOTAL'LEN   := 0;   <<cumulative length of std title thus far>>   01160000
                                                                        01162000
   BYTE                                                                 01164000
      CHAR;                                                             01166000
                                                                        01168000
   DEFINE                                                               01170000
      STATE'FILE  = 0 #,                                                01172000
      STATE'LOCK  = 1 #,                                                01174000
      STATE'GROUP = 2 #,                                                01176000
      STATE'ACCT  = 3 #;                                                01178000
                                                                        01180000
   <<---------------------->>                                           01182000
   SUBROUTINE ERR (N); VALUE N; INTEGER N;                              01184000
      BEGIN                                                             01186000
                                                                        01188000
      ERROR:= N;                                                        01190000
      DISPLAY'TO'STANDARD:=FAILED;                                      01192000
      GO XIT;                                                           01194000
                                                                        01196000
      END <<ERR SUB>>;                                                  01198000
   <<--------------------->>                                            01200000
   SUBROUTINE APPEND'CHAR;                                              01202000
      BEGIN                                                             01204000
                                                                        01206000
      TOTAL'LEN:=TOTAL'LEN+1;                                           01208000
      IF (PART'LEN:=PART'LEN+1) > 8 THEN                                01210000
         ERR (SE'PART'TOO'LONG);       <<part too long>>                01212000
                                                                        01214000
      PSTD(TOTAL'LEN):=CHAR;                                            01216000
                                                                        01218000
      END <<APPEND'CHAR SUB>>;                                          01220000
   <<------------------------->>                                        01222000
   LOGICAL SUBROUTINE CHECK'DELIM (CHAR); VALUE CHAR; BYTE CHAR;        01224000
      BEGIN                                                             01226000
                                                                        01228000
      DELIM'INX:=DELIMS(0)+1;                                           01230000
                                                                        01232000
      WHILE (DELIM'INX:=DELIM'INX-1) > 0 DO                             01234000
         IF DELIMS(DELIM'INX) = CHAR THEN                               01236000
            BEGIN                                                       01238000
            CHECK'DELIM:=GOOD;                                          01240000
            RETURN;                                                     01242000
            END;                                                        01244000
                                                                        01246000
      CHECK'DELIM:=FAILED;                                              01248000
                                                                        01250000
      END <<CHECK'DELIM SUB>>;                                          01252000
   <<------------------------>>                                         01254000
   SUBROUTINE CLASSIFY'CHAR;                                            01256000
      BEGIN                                                             01258000
                                                                        01260000
            <<classify the character...>>                               01262000
                                                                        01264000
      WILD:=DIGIT:=LETTER:=FALSE;                                       01266000
                                                                        01268000
      IF CHAR="@" OR CHAR="?" OR CHAR="#" THEN                          01270000
         WILD:=TRUE                    <<wildcard>>                     01272000
      ELSE IF %60 <= INTEGER(CHAR) <= %71 THEN                          01274000
         DIGIT:=TRUE                   <<digit from 0..9>>              01276000
      ELSE IF %101 <= INTEGER(CHAR) <= %132 THEN                        01278000
         LETTER:=TRUE                  <<uppercase A..Z>>               01280000
      ELSE IF %141 <= INTEGER(CHAR) <= %172 THEN                        01282000
         BEGIN                                                          01284000
         LETTER:=TRUE;                 <<lowercase a..z>>               01286000
            <<upcase it...>>                                            01288000
         CHAR:=(CHAR-"a")+"A";                                          01290000
         END;                                                           01292000
                                                                        01294000
      END <<CLASSIFY'CHAR SUB>>;                                        01296000
   <<--------------------->>                                            01298000
   SUBROUTINE CLOSE'PART;                                               01300000
      BEGIN                                                             01302000
                                                                        01304000
      IF PART'LEN = 0 THEN                                              01306000
         ERR (SE'ZERO'PART);           <<zero length part>>             01308000
                                                                        01310000
      CASE STATE OF                                                     01312000
         BEGIN                                                          01314000
                                                                        01316000
         <<STATE'FILE:>>                                                01318000
            BEGIN                                                       01320000
            STD'FILE'WILD:=WILD'PART;                                   01322000
            STD'FILE'LEN:=PART'LEN;                                     01324000
            END;                                                        01326000
                                                                        01328000
         <<STATE'LOCK:>>                                                01330000
            BEGIN                                                       01332000
            STD'LOCK'WILD:=WILD'PART;                                   01334000
            STD'LOCK'LEN:=PART'LEN;                                     01336000
            END;                                                        01338000
                                                                        01340000
         <<STATE'GROUP:>>                                               01342000
            BEGIN                                                       01344000
            STD'GROUP'WILD:=WILD'PART;                                  01346000
            STD'GROUP'LEN:=PART'LEN;                                    01348000
            END;                                                        01350000
                                                                        01352000
         <<STATE'ACCT:>>                                                01354000
            BEGIN                                                       01356000
            STD'ACCT'WILD:=WILD'PART;                                   01358000
            STD'ACCT'LEN:=PART'LEN;                                     01360000
            END                                                         01362000
         END;                                                           01364000
                                                                        01366000
      END <<CLOSE'PART SUB>>;                                           01368000
   <<--------------------->>                                            01370000
   SUBROUTINE LOOK'AT'CHAR;                                             01372000
      BEGIN                                                             01374000
                                                                        01376000
      IF WILD THEN                                                      01378000
         BEGIN                         <<wildcard found>>               01380000
         WILD'PART:=TRUE;                                               01382000
         STD'WILD:=TRUE;                                                01384000
         IF LOGICAL(STD'DOLLAR) OR LOGICAL(STD'BACK) THEN               01386000
            ERR (SE'WILD'D'OR'B);      <<wild and either $ or *>>       01388000
         IF PART'LEN=0 AND CHAR="#" THEN                                01390000
            ERR (SE'FIRST'IS'DIGIT);   <<first char cant be digit>>     01392000
         END                                                            01394000
                                                                        01396000
      ELSE IF PART'LEN=0 AND DIGIT THEN                                 01398000
         ERR (SE'FIRST'IS'DIGIT);      <<first char cant be digit>>     01400000
                                                                        01402000
      APPEND'CHAR;                                                      01404000
                                                                        01406000
      END <<LOOK'AT'CHAR SUB>>;                                         01408000
   <<--------------------->>                                            01410000
   SUBROUTINE START'PART;                                               01412000
      BEGIN                                                             01414000
                                                                        01416000
      PART'INX:= (TOTAL'LEN:=TOTAL'LEN+1);                              01418000
                                                                        01420000
      CASE STATE OF                                                     01422000
         BEGIN                                                          01424000
                                                                        01426000
         <<STATE'FILE:>>                                                01428000
            BEGIN                                                       01430000
            PSTD(PART'INX):=1;                                          01432000
            PART'INX:= (TOTAL'LEN:=TOTAL'LEN+1);                        01434000
            STD'FILE'INX:=PART'INX;                                     01436000
            END;                                                        01438000
                                                                        01440000
         <<STATE'LOCK:>>                                                01442000
            STD'LOCK'INX:=PART'INX;                                     01444000
                                                                        01446000
         <<STATE'GROUP:>>                                               01448000
            STD'GROUP'INX:=PART'INX;                                    01450000
                                                                        01452000
         <<STATE'ACCT:>>                                                01454000
            STD'ACCT'INX:=PART'INX;                                     01456000
                                                                        01458000
         END;                                                           01460000
                                                                        01462000
      WILD'PART:=FALSE;                                                 01464000
      PART'LEN:=0;                                                      01466000
                                                                        01468000
      END <<START'PART SUB>>;                                           01470000
   <<--------------------->>                                            01472000
                                                                        01474000
   IF BITMASK.(11:4) <> %17 THEN                                        01476000
      ERR (SE'MISSING'PARAMETERS);                                      01478000
                                                                        01480000
   IF NOT BITMASK.(15:1) THEN                                           01482000
      BEGIN                                                             01484000
      @DELIMS:=@DEFAULT'DELIMS;                                         01486000
      MOVE DELIMS:=(%4, " ,;-");                                        01488000
      END;                                                              01490000
                                                                        01492000
   DISPLAY'TO'STANDARD:=GOOD;                                           01494000
                                                                        01496000
   ERROR:=0;                                                            01498000
                                                                        01500000
   PSTD(0):=0;                                                          01502000
   MOVE PSTD(1):=PSTD(0),(MAX'STD'LEN-1);                               01504000
   STD'VERSION:=1;            <<this is version 1 of std form>>         01506000
   TOTAL'LEN:=10-1;           <<first available index-1>>               01508000
                                                                        01510000
   STATE:=STATE'FILE;                                                   01512000
   START'PART;                                                          01514000
                                                                        01516000
   CHAR'INX:=0;                                                         01518000
   DONE:=FALSE;                                                         01520000
                                                                        01522000
   WHILE NOT DONE DO                                                    01524000
      BEGIN                                                             01526000
                                                                        01528000
            <<classify the character...>>                               01530000
                                                                        01532000
      CHAR:=PDIS(CHAR'INX);                                             01534000
      CLASSIFY'CHAR;                                                    01536000
                                                                        01538000
            <<look at the character...>>                                01540000
                                                                        01542000
      IF WILD OR LETTER OR DIGIT THEN                                   01544000
         LOOK'AT'CHAR                                                   01546000
                                                                        01548000
      ELSE IF CHAR = "." OR CHAR = "/" THEN                             01550000
         BEGIN                                                          01552000
         CLOSE'PART;                   <<close off current part>>       01554000
         IF CHAR = "/" THEN                                             01556000
            IF STATE <> STATE'FILE THEN                                 01558000
               ERR (SE'LOCKWORD'LOC)   <<bad place for lockword>>       01560000
            ELSE                                                        01562000
               STATE:=STATE'LOCK                                        01564000
         ELSE IF STATE = STATE'FILE THEN                                01566000
            STATE:=STATE'GROUP         <<dot moves from file->group>>   01568000
         ELSE IF STATE = STATE'LOCK THEN                                01570000
            STATE:=STATE'GROUP         <<dot moves from lock->group>>   01572000
         ELSE IF STATE = STATE'GROUP THEN                               01574000
            STATE:=STATE'ACCT          <<dot moves from group->acct>>   01576000
         ELSE                                                           01578000
            ERR (SE'TOO'MANY'PERIODS); <<too many periods>>             01580000
         START'PART;                   <<setup next part>>              01582000
         END                                                            01584000
                                                                        01586000
      ELSE IF CHAR = "*" THEN                                           01588000
         BEGIN                                                          01590000
         STD'BACK:=TRUE;                                                01592000
         IF STATE <> STATE'FILE OR PART'LEN <> 0 THEN                   01594000
            ERR (SE'STAR'NOT'FIRST);   <<"*" must be first character>>  01596000
         IF LOGICAL(STD'DOLLAR) THEN                                    01598000
            ERR (SE'STAR'AND'DOLLAR);  <<dollar and backref true>>      01600000
         END                                                            01602000
                                                                        01604000
      ELSE IF CHAR = "$" THEN                                           01606000
         BEGIN                                                          01608000
         STD'DOLLAR:=TRUE;                                              01610000
         IF STATE <> STATE'FILE OR PART'LEN <> 0 THEN                   01612000
            ERR (SE'DOLLAR'NOT'FIRST); <<"$" must be first character>>  01614000
         IF LOGICAL(STD'BACK) THEN                                      01616000
            ERR (SE'STAR'AND'DOLLAR);  <<dollar and backref bad>>       01618000
         END                                                            01620000
                                                                        01622000
      ELSE IF CHECK'DELIM (CHAR) = GOOD THEN                            01624000
         DONE:=TRUE                                                     01626000
                                                                        01628000
      ELSE                                                              01630000
         ERR (SE'ILLEGAL'CHARACTER);   <<invalid title character>>      01632000
                                                                        01634000
      IF NOT DONE THEN                                                  01636000
         CHAR'INX:=CHAR'INX+1;                                          01638000
                                                                        01640000
      END;                                                              01642000
                                                                        01644000
   CLOSE'PART;                                                          01646000
                                                                        01648000
   TOTAL'LEN:=TOTAL'LEN+1;                                              01650000
   PSTD(0):=TOTAL'LEN.(0:8);                                            01652000
   PSTD(1):=TOTAL'LEN.(8:8);                                            01654000
                                                                        01656000
XIT:                                                                    01658000
                                                                        01660000
   END <<DISPLAY'TO'STANDARD PROC>>;                                    01662000
$PAGE "STANDARD'TO'DISPLAY"                                             01664000
<<************************************************************>>        01666000
LOGICAL PROCEDURE STANDARD'TO'DISPLAY (PSTD, PDIS, ERROR, LEN);         01668000
            VALUE PSTD, PDIS;                                           01670000
            INTEGER ERROR, LEN;                                         01672000
            BYTE POINTER PSTD, PDIS;                                    01674000
   BEGIN                                                                01676000
   INTEGER                                                              01678000
      PART'LEN;                                                         01680000
   LABEL                                                                01682000
      XIT;                                                              01684000
   <<------------------>>                                               01686000
   SUBROUTINE ERR (N); VALUE N; INTEGER N;                              01688000
      BEGIN                                                             01690000
                                                                        01692000
      ERROR:=N;                                                         01694000
      STANDARD'TO'DISPLAY:=FAILED;                                      01696000
      GO XIT;                                                           01698000
                                                                        01700000
      END <<ERR SUB>>;                                                  01702000
   <<------------------->>                                              01704000
   SUBROUTINE APPEND'CHAR (CHAR); VALUE CHAR; BYTE CHAR;                01706000
      BEGIN                                                             01708000
                                                                        01710000
      PDIS(LEN):=CHAR;                                                  01712000
      LEN:=LEN+1;                                                       01714000
      IF LEN > MAX'TITLE'LEN THEN                                       01716000
         ERR (DE'STANDARD'TOO'LONG);                                    01718000
                                                                        01720000
      END <<APPEND'CHAR SUB>>;                                          01722000
   <<------------------>>                                               01724000
   SUBROUTINE APPEND'PART (CHAR, INX); VALUE CHAR, INX;                 01726000
            BYTE CHAR;                                                  01728000
            INTEGER INX;                                                01730000
      BEGIN                                                             01732000
                                                                        01734000
      IF CHAR <> " " THEN                                               01736000
         APPEND'CHAR (CHAR);                                            01738000
                                                                        01740000
      PART'LEN:=PSTD(INX).STD'PART'LENf;                                01742000
      WHILE PART'LEN > 0 DO                                             01744000
         BEGIN                                                          01746000
         INX:=INX+1;                                                    01748000
         PART'LEN:=PART'LEN-1;                                          01750000
         APPEND'CHAR (PSTD(INX));                                       01752000
         END;                                                           01754000
                                                                        01756000
      END <<APPEND'PART SUB>>;                                          01758000
   <<---------------------->>                                           01760000
                                                                        01762000
   ERROR:=0;                                                            01764000
                                                                        01766000
   LEN:=0;                                                              01768000
                                                                        01770000
   IF LOGICAL(STD'BACK) THEN                                            01772000
      APPEND'CHAR ("*")                                                 01774000
   ELSE IF LOGICAL(STD'DOLLAR) THEN                                     01776000
      APPEND'CHAR ("$");                                                01778000
                                                                        01780000
   IF STD'FILE'INX = 0 THEN                                             01782000
      ERR (DE'STANDARD'EMPTY)                                           01784000
   ELSE                                                                 01786000
      APPEND'PART (" ", STD'FILE'INX);                                  01788000
                                                                        01790000
   IF STD'LOCK'INX > 0 THEN                                             01792000
      APPEND'PART ("/", STD'LOCK'INX);                                  01794000
                                                                        01796000
   IF STD'GROUP'INX > 0 THEN                                            01798000
      APPEND'PART (".", STD'GROUP'INX);                                 01800000
                                                                        01802000
   IF STD'ACCT'INX > 0 THEN                                             01804000
      APPEND'PART (".", STD'ACCT'INX);                                  01806000
                                                                        01808000
   APPEND'CHAR (" ");                                                   01810000
   LEN:=LEN-1;                <<dont count trailing blank>>             01812000
                                                                        01814000
   STANDARD'TO'DISPLAY := GOOD;                                         01816000
                                                                        01818000
XIT:                                                                    01820000
                                                                        01822000
   END <<STANDARD'TO'DISPLAY PROC>>;                                    01824000
$PAGE"PATTERN'BUILD"                                                    01826000
LOGICAL PROCEDURE PATTERN'BUILD (PTEXT, PATTERN, ERROR'CODE);           01828000
         VALUE PTEXT;                                                   01830000
         INTEGER ERROR'CODE;                                            01832000
         BYTE POINTER PTEXT;                                            01834000
         INTEGER ARRAY PATTERN;                                         01836000
      << This routine encodes a "pattern" into a special format for     01838000
        use by the procedure PATTERN'MATCH.  (See the comment in        01840000
        that procedure for the layout of an encoded "pattern".)         01842000
                                                                        01844000
        This assumes PTEXT points to a string of 1 to PAT'MAX'FIRM      01846000
        characters composed of (usually) A..Z, a..z, 0..9, and          01848000
        "#?@".  This string is a "pattern".  PAT'MAX'FIRM is usually    01850000
        8.  The first byte of the text is the length of the text,       01852000
        not self-inclusive.  Thus the text "CAT#" would be represented  01854000
        as:  %4, "C", "A", "T", "#".                                    01856000
                                                                        01858000
        Note: for compatibility with standard-form titles,              01860000
        only the bottom 7 bits of the length are used...thus,           01862000
        a pointer like:   %(2)10000011, "C", "?", "#"                   01864000
        can be passed into PATTERN'BUILD without having to              01866000
        zap the wildcard bit.                                           01868000
                                                                        01870000
        If more than PAT'MAX'PART parts are found in the pattern text,  01872000
        the routine result will be FAILED and ERROR'CODE will be set    01874000
        to PB'ERR'MANY'PARTS.  PAT'MAX'PART is usually 8.               01876000
                                                                        01878000
        If the pattern text contains more than PAT'MAX'FIRM "firm"      01880000
        characters, a FAILED will be returned and ERROR'CODE will be    01882000
        set to PB'ERR'MANY'FIRM.  PAT'MAX'FIRM is usually 8.            01884000
        A "firm" character is any character that matches at least       01886000
        1 character (i.e: any character other than "@" is a "firm"      01888000
        character).                                                     01890000
                                                                        01892000
        If no error is found, GOOD is returned and ERROR'CODE:=0.       01894000
                                                                        01896000
        PATTERN must be at least 9 words long, even though a short      01898000
        pattern wont use all 9 words.  PATTERN is zeroed at the         01900000
        start of the routine.                                           01902000
                                                                        01904000
        Note that the pattern text is NOT shifted to uppercase!         01906000
                                                                  >>    01908000
      <<---------------------------------------------------------->>    01910000
   BEGIN                                                                01912000
                                                                        01914000
   INTEGER                                                              01916000
      I,                                                                01918000
      FIRMCOUNT   := 0,       <<number of "firm" chars seen>>           01920000
      LEN,                                                              01922000
      PART        := 0,       <<number of parts seen>>                  01924000
      TEXTLEFT;                                                         01926000
                                                                        01928000
   BYTE ARRAY                                                           01930000
      TEXT'COPY'  (0:64);     <<holds a copy of PTEXT(1...)>>           01932000
                                                                        01934000
   LABEL                                                                01936000
      END'PATTERN'BUILD;                                                01938000
                                                                        01940000
   <<------------------->>                                              01942000
   SUBROUTINE FAIL (N); VALUE N; INTEGER N;                             01944000
      BEGIN                                                             01946000
      PATTERN'BUILD:=FAILED;                                            01948000
      ERROR'CODE:=N;                                                    01950000
      GO END'PATTERN'BUILD;                                             01952000
      END <<FAIL SUB>>;                                                 01954000
   <<------------------->>                                              01956000
                                                                        01958000
   ERROR'CODE:=0;                                                       01960000
   PATTERN(0):=0;                                                       01962000
   MOVE PATTERN(1):=PATTERN(0),(PAT'MAX'PART);                          01964000
                                                                        01966000
   TEXTLEFT:=INTEGER(PTEXT).(9:7);     <<only use bottom 7 bits>>       01968000
                                                                        01970000
   MOVE TEXT'COPY':=PTEXT(1),(TEXTLEFT), 2;                             01972000
   MOVE *:=0;                          <<append a stopper>>             01974000
   @PTEXT:=@TEXT'COPY';                                                 01976000
                                                                        01978000
   WHILE TEXTLEFT > 0 DO                                                01980000
      BEGIN                                                             01982000
                                                                        01984000
      PART:=PART+1;                                                     01986000
      IF PART > PAT'MAX'PART THEN                                       01988000
         FAIL (PB'ERR'MANY'PARTS);                                      01990000
                                                                        01992000
      IF PTEXT = "?" THEN              <<match any 1 character>>        01994000
         BEGIN                <<count number of contiguous "?"...>>     01996000
         SCAN PTEXT WHILE "?",1;       <<leave pointer>>                01998000
         LEN:=TOS-@PTEXT;              <<number of "?">>                02000000
         PATTERN(PART).PATLENf := LEN;                                  02002000
         PATTERN(PART).PATCHARf:="?";                                   02004000
         PATTERN(PART).PATTYPEf:= ANYONECHARACTERp;                     02006000
         FIRMCOUNT:=FIRMCOUNT+LEN;                                      02008000
         END                                                            02010000
                                                                        02012000
      ELSE IF PTEXT = "#" THEN         <<match digit>>                  02014000
         BEGIN                <<count number of contiguous "#"...>>     02016000
         SCAN PTEXT WHILE "#",1;       <<leave pointer>>                02018000
         LEN:=TOS-@PTEXT;              <<number of "#">>                02020000
         PATTERN(PART).PATLENf := LEN;                                  02022000
         PATTERN(PART).PATCHARf:= "#";                                  02024000
         PATTERN(PART).PATTYPEf:= DIGITONLYp;                           02026000
         FIRMCOUNT:=FIRMCOUNT + LEN;                                    02028000
         END                                                            02030000
                                                                        02032000
      ELSE IF PTEXT = "@" THEN   <<matches any number of characters>>   02034000
         BEGIN                <<count number of contiguous "@"...>>     02036000
         SCAN PTEXT WHILE "@",1;       <<leave pointer>>                02038000
         LEN:=TOS-@PTEXT;              <<number of "?">>                02040000
         PATTERN(PART).PATLENf := LEN;                                  02042000
         PATTERN(PART).PATCHARf:="@";                                   02044000
         PATTERN(PART).PATTYPEf:= ANYCHARACTERSp;                       02046000
         END                                                            02048000
                                                                        02050000
      ELSE                    <<not a pattern match character...>>      02052000
         BEGIN                                                          02054000
         I:=INTEGER(PTEXT);                                             02056000
         SCAN PTEXT WHILE I, 1;                                         02058000
         LEN:=TOS-@PTEXT;                                               02060000
         PATTERN(PART).PATLENf := LEN;                                  02062000
         PATTERN(PART).PATCHARf:= INTEGER(PTEXT);                       02064000
         PATTERN(PART).PATTYPEf:= EXACTp;                               02066000
         FIRMCOUNT:=FIRMCOUNT+LEN;                                      02068000
         END;                                                           02070000
                                                                        02072000
      IF FIRMCOUNT > PAT'MAX'FIRM THEN                                  02074000
         FAIL (PB'ERR'MANY'FIRM);                                       02076000
                                                                        02078000
      @PTEXT:=@PTEXT+LEN;                                               02080000
      TEXTLEFT:=TEXTLEFT-LEN;                                           02082000
      END;                                                              02084000
                                                                        02086000
   PATTERN(0):=PART;          <<remember how many parts in pattern.>>   02088000
                                                                        02090000
   PATTERN'BUILD:=GOOD;                                                 02092000
                                                                        02094000
END'PATTERN'BUILD:                                                      02096000
                                                                        02098000
   END <<PATTERN'BUILD PROC>>;                                          02100000
$PAGE "PATTERN'MATCH"                                                   02102000
<<***************************************************************>>     02104000
LOGICAL PROCEDURE PATTERN'MATCH (PTEXT, PATTERN);                       02106000
         VALUE PTEXT;                                                   02108000
         BYTE POINTER PTEXT;                                            02110000
         INTEGER ARRAY PATTERN;                                         02112000
      <<This routine compares the pattern in PATTERN to the             02114000
        title in PTEXT.  Byte(0) of PTEXT is the text length            02116000
        (0 to PAT'MAX'FIRM (usually 8)).  Only the bottom 7             02118000
        bits of the length are used...this maintains compatibility      02120000
        with standard-form titles, which may use the eighth bit         02122000
        as a wildcard flag.                                             02124000
                                                                        02126000
        If the text in PTEXT matches the pattern in PATTERN,            02128000
        a GOOD is returned, otherwise a FAILED.                         02130000
                                                                        02132000
        The layout of PATTERN is:                                       02134000
            PATTERN (0) = number of parts in the pattern.               02136000
            PATTERN (1..PATTERN(0)) = separate pattern parts.           02138000
        Each pattern part is a single word (16 bits) that looks         02140000
        like:                                                           02142000
              0  1  2    7  8        15                                 02144000
            +------+------+--+--------+                                 02146000
            ! Part ! Part ! Part      !                                 02148000
            ! Type !Length! Character !                                 02150000
            !      !      !           !                                 02152000
            +------+------+-----------+                                 02154000
        Field names:                                                    02156000
             PATTYPEf = (0:2)  PATLENf = (2:6)  PATCHARf = (8:8)        02158000
Char:   Possible types:          Meanings:                              02160000
                                                                        02162000
  ?        ANYONECHARACTERp      Match any sequence of PATLENf          02164000
                                 characters.                            02166000
                                                                        02168000
  @        ANYCHARACTERSp        Match any number of characters.        02170000
                                 PATLENf is disregarded, but happens    02172000
                                 to be the number of contiguous         02174000
                                  "@"'s found in the original           02176000
                                 pattern.                               02178000
                                                                        02180000
  #        DIGITONLYp            Match any sequence of PATLENf          02182000
                                 digits.                                02184000
                                                                        02186000
  A..Z,    EXACTp                Match the exact ASCII character        02188000
  a..z, 0..9, ...                that is found in PATLENf field.        02190000
                                                                        02192000
      A pattern text of:  CA?D#@ would be represented as:               02194000
                                                                        02196000
         6, (EXACTp, 1, "C"), (EXACTp, 1, "A"),                         02198000
            (ANYONECHARACTERp, 1, "?"), (EXACTp, 1, "D"),               02200000
            (DIGITONLYp, 1, "#"), (ANYCHARACTERSp, 1, "@")              02202000
                                                                        02204000
      A pattern text of:  ??@@AA would be represented as:               02206000
                                                                        02208000
         3, (ANYONECHARACTERp, 2, "?"), (ANYCHARACTERSp, 2, "@"),       02210000
            (EXACTp, 2, "A")                                            02212000
                                                                >>      02214000
   <<----------------------------------------------------------->>      02216000
   BEGIN                                                                02218000
                                                                        02220000
   PATTERN'MATCH:=SUB'MATCH (PTEXT(1),                                  02222000
                             INTEGER(PTEXT).(9:7),                      02224000
                             PATTERN, 1);                               02226000
                                                                        02228000
   END <<PATTERN'MATCH PROC>>;                                          02230000
$PAGE "SUB'MATCH"                                                       02232000
<<***************************************************************>>     02234000
LOGICAL PROCEDURE SUB'MATCH (PTEXT, ACTUALLEN, PATTERN, STARTPART);     02236000
         VALUE PTEXT, ACTUALLEN, STARTPART;                             02238000
         INTEGER ACTUALLEN, STARTPART;                                  02240000
         BYTE POINTER PTEXT;                                            02242000
         INTEGER ARRAY PATTERN;                                         02244000
      <<This routine attempts to match the remaining portion            02246000
        of the pattern versus the remaining portion of the              02248000
        original text.  If the match succeeds, GOOD is                  02250000
        returned, otherwise FAILED.                                     02252000
        Note: it is recursive!>>                                        02254000
   BEGIN                                                                02256000
   INTEGER                                                              02258000
      I,                                                                02260000
      LEN,                                                              02262000
      MINLEN,                                                           02264000
      PART,                                                             02266000
      PARTS;                                                            02268000
                                                                        02270000
   SUB'MATCH:=FAILED;                                                   02272000
                                                                        02274000
   MINLEN:=0;                                                           02276000
   PARTS:=PATTERN(0);                                                   02278000
   PART:=STARTPART-1;                                                   02280000
                                                                        02282000
         <<determine minimum length that the rest of the                02284000
           pattern must be...>>                                         02286000
                                                                        02288000
   WHILE (PART:=PART+1) <= PARTS DO                                     02290000
      IF (I:=PATTERN(PART)).PATTYPEf <> ANYCHARACTERSp THEN             02292000
         MINLEN:=MINLEN+I.PATLENf;                                      02294000
                                                                        02296000
         <<see if test string has any possible chance of matching       02298000
           pattern...>>                                                 02300000
                                                                        02302000
   IF MINLEN > ACTUALLEN THEN                                           02304000
      RETURN;                 <<FAILED>>                                02306000
                                                                        02308000
         <<loop thru easy parts, recursing to handle                    02310000
           complex parts ("@")...>>                                     02312000
                                                                        02314000
   PART:=STARTPART-1;                                                   02316000
                                                                        02318000
   WHILE (PART:=PART+1) <= PARTS DO                                     02320000
      BEGIN                                                             02322000
      I:=PATTERN(PART);                                                 02324000
      LEN:=I.PATLENf;         <<length of this part>>                   02326000
                                                                        02328000
      IF (ACTUALLEN < LEN) AND I.PATTYPEf <> ANYCHARACTERSp THEN        02330000
         RETURN;              <<can't possibly match>>                  02332000
                                                                        02334000
      CASE I.PATTYPEf OF                                                02336000
         BEGIN                                                          02338000
                                                                        02340000
         <<ANYONECHARACTERp:>>                                          02342000
            ;                          <<valid match, by definition!>>  02344000
                                                                        02346000
         <<ANYCHARACTERSp:>>                                            02348000
            BEGIN                      <<match from 0 to ACTUALLEN>>    02350000
            IF PART = PARTS THEN                                        02352000
               BEGIN                                                    02354000
               SUB'MATCH:=GOOD;        <<is last part.>>                02356000
               RETURN;                                                  02358000
               END;                                                     02360000
                  <<try matching with 0, 1, ..., ACTUALLEN chars...>>   02362000
            LEN:=ACTUALLEN-MINLEN;                                      02364000
            DO                                                          02366000
               IF SUB'MATCH (PTEXT(LEN), ACTUALLEN-LEN,                 02368000
                             PATTERN, PART+1) = GOOD THEN               02370000
                  BEGIN                                                 02372000
                  SUB'MATCH:=GOOD;     <<it worked!>>                   02374000
                  RETURN;                                               02376000
                  END                                                   02378000
            UNTIL                                                       02380000
               (LEN:=LEN-1) < 0;                                        02382000
            RETURN;                    <<it failed!>>                   02384000
            END;                                                        02386000
                                                                        02388000
         <<DIGITONLYp:>>                                                02390000
            BEGIN                                                       02392000
            WHILE (LEN:=LEN-1) >= 0 DO                                  02394000
               IF PTEXT(LEN) <> NUMERIC THEN                            02396000
                  RETURN;              <<not a digit!>>                 02398000
            LEN:=I.PATLENf;                                             02400000
            END;                                                        02402000
                                                                        02404000
         <<EXACTp:>>                                                    02406000
            BEGIN                                                       02408000
            WHILE (LEN:=LEN-1) >= 0 DO                                  02410000
               IF INTEGER(PTEXT(LEN)) <> I.PATCHARf THEN                02412000
                  RETURN;                 <<mismatched!>>               02414000
            LEN:=I.PATLENf;                                             02416000
            END;                                                        02418000
         END;                                                           02420000
                                                                        02422000
      MINLEN:=MINLEN-LEN;              <<subtract # chars matched>>     02424000
      ACTUALLEN:=ACTUALLEN-LEN;        <<ditto>>                        02426000
      @PTEXT:=@PTEXT(LEN);             <<point to remainder of text>>   02428000
                                                                        02430000
      END;        <<end of while loop>>                                 02432000
                                                                        02434000
   IF ACTUALLEN = 0 THEN                                                02436000
      SUB'MATCH:=GOOD;                 <<matched ok!>>                  02438000
                                                                        02440000
   END <<SUB'MATCH PROC>>;                                              02442000
$PAGE "PATTERNMATCH"                                                    02444000
LOGICAL PROCEDURE PATTERNMATCH (CUR'FILE,PAT'FILE);                     02446000
                  VALUE CUR'FILE,PAT'FILE;                              02448000
                  BYTE POINTER CUR'FILE,PAT'FILE;                       02450000
BEGIN                                                                   02452000
                                                                        02454000
 BYTE POINTER                                                           02456000
    PSTD,          << Used for STD'... defines >>                       02458000
    CUR'NAME,      << Pointers to filename field, >>                    02460000
    CUR'GROUP,     << file group field, >>                              02462000
    CUR'ACCT,      << file acct field, >>                               02464000
    PAT'NAME,      << pattern name field, >>                            02466000
    PAT'GROUP,     << pattern group field, >>                           02468000
    PAT'ACCT;      << and pattern acct field. >>                        02470000
                                                                        02472000
 INTEGER ARRAY PATTERN(0:8); << BUILT PATTERN GOES HERE >>              02474000
                                                                        02476000
 INTEGER ERROR'CODE; << USED FOR ERRORS FROM PATTERNBUILD >>            02478000
                                                                        02480000
  PATTERNMATCH := FALSE;                                                02482000
                                                                        02484000
  @PSTD     := @CUR'FILE;    << to use following defines >>             02486000
  @CUR'NAME := @PSTD( STD'FILE'INX );  << Pick off filename >>          02488000
  @CUR'GROUP:= @PSTD( STD'GROUP'INX ); << Pick off file group >>        02490000
  @CUR'ACCT := @PSTD( STD'ACCT'INX );  << Pick off file acct >>         02492000
                                                                        02494000
  @PSTD     := @PAT'FILE;    << Now point to pattern file... >>         02496000
  @PAT'NAME := @PSTD( STD'FILE'INX );  << Pattern name... >>            02498000
  @PAT'GROUP:= @PSTD( STD'GROUP'INX);  << Pattern group... >>           02500000
  @PAT'ACCT := @PSTD( STD'ACCT'INX);   << Pattern acct ...>>            02502000
                                                                        02504000
  PATTERN'BUILD( PAT'NAME, PATTERN , ERROR'CODE);                       02506000
  IF ERROR'CODE <> 0 THEN   << FAILED TO BUILD PATTERN >>               02508000
     BEGIN                                                              02510000
      PRINT'MESSAGE(NAME'PATTERN'ERROR);                                02512000
      RETURN;                                                           02514000
     END;                                                               02516000
  IF PATTERN'MATCH( CUR'NAME, PATTERN ) = FAILED THEN RETURN;           02518000
                                                                        02520000
  PATTERN'BUILD( PAT'GROUP, PATTERN, ERROR'CODE );                      02522000
  IF ERROR'CODE <> 0 THEN  << FAILED TO BUILD GROUP PAT >>              02524000
     BEGIN                                                              02526000
      PRINT'MESSAGE(GROUP'PATTERN'ERROR);                               02528000
      RETURN;                                                           02530000
     END;                                                               02532000
  IF PATTERN'MATCH( CUR'GROUP, PATTERN) = FAILED THEN RETURN;           02534000
                                                                        02536000
  PATTERN'BUILD( PAT'ACCT, PATTERN, ERROR'CODE );                       02538000
  IF ERROR'CODE <> 0 THEN                                               02540000
     BEGIN                                                              02542000
      PRINT'MESSAGE(ACCOUNT'PATTERN'ERROR);                             02544000
      RETURN;                                                           02546000
     END;                                                               02548000
  IF PATTERN'MATCH( CUR'ACCT, PATTERN)  = FAILED THEN RETURN;           02550000
                                                                        02552000
  <<  MADE IT ! >>                                                      02554000
  PATTERNMATCH := TRUE;                                                 02556000
  RETURN;                                                               02558000
END; << PATTERNMATCH >>                                                 02560000
                                                                        02562000
                                                                        02564000
$PAGE "CONTROLY"                                                        02566000
!-----------------------------------------------------------------------02568000
! CONTROLY  is  the  procedure  entered  in  the event of a user hitting02570000
! Control Y.  It is a very standard procedure.  It switches the CONTROL'02572000
! 'Y'DETECTED flag so that after the current file is recovered, the user02574000
! is  asked  if  he  wishes  to continue or not.  Then, the Control-Y is02576000
! reset and we return to the point where the Control Y was hit.  This is02578000
! This is done by placing %31400+n on the stack and executiEXIT instruc-02580000
! where  n  is the number of words currently in the stack plus the stack02582000
! plus  the stack marker.  For more information, see the INTRINSICS man-02584000
! al under CONTROL Y.                                                   02586000
!-----------------------------------------------------------------------02588000
                                                                        02590000
PROCEDURE CONTROLY;                                                     02592000
BEGIN                                                                   02594000
INTEGER SDEC=Q+1;                                                       02596000
CONTROL'Y'DETECTED:=TRUE;                                               02598000
PRINT'MESSAGE(CONTROLY'DETECTED);                                       02600000
RESETCONTROL;                                                           02602000
TOS:=EXITN+SDEC;                                                        02604000
ASSEMBLE(XEQ 0);                                                        02606000
END;                                                                    02608000
$PAGE "CHECK'LIST"                                                      02610000
LOGICAL PROCEDURE CHECK'LIST;                                           02612000
 << This procedure chases down the list of filesets entered             02614000
     and tries to convert them to standard form.  If we succeed,        02616000
    "TRUE" is returned, if not, an error message is printed,            02618000
    the user is prompted for more input, and "FALSE" is returned>>      02620000
                                                                        02622000
 BEGIN                                                                  02624000
  INTEGER ARRAY ERROR'LIST(*)=PB := PART'TOO'LONG,ZERO'LEN,INVALID'WILD,02626000
  NUMERIC'ILLEGAL,INVALID'LOCKWORD,TOO'MANY'PERIODS,INVALID'STAR,       02628000
  INVALID'SPECIAL'CHARS,INVALID'DOLLAR,ILLEGAL'CHAR,PARMS'MISSING;      02630000
                                                                        02632000
  LOGICAL EOL:=FALSE;                                                   02634000
  BYTE POINTER PSTD;                                                    02636000
  BYTE ARRAY DELIMS(0:5);                                               02638000
  BYTE POINTER DPTR := @DELIMS;                                         02640000
  MOVE DELIMS := (%4," ,",%15,%0);                                      02642000
  @LIST'PT := @FILE'LIST;    <<point to begin of list>>                 02644000
  @OUT'PT  := @OUT'LIST;     <<point to begin of stnd list>>            02646000
  KOUNT := 0;                                                           02648000
  NUM'STRICT := 0;                                                      02650000
                                                                        02652000
   DO BEGIN                                                             02654000
    SCAN LIST'PT WHILE "  ",1;                                          02656000
    @LIST'PT := TOS;                                                    02658000
    DISPLAY'TO'STANDARD(LIST'PT,OUT'PT,ERROR,CHAR'INX,DPTR);            02660000
                                                                        02662000
    IF ERROR = 0 THEN        <<converted to stnd form o.k.>>            02664000
     BEGIN                                                              02666000
      @PSTD := @OUT'PT;  << To use STD'WILD define >>                   02668000
      IF  STD'WILD = 0  THEN NUM'STRICT := NUM'STRICT + 1               02670000
                    ELSE GOT'WILD   := TRUE;                            02672000
      @OUT'PT := @OUT'PT + MAX'STD'LEN;<<bump stnd list pointer>>       02674000
      KOUNT := KOUNT +1;     <<count the number of filesets entered>>   02676000
       IF KOUNT > MAX'LIST THEN                                         02678000
        BEGIN                                                           02680000
         PRINT'MESSAGE(EXCESSIVE'FILESETS);                             02682000
         NUM'STRICT := MAX'LIST;                                        02684000
         KOUNT := MAX'LIST;                                             02686000
         CHECK'LIST := TRUE;                                            02688000
         RETURN;                                                        02690000
        END;                                                            02692000
      @LIST'PT := @LIST'PT + CHAR'INX ;                                 02694000
      SCAN LIST'PT WHILE "  ",1;                                        02696000
      @LIST'PT := TOS;                                                  02698000
      IF LIST'PT = "," THEN @LIST'PT := @LIST'PT + 1                    02700000
      ELSE IF LIST'PT =  0  THEN EOL := TRUE                            02702000
           ELSE BEGIN                                                   02704000
                   ERROR := SE'ILLEGAL'CHARACTER;                       02706000
                   GO TO ERRMSG;                                        02708000
                END;                                                    02710000
     END                                                                02712000
    ELSE << error from DISPLAY'TO'STND >>                               02714000
     BEGIN                                                              02716000
ERRMSG:                                                                 02718000
       LEN := @END'OF'LIST - @LIST'PT + 1 ;<<len of input ignored>>     02720000
       MOVE IO'BUFFER'B := LIST'PT,(LEN);                               02722000
       PRINT (IO'BUFFER,-LEN," ");                                      02724000
       IO'BUFFER'B := " ";                                              02726000
       MOVE IO'BUFFER'B(1) := IO'BUFFER'B,(LEN-1);                      02728000
       MOVE IO'BUFFER'B(CHAR'INX) := "^";                               02730000
       PRINT (IO'BUFFER,-LEN," ");                                      02732000
       PRINT'MESSAGE(ERROR'LIST(ERROR-1));                              02734000
       PRINT'MESSAGE(REENTER'FILESETS);                                 02736000
       @LIST'PT := @FILE'LIST;      <<back up and try again...>>        02738000
       CHECK'LIST := FALSE;                                             02740000
       RETURN;                                                          02742000
      END;                                                              02744000
     END UNTIL EOL = TRUE OR KOUNT > MAX'LIST;                          02746000
    CHECK'LIST := TRUE;                                                 02748000
    RETURN;                                                             02750000
   END;  <<  CHECK'LIST  >>                                             02752000
<<                                                           >>         02754000
$PAGE "MATCHES'LIST"                                                    02756000
LOGICAL PROCEDURE MATCHES'LIST;                                         02758000
 << This Procedure compares the current filename (from FORMDES)         02760000
    with the list of filesets specified.  If it matches a fileset       02762000
    on the list, "TRUE" is returned and the existing file is not        02764000
    overwritten.                                               >>       02766000
                                                                        02768000
 BEGIN                                                                  02770000
  INTEGER K:= 0;                                                        02772000
  @OUT'PT := @OUT'LIST;           <<point to begin of stnd list>>       02774000
   DO BEGIN                       <<loop for each fileset on list>>     02776000
    IF PATTERNMATCH(FORMDES'STD'PTR,OUT'PT) = TRUE THEN                 02778000
     BEGIN                        <<file was on list...>>               02780000
      MATCHES'LIST := TRUE;       <<return "TRUE">>                     02782000
      RETURN;                                                           02784000
     END;                                                               02786000
    @OUT'PT := @OUT'PT + MAX'STD'LEN;  <<bump list pointer>>            02788000
    K := K + 1;                        <<bump fileset counter>>         02790000
   END UNTIL K = KOUNT;       << loop to next fileset on list >>        02792000
  MATCHES'LIST := FALSE;     <<if we fall through -> no match>>         02794000
  RETURN;                                                               02796000
 END;   << MATCHES'LIST >>                                              02798000
$PAGE "PRINT'MESSAGE"                                                   02800000
PROCEDURE PRINT'MESSAGE(MESSAGE'NUM,FNUM,CCTL);                         02802000
VALUE MESSAGE'NUM,FNUM,CCTL;                                            02804000
INTEGER MESSAGE'NUM,FNUM,CCTL;                                          02806000
OPTION VARIABLE;                                                        02808000
                                                                        02810000
BEGIN                                                                   02812000
INTEGER                                                                 02814000
   ERROR'CODE;                                                          02816000
LOGICAL                                                                 02818000
   PMAP = Q-4;                                                          02820000
DEFINE                                                                  02822000
   L = LEN := MOVE IO'BUFFER'B(29) :=#,                                 02824000
   P = LEN := MOVE IO'BUFFER'B :=#,                                     02826000
   CCTL'SPECIFIED = PMAP.(15:1)#,                                       02828000
   FNUM'SPECIFIED = PMAP.(14:1)#;                                       02830000
                                                                        02832000
IF NOT CCTL'SPECIFIED THEN                                              02834000
   CCTL := 0;                                                           02836000
                                                                        02838000
IF MESSAGE'NUM >= 100 THEN                                              02840000
   BEGIN   ! Insert the file name and FWRITE to list file.              02842000
   MOVE IO'BUFFER'B := FILE'NAME,(26);                                  02844000
   MOVE IO'BUFFER'B(26) := " - ";                                       02846000
   CASE (MESSAGE'NUM MOD 100) OF                                        02848000
     BEGIN                                                              02850000
     L "duplicate name in directory, file not recovered";               02852000
     L "FOPEN of existing file to purge failed";                        02854000
     L "purge of existing file failed";                                 02856000
     L "FCLOSE to save the file failed";                                02858000
     L "the file on the tape is shorter than calculated";               02860000
     L "successful recovery of file";                                   02862000
     L "I/O error when reading/writing the file label";                 02864000
     L "has more user labels on the tape than file label reflects";     02866000
     L "write error while writing the file's user labels";              02868000
     L "write error while writing data to the file";                    02870000
     L "has more data records on tape than the file label reflects";    02872000
     L "FOPEN of the disc file failed";                                 02874000
     L "FFILEINFO of file failed";                                      02876000
     L "read error encountered on data portion of file on tape";        02878000
     L "continues on another tape";                                     02880000
     END;                                                               02882000
   LEN := LEN+29;                                                       02884000
   END                                                                  02886000
ELSE                                                                    02888000
   BEGIN   ! Just PRINT the message, no file name attached.             02890000
   CASE MESSAGE'NUM - 1 OF                                              02892000
     BEGIN                                                              02894000
     P "Error occured on forward space file of 'RECOVTP'";              02896000
     P "Answer 'YES' or 'NO'";                                          02898000
     P "FCLOSE of output file 'LIST' failed";                           02900000
     P "FCLOSE of file 'RECOVTP' failed";                               02902000
     P "The file 'RECOVTP' is not in the SADUTIL format";               02904000
     P "Error occured on rewind-unload of 'RECOVTP'";                   02906000
     P "Mount a new recovery tape or serial disc";                      02908000
     P "Read error encountered on file label block of tape";            02910000
     P "Catastrophic tape error, can't continue";                       02912000
     P "Enter filesets to recover";                                     02914000
     P "Terminate the fileset list with a null line";                   02916000
     P ">";                                                             02918000
     P " ";                                                             02920000
     P "Do you wish to keep existing copies of files? ";                02922000
     P "RECOVER5 V.UU.FF (C) HEWLETT-PACKARD CO., 1984";                02924000
     P "RECOVER5 will only run on MPE-V (G.00.00) or later";            02926000
     P "FOPEN of output file 'LIST' failed";                            02928000
     P "FOPEN of $STDIN failed";                                        02930000
     P "You must have system manager capability to run RECOVER5";       02932000
     P "FOPEN of tape or serial disc file 'RECOVTP' failed";            02934000
     P "CONTROL-Y detected, do you wish to continue? ";                 02936000
     P "Is there another recovery tape available? ";                    02938000
     P "Is there a continuation tape for this file? ";                  02940000
     P "CONTROL-Y will be acknowleged at the end of this file";         02942000
     P "Error building pattern in paternmatch-name";                    02944000
     P "Error building pattern in paternmatch-group";                   02946000
     P "Error building pattern in paternmatch-account";                 02948000
     P "Exessive filesets ignored (10 accepted)";                       02950000
     P "Part too long";                                                 02952000
     P "Zero length part found";                                        02954000
     P "Found wildcard and either '$' or '*'";                          02956000
     P "First character of part may not be numeric";                    02958000
     P "Lockword may only follow the file part";                        02960000
     P "Too many periods were found, the maximum is two";               02962000
     P "A '*' was found, but it wasn't the first character";            02964000
     P "Both '$' and '*' may not be specified";                         02966000
     P "A '$' was found, but it wasn't the first character";            02968000
     P "An illegal character was found";                                02970000
     P "Needed parameters to the proc were missing";                    02972000
     P "Reenter all filesets";                                          02974000
     P "FWRITE to output file 'LIST' failed";                           02976000
     P "Mount and reply to tape or serial disc file 'RECOVTP'";         02978000
     P "The tape mounted doesn't contain the continuation of this file";02980000
     END;                                                               02982000
  END;                                                                  02984000
                                                                        02986000
IF MESSAGE'NUM >= 100 THEN                                              02988000
   BEGIN   ! Output message to file "LIST" and get file error.          02990000
   IF MESSAGE'NUM >= 200                                                02992000
      THEN PRINT(IO'BUFFER,-LEN,CCTL)                                   02994000
      ELSE FWRITE(LIST'FNUM,IO'BUFFER,-LEN,0);                          02996000
   IF <> THEN                                                           02998000
      BEGIN                                                             03000000
      PRINT'MESSAGE(FWRITE'LIST'ERROR,LIST'FNUM);                       03002000
      EXIT'PROGRAM;                                                     03004000
      END;                                                              03006000
   IF FNUM'SPECIFIED THEN                                               03008000
      BEGIN                                                             03010000
      FCHECK(FNUM,ERROR'CODE);                                          03012000
      FERRMSG(ERROR'CODE,IO'BUFFER,LEN);                                03014000
      FWRITE(LIST'FNUM,IO'BUFFER,-LEN,0);                               03016000
      IF <> THEN                                                        03018000
         BEGIN                                                          03020000
         PRINT'MESSAGE(FWRITE'LIST'ERROR,LIST'FNUM);                    03022000
         EXIT'PROGRAM;                                                  03024000
         END;                                                           03026000
      END;                                                              03028000
   END                                                                  03030000
ELSE                                                                    03032000
   BEGIN   ! PRINT the message, and possibly do file stuff.             03034000
   IF MESSAGE'NUM = BANNER THEN                                         03036000
      MOVE IO'BUFFER'B(VUUFF'COL) := OFFICIAL'VUUFF;                    03038000
   PRINT(IO'BUFFER,-LEN,CCTL);                                          03040000
   IF <> THEN                                                           03042000
      TERMINATE;                                                        03044000
   IF FNUM'SPECIFIED THEN                                               03046000
      BEGIN                                                             03048000
      FCHECK(FNUM,ERROR'CODE);                                          03050000
      FERRMSG(ERROR'CODE,IO'BUFFER,LEN);                                03052000
      PRINT(IO'BUFFER,-LEN,0);                                          03054000
      IF <> THEN                                                        03056000
         TERMINATE;                                                     03058000
      END;                                                              03060000
   END;                                                                 03062000
END;                                                                    03064000
                                                                        03066000
$PAGE "DUPLICATE'FILE"                                                  03068000
LOGICAL PROCEDURE DUPLICATE'FILE;                                       03070000
                                                                        03072000
!-----------------------------------------------------------------------03074000
! If  the user wants to keep existing copies of his files (KEEPING'FILES03076000
! is  true)  then DUPLICATE'FILE will be called to determine if the file03078000
! already exists.  If so, then print an appropriate error message.      03080000
!                                                                       03082000
! Output variable:                                                      03084000
!    DUPLICATE'FILE - TRUE is a duplicate file exists, FALSE otherwise. 03086000
!-----------------------------------------------------------------------03088000
                                                                        03090000
BEGIN                                                                   03092000
INTEGER                                                                 03094000
   DUP'FNUM;                                                            03096000
                                                                        03098000
DUPLICATE'FILE := FALSE;                                                03100000
DUP'FNUM := FOPEN(FORMDES,1,%10502,,,,,,,,,,FLFILECODE);                03102000
IF DUP'FNUM <> 0 THEN                                                   03104000
   BEGIN       ! The FOPEN succeeded, a duplicate file exists.          03106000
   FCLOSE(DUP'FNUM,0,0);                                                03108000
   PRINT'MESSAGE(DUPLICATE'FILE'ERROR);                                 03110000
   DUPLICATE'FILE := TRUE;                                              03112000
   END;                                                                 03114000
END;                                                                    03116000
$PAGE "GET'YES'NO"                                                      03118000
LOGICAL PROCEDURE GET'YES'NO(MESSAGE'NUM);                              03120000
VALUE MESSAGE'NUM;                                                      03122000
INTEGER MESSAGE'NUM;                                                    03124000
                                                                        03126000
!-----------------------------------------------------------------------03128000
! This  procedure  prompts the user with the message number sent and ex-03130000
! pects a YES or NO response.                                           03132000
!                                                                       03134000
! Input variable:                                                       03136000
!    MESSAGE'NUM - The message number to print.                         03138000
!                                                                       03140000
! Output variable:                                                      03142000
!    GET'YES'NO  - TRUE if the user responded with YES, FALSE if NO.    03144000
!-----------------------------------------------------------------------03146000
                                                                        03148000
BEGIN                                                                   03150000
LOGICAL                                                                 03152000
  GOOD'ANSWER := FALSE;                                                 03154000
                                                                        03156000
DO BEGIN   ! Until a correct answer is given.                           03158000
   PRINT'MESSAGE(MESSAGE'NUM,,NOCRLF);                                  03160000
   LEN := FREAD(STDIN'FNUM,IO'BUFFER,-5);                               03162000
   IF LEN > 1 THEN                                                      03164000
      IF IO'BUFFER'B = "YES" OR IO'BUFFER'B = "yes" THEN                03166000
         BEGIN                                                          03168000
         GET'YES'NO := YES;                                             03170000
         GOOD'ANSWER := TRUE;                                           03172000
         END                                                            03174000
      ELSE IF IO'BUFFER'B = "NO" OR IO'BUFFER'B = "no" THEN             03176000
         BEGIN                                                          03178000
         GET'YES'NO := NO;                                              03180000
         GOOD'ANSWER := TRUE;                                           03182000
         END;                                                           03184000
   IF NOT GOOD'ANSWER THEN                                              03186000
      PRINT'MESSAGE(ANSWER'YES'NO);                                     03188000
   END                                                                  03190000
UNTIL GOOD'ANSWER;                                                      03192000
END;                                                                    03194000
$PAGE "EXIT'PROGRAM"                                                    03196000
PROCEDURE EXIT'PROGRAM;                                                 03198000
                                                                        03200000
!-----------------------------------------------------------------------03202000
! This  procedure is called in emergency situations in which there is no03204000
! hope for recovery.  It closes the LIST and tape file and terminates.  03206000
!-----------------------------------------------------------------------03208000
                                                                        03210000
BEGIN                                                                   03212000
FCLOSE(LIST'FNUM,1,0);                                                  03214000
IF < THEN                                                               03216000
   PRINT'MESSAGE(LIST'FCLOSE'ERROR,LIST'FNUM);                          03218000
FCLOSE(TAPE'FNUM,0,0);                                                  03220000
IF < THEN                                                               03222000
   PRINT'MESSAGE(TAPE'FCLOSE'ERROR,TAPE'FNUM);                          03224000
TERMINATE;                      ! End this madness once and for all.    03226000
END;                                                                    03228000
$PAGE "CONTROL"                                                         03230000
PROCEDURE CONTROL(FUNCTION,MSG'NUMBER);                                 03232000
VALUE FUNCTION,MSG'NUMBER;                                              03234000
INTEGER FUNCTION,MSG'NUMBER;                                            03236000
                                                                        03238000
!-----------------------------------------------------------------------03240000
! CONTROL  performs  FCONTROL  functions  against the tape drive.  If an03242000
! error occurs, then print the message sent and exit the program.       03244000
!                                                                       03246000
! Input variables:                                                      03248000
!    FUNCTION - The FCONTROL function to execute                        03250000
!    MSG'NUMBER - If an error occurs, print this message.               03252000
!-----------------------------------------------------------------------03254000
                                                                        03256000
BEGIN                                                                   03258000
FCONTROL(TAPE'FNUM,FUNCTION,DUMMY);                                     03260000
IF < THEN                                                               03262000
   BEGIN                                                                03264000
   PRINT'MESSAGE(MSG'NUMBER,TAPE'FNUM);                                 03266000
   EXIT'PROGRAM;                                                        03268000
   END;                                                                 03270000
END;                                                                    03272000
$PAGE "CHANGE'JIT"                                                      03274000
PROCEDURE CHANGE'JIT(GROUP,ACCOUNT);                                    03276000
ARRAY GROUP,ACCOUNT;                                                    03278000
                                                                        03280000
!-----------------------------------------------------------------------03282000
! Due  to  a  design  feature  of MPE, users cannot create files accross03284000
! account  boundries,  even  if  they  have  all the capabilities in the03286000
! world.  Therefore,  in order for RECOVER5 to close files with the save03288000
! option  in  all groups and accounts, it must kludge the JIT to reflect03290000
! the  current  file  being  saved.  Therefore, right before the file is03292000
! to be closed, we change the group logon and account name in the JIT to03294000
! be  that  of the current file being saved.  We them immediately change03296000
! it back to the original group logon and account.  During the time that03298000
! we are called from CLOSE'FILE, BREAK and CONTROL-Y will be disabled so03300000
! that  the  user  cannot get into trouble, ie. exiting the program with03302000
! his JIT set to another group and account.                             03304000
!                                                                       03306000
! Input global variable:                                                03308000
!    JIT'DST - The data segment number of our job information table, ob-03310000
!    tained from the PCB global area in SET'UP'SHOP.                    03312000
!                                                                       03314000
! Input variable:                                                       03316000
!    GROUP & ACCOUNT - Obviously, the group and account to place into   03318000
!    the JIT.                                                           03320000
!-----------------------------------------------------------------------03322000
                                                                        03324000
BEGIN                                                                   03326000
SUBROUTINE DEF'MOVETODSEG;                                              03328000
                                                                        03330000
MOVETODSEG(JIT'DST,JIT'ACCOUNT,@ACCOUNT,4);                             03332000
MOVETODSEG(JIT'DST,JIT'LOGON'GROUP,@GROUP,4);                           03334000
END;                                                                    03336000
$PAGE "CORRECTLABEL"                                                    03338000
LOGICAL PROCEDURE CORRECT'FILE'LABEL(LABEL'ADDRESS);                    03340000
VALUE LABEL'ADDRESS;                                                    03342000
DOUBLE LABEL'ADDRESS;                                                   03344000
                                                                        03346000
!-----------------------------------------------------------------------03348000
! CORRECT'FILE'LABEL changes the file label of the disc file just recov-03350000
! ered  back  to  the way it originally was.  We must patch back a whole03352000
! bunch of file label variables to their original state.  It first reads03354000
! the  old  file  label,  updates  the  new file label with the original03356000
! label's  data,  corrects  the  extent map  and writes the new improved03358000
! label back out.                                                       03360000
!                                                                       03362000
! Input variable:                                                       03364000
!    LABEL'ADDRESS - The LDEV and disc adress of the file's FLAB.       03366000
!-----------------------------------------------------------------------03368000
                                                                        03370000
BEGIN                                                                   03372000
INTEGER ARRAY                                                           03374000
   NEW'FLAB(0:127),                                                     03376000
   REPL'EXTENTS'I(0:63);                                                03378000
DOUBLE  ARRAY                                                           03380000
   REPL'EXTENTS  (*) = REPL'EXTENTS'I;                                  03382000
DOUBLE POINTER                                                          03384000
   NEW'EXTENTS;                                                         03386000
INTEGER                                                                 03388000
   LDEV,                                                                03390000
   P1 = LABEL'ADDRESS,                 ! LDEV and HODA                  03392000
   FISIR'RETURN,                                                        03394000
   OFFSET,                                                              03396000
   EXTENT'NUM;                                                          03398000
                                                                        03400000
FISIR'RETURN := GETSIR(FISIR);                                          03402000
LDEV := P1.(0:8);                                                       03404000
P1.(0:8) := 0;                                                          03406000
IF (FLABIO(LDEV,LABEL'ADDRESS,READ,NEW'FLAB) <> 0) THEN                 03408000
   BEGIN   ! Error reading the FLAB, report it and return.              03410000
   CORRECT'FILE'LABEL := FAILED;                                        03412000
   RELSIR(FISIR,FISIR'RETURN);                                          03414000
   RETURN;                                                              03416000
   END;                                                                 03418000
                                                                        03420000
MOVE NEW'FLAB(12) := FLAB(12),(15);    ! 12-26                          03422000
NEW'FLAB(28).(0:3) := 0;               ! Clear store/restore/load bits  03424000
MOVE NEW'FLAB(29):= FLAB(29),(3);      ! 29-31                          03426000
MOVE NEW'FLAB(36):= FLAB(36),(3);      ! 36-38                          03428000
MOVE NEW'FLAB(42):= FLAB(42),(2);      ! 42-43                          03430000
MOVE NEW'FLAB(108):= FLAB(108),(20);   ! 108-127                        03432000
                                                                        03434000
!-----------------------------------------------------------------------03436000
! Here  we  must check the old FLAB to see if it had any extents missing03438000
! the  middle.  If it did, then we create a replacement extent map using03440000
! the  extent  map  from  the  new  file and form it as the old FLAB was03442000
! formed,  inserting  missing  extents in the same place as the old FLAB03444000
! with  the  new  extent  addresses in place of the old ones. Below is a03446000
! diagram demonstrating possible extent map permutation.                03448000
!                                                                       03450000
!    Old original             New              Replacement              03452000
!    --------------      --------------      --------------             03454000
!    | Old EXT 1  |----->|  New EXT 1 |----->| Rep. EXT 1 |             03456000
!    |------------|      |------------|      |------------|             03458000
!    | 0 (missing)| |--->|  New EXT 2 |---|  | 0 (missing)|             03460000
!    |------------| |    |------------|   |  |------------|             03462000
!    | Old EXT 3  |-| |->|  New EXT 3 |-| |->| Rep. EXT 3 |             03464000
!    |------------|   |  |------------| |    |------------|             03466000
!    | 0 (missing)|   |  |     0      | |    | 0 (missing)|             03468000
!    |------------|   |  |------------| |    |------------|             03470000
!    | Old EXT 5  |---|  |     0      | |--->| Rep. EXT 5 |             03472000
!    |------------|      |------------|      |------------|             03474000
!    ~            ~      ~            ~      ~            ~             03476000
!                                                                       03478000
!-----------------------------------------------------------------------03480000
                                                                        03482000
EXTENT'NUM := OFFSET := 0;                                              03484000
MOVE REPL'EXTENTS'I:=( 64(0) );                                         03486000
@NEW'EXTENTS := @NEW'FLAB(FLEXTINDEX);                                  03488000
WHILE (EXTENT'NUM+OFFSET <= FLNUMEXTS) DO                               03490000
  BEGIN                                                                 03492000
  IF FLABDBL(DFLEXTINDEX+EXTENT'NUM+OFFSET) = 0D THEN                   03494000
     OFFSET := OFFSET +1                                                03496000
  ELSE                                                                  03498000
     BEGIN                                                              03500000
     REPL'EXTENTS(EXTENT'NUM+OFFSET) := NEW'EXTENTS(EXTENT'NUM);        03502000
     EXTENT'NUM := EXTENT'NUM +1;                                       03504000
     END;                                                               03506000
  END;                                                                  03508000
                                                                        03510000
MOVE NEW'FLAB(FLEXTINDEX) := REPL'EXTENTS'I,((FLNUMEXTS+1)*2);          03512000
                                                                        03514000
IF (FLABIO(LDEV,LABEL'ADDRESS,WRITE,NEW'FLAB) <> 0)                     03516000
   THEN CORRECT'FILE'LABEL := FAILED                                    03518000
   ELSE CORRECT'FILE'LABEL := GOOD;                                     03520000
RELSIR(FISIR,FISIR'RETURN);                                             03522000
END;                                                                    03524000
$PAGE "CLOSE'FILE"                                                      03526000
LOGICAL PROCEDURE CLOSE'FILE;                                           03528000
                                                                        03530000
!-----------------------------------------------------------------------03532000
! This  procedure closes the newly created file.  It checks on a variety03534000
! of possible error conditions. If the file already exists, and the user03536000
! does  not  want  to keep the old file, then purge the old file and re-03538000
! close  the  new.  We  disable BREAK and CONTROL-Y during the procedure03540000
! because  we  don't want the user exiting the program while his JIT re-03542000
! flects  another  user's  group and account.  We will turn them back on03544000
! when the JIT is changed back to the user's original group and account.03546000
!                                                                       03548000
! Input global variable:                                                03550000
!    DISC'FNUM - File number of the newly created file.                 03552000
!                                                                       03554000
! Output variable:                                                      03556000
!   CLOSE'FILE - FAILED if an error occured.                            03558000
!                GOOD  if everything went A-OK.                         03560000
!-----------------------------------------------------------------------03562000
                                                                        03564000
BEGIN                                                                   03566000
INTEGER                                                                 03568000
   OLD'FNUM,                                                            03570000
   ERROR'CODE;                                                          03572000
                                                                        03574000
CLOSE'FILE := GOOD;    ! Assume successful completion.                  03576000
FCONTROL(STDIN'FNUM,DISABLE'BREAK,DUMMY);                               03578000
XCONTRAP(0,DUMMY);                                                      03580000
CHANGE'JIT(FLGRPNAME,FLACCTNAME);                                       03582000
FCLOSE(DISC'FNUM,1,0); ! Attempt to close the file with the SAVE option.03584000
IF < THEN              ! Oh, Oh, the FCLOSE SAVE failed.                03586000
   BEGIN                                                                03588000
   FCHECK(DISC'FNUM,ERROR'CODE);                                        03590000
   IF ERROR'CODE=100 AND NOTKEEP THEN                                   03592000
      BEGIN            ! OK, purge the old file, save the new.          03594000
      OLD'FNUM := FOPEN(FORMDES,1,%10502,,,,,,,,,,FLFILECODE);          03596000
      IF < THEN        ! Damn, FOPEN of old for purge failed.           03598000
         BEGIN         ! Let the user know about the failure.           03600000
         PRINT'MESSAGE(FOPEN'EXISTING'FILE'ERROR,OLD'FNUM);             03602000
         FCLOSE(DISC'FNUM,0,0);     ! New file gone!                    03604000
         CLOSE'FILE := FAILED;      ! Report error.                     03606000
         END                                                            03608000
      ELSE             ! Old file FOPENed, now FCLOSE w/ purge.         03610000
         BEGIN                                                          03612000
         FCLOSE(OLD'FNUM,4,0);                                          03614000
         IF = THEN                                                      03616000
            BEGIN      ! File purged OK, close new file SAVE.           03618000
            FCLOSE(DISC'FNUM,1,0);                                      03620000
            IF < THEN                                                   03622000
               BEGIN   ! This should never, ever happen.                03624000
               PRINT'MESSAGE(FCLOSE'ERROR,DISC'FNUM);                   03626000
               CLOSE'FILE := FAILED;                                    03628000
               END;                                                     03630000
            END                                                         03632000
         ELSE                                                           03634000
            BEGIN      ! Error purging the existing file.               03636000
            PRINT'MESSAGE(PURGE'ERROR,DISC'FNUM);                       03638000
            FCLOSE(DISC'FNUM,0,0);  ! New file is gone, deleted kapoot. 03640000
            FCLOSE(OLD'FNUM,0,0);   ! Try closing it with default DISP. 03642000
            CLOSE'FILE := FAILED;   ! Report error.                     03644000
            END;                                                        03646000
         END;                                                           03648000
      END                                                               03650000
   ELSE                                                                 03652000
     BEGIN         ! Other FCLOSE failure, alert user.                  03654000
     PRINT'MESSAGE(FCLOSE'ERROR,DISC'FNUM);                             03656000
     FCLOSE(DISC'FNUM,0,0);         ! Close new file, GONE!             03658000
     CLOSE'FILE := FAILED;          ! Report error.                     03660000
     END;                                                               03662000
   END;                                                                 03664000
CHANGE'JIT(LOGON'GROUP,LOGON'ACCOUNT);                                  03666000
FCONTROL(STDIN'FNUM,ENABLE'BREAK,DUMMY);                                03668000
XCONTRAP(@CONTROLY,DUMMY);                                              03670000
END;                                ! CLOSE'FILE procedure.             03672000
$PAGE "PROCESS'FILE'EOF"                                                03674000
PROCEDURE PROCESS'FILE'EOF;                                             03676000
                                                                        03678000
!-----------------------------------------------------------------------03680000
! This procedure does the necessary processing to save a disc file after03682000
! it  has  been read in. It closes the new disc file for SAVE via CLOSE'03684000
! 'FILE.  If that is successfull, it corrects the file label of the file03686000
! to reflect the correct information.                                   03688000
!-----------------------------------------------------------------------03690000
                                                                        03692000
BEGIN                                                                   03694000
DOUBLE                                                                  03696000
   LABEL'ADDRESS;             ! Disk address of the FLAB.               03698000
                                                                        03700000
FFILEINFO(DISC'FNUM,19,LABEL'ADDRESS);                                  03702000
IF <> OR LABEL'ADDRESS = 0D THEN                                        03704000
   PRINT'MESSAGE(FFILEINFO'ERROR,DISC'FNUM)                             03706000
ELSE IF CLOSE'FILE THEN                                                 03708000
   BEGIN                      ! The FCLOSE was successful.              03710000
   IF CORRECT'FILE'LABEL(LABEL'ADDRESS)                                 03712000
      THEN PRINT'MESSAGE(SUCCESSFUL'RECOVERY)                           03714000
      ELSE PRINT'MESSAGE(FLAB'IO'ERROR);                                03716000
   END;                                                                 03718000
END;                                                                    03720000
$PAGE "READ'FILE'FROM'TAPE - Declaration and SUBROUTINE ERROR"          03722000
PROCEDURE READ'FILE'FROM'TAPE(RECORD'LEN,TAPE'PNTR);                    03724000
VALUE RECORD'LEN,TAPE'PNTR;                                             03726000
INTEGER RECORD'LEN;                                                     03728000
INTEGER POINTER TAPE'PNTR;                                              03730000
!-----------------------------------------------------------------------03732000
! This  procedure reads records from tape and writes to the current file03734000
! until  EOF  is encountered on the tape.  It is called from RECOVER'ALL03736000
! FILES  in  two  cases.  The first is to simply read in the user labels03738000
! and  data  from  a  normal file on tape.  The second is to continue to03740000
! read in a "continuation" file, ie. only data will be present.         03742000
!                                                                       03744000
! Input variable:                                                       03746000
!    RECORD'LEN - If  this  is  a  continuation file, than this variable03748000
!    will  have  the  value  0 because the indication for a continuation03750000
!    file  is  a  12 word record with the file, group & account.  With a03752000
!    a  normal file, this variable will have the value of the first tape03754000
!    record  (usually 4096 words, unless we have a very small file) less03756000
!    128 words for the FLAB.                                            03758000
!                                                                       03760000
!    TAPE'PNTR - Pointer to the area in the tape buffer to start to use.03762000
!    If  RECORD'LEN <> 0 then this will have the value of @TAPE'BUFFER +03764000
!    128 (since we skip over the FLAB).                                 03766000
!                                                                       03768000
! Output global variable:                                               03770000
!    CONTINUATION - Sets this to TRUE if it encounters a file that spans03772000
!    more than one reels of tape.                                       03774000
!-----------------------------------------------------------------------03776000
                                                                        03778000
BEGIN                                                                   03780000
LOGICAL                                                                 03782000
   DONE := FALSE;                                                       03784000
BYTE POINTER                                                            03786000
   TAPE'PNTR'B;                                                         03788000
                                                                        03790000
SUBROUTINE ERROR(MSG'NUMBER);                                           03792000
VALUE MSG'NUMBER;                                                       03794000
INTEGER MSG'NUMBER;                                                     03796000
                                                                        03798000
!-----------------------------------------------------------------------03800000
! This  subroutine is called if an error is encountered while writing to03802000
! the  disc file.  It prints an error message and skips to the next file03804000
! on  the  tape.  It then performs the final processing of the file like03806000
! an  EOF has been reached to salvage what we can.  This is done via the03808000
! procedure PROCESS'FILE'EOF.                                           03810000
!-----------------------------------------------------------------------03812000
                                                                        03814000
BEGIN                                                                   03816000
PRINT'MESSAGE(MSG'NUMBER,DISC'FNUM);                                    03818000
CONTROL(FORWARD'SPACE'FILE,TAPE'FSF'ERROR);                             03820000
PROCESS'FILE'EOF;                                                       03822000
ASSEMBLE(EXIT 0);                                                       03824000
END;                                                                    03826000
$PAGE "READ'FILE'FROM'TAPE - Outer block "                              03828000
DO BEGIN      ! Until we hit then end of the tape or an error occurs.   03830000
   IF RECORD'LEN > 0 THEN                                               03832000
      BEGIN   ! Normal processing, lets do it.                          03834000
      IF SECT'OFFSET'DATA > 0 THEN                                      03836000
         BEGIN                  ! Need to write ULABS?                  03838000
         WHILE SECT'OFFSET'DATA > 0 AND RECORD'LEN > 0 DO               03840000
            BEGIN               ! Possible write ULABS.                 03842000
            IF NUM'ULABS > 0 THEN                                       03844000
               BEGIN            ! Definetely have ULABS.                03846000
               FWRITELABEL(DISC'FNUM,TAPE'PNTR,128,FLLBL-NUM'ULABS);    03848000
               IF < THEN ERROR(ULAB'WRITE'ERROR);                       03850000
               IF > THEN ERROR(TOO'MANY'ULABS);                         03852000
               NUM'ULABS := NUM'ULABS - 1;                              03854000
               END;                                                     03856000
            SECT'OFFSET'DATA := SECT'OFFSET'DATA - 1;                   03858000
            @TAPE'PNTR := @TAPE'PNTR + 128;                             03860000
            RECORD'LEN := RECORD'LEN - 128;                             03862000
            END;   ! of WHILE loop.                                     03864000
         END;   ! of IF clause.                                         03866000
                                                                        03868000
      IF RECORD'LEN > 0 THEN                                            03870000
         BEGIN  ! Write the rest of the buffer MR, NOBUF in one shot    03872000
         FWRITE(DISC'FNUM,TAPE'PNTR,RECORD'LEN,0);                      03874000
         IF < THEN ERROR(DATA'WRITE'ERROR);                             03876000
         IF > THEN ERROR(TOO'MANY'DATA'RECORDS);                        03878000
         END;                                                           03880000
      END;   ! of normal processing IF clause.                          03882000
                                                                        03884000
   ! Now read the next block from tape into the buffer and continue.    03886000
                                                                        03888000
   CONTINUATION := FALSE;                                               03890000
   @TAPE'PNTR := @TAPE'BUFFER;                                          03892000
   @TAPE'PNTR'B := @TAPE'PNTR * 2;                                      03894000
   RECORD'LEN := FREAD(TAPE'FNUM,TAPE'PNTR,TAPE'REC'SIZE);              03896000
   IF > THEN                                                            03898000
      BEGIN   ! EOF encountered, process it and leave.                  03900000
      PROCESS'FILE'EOF;                                                 03902000
      DONE := TRUE;                                                     03904000
      END                                                               03906000
   ELSE IF < THEN                                                       03908000
      BEGIN   ! Tape read error, attempt to skip bad file.              03910000
      PRINT'MESSAGE(TAPE'DATA'READ'ERROR,TAPE'FNUM);                    03912000
      CONTROL(FORWARD'SPACE'FILE,TAPE'FSF'ERROR);                       03914000
      DONE := TRUE;             ! Done with this file.                  03916000
      END                                                               03918000
   ELSE IF RECORD'LEN = 4 AND TAPE'PNTR'B = CONTINUATION'RECORD THEN    03920000
      BEGIN   ! Continuation file, will ask for next tape.              03922000
      CONTINUATION := TRUE;     ! Set global flag.                      03924000
      DONE := TRUE;                                                     03926000
      PRINT'MESSAGE(FILE'CONTINUATION);                                 03928000
      END;                                                              03930000
   END  ! of DO loop.                                                   03932000
UNTIL DONE;                                                             03934000
END; ! of READ'FILE'FROM'TAPE.                                          03936000
$PAGE "FOPEN'FILE"                                                      03938000
LOGICAL PROCEDURE FOPEN'FILE;                                           03940000
                                                                        03942000
!-----------------------------------------------------------------------03944000
! This  procedure  performs the FOPEN of the disc file based on the info03946000
! found  in  the  FLAB  just  read  from tape.  We FOPEN the file with a03948000
! record  size  of 128 words and a blocking factor of the number of sec-03950000
! tors  per  block.  The  special entry point ROPEN has been implemented03952000
! for RECOVER5 to patch the block size to 1 sector and the blocking fac-03954000
! tor  to 1 so that we can write to the file unbuffered, multi-record in03956000
! increments of one sector.  When we write to the file, we will "stream"03958000
! the  file, which means that the file system will perform the entire 4K03960000
! transfer  in as little as a single I/O, depending on extent boundries.03962000
! This will greatly increase the performance of RECOVER5.               03964000
!                                                                       03966000
! Output global variables:                                              03968000
!                                                                       03970000
!    SECT'OFFSET'DATA - Number of sectors from FLAB to file's data      03972000
!    NUM'ULABS        - The number of user labels to be written         03974000
!-----------------------------------------------------------------------03976000
                                                                        03978000
BEGIN                                                                   03980000
INTEGER                                                                 03982000
   SECTORS'PER'BLOCK;                                                   03984000
DOUBLE                                                                  03986000
   NUM'DATA'SECTORS;                  ! Number of data sectors in file. 03988000
                                                                        03990000
FOPEN'FILE := FAILED;                 ! Assume failure.                 03992000
SECTORS'PER'BLOCK := (FLBLKSIZE+127)/128;                               03994000
NUM'ULABS := FLLBL;                                                     03996000
NUM'DATA'SECTORS := (DBL(FLNUMEXTS) * DBL(FLEXTSIZE)) +                 03998000
                    DBL(FLLASTEXTSIZE) - DBL(FLSECTOFF);                04000000
SECT'OFFSET'DATA  := FLSECTOFF - 1;   ! Less one for FLAB.              04002000
                                                                        04004000
DISC'FNUM := ROPEN(FORMDES,%2000,%421,,,,NUM'ULABS,SECTORS'PER'BLOCK,,  04006000
              NUM'DATA'SECTORS,FLNUMEXTS+1,,FLFILECODE);                04008000
IF <                                                                    04010000
   THEN PRINT'MESSAGE(DISC'FOPEN'ERROR,DISC'FNUM)                       04012000
   ELSE FOPEN'FILE := GOOD;                                             04014000
END;                                                                    04016000
$PAGE "RECOVER'FILE"                                                    04018000
LOGICAL PROCEDURE RECOVER'FILE;                                         04020000
                                                                        04022000
!-----------------------------------------------------------------------04024000
! This  procedure  determines  if  a file is to be recovered or not.  It04026000
! checks  out  all the file lists to see if the current file being exam-04028000
! ined on tape matches the list of files supplied by the user.  Finally,04030000
! if  the KEEP option has been specified, it determines if a file of the04032000
! same name already exists.  If all the files specified have been found,04034000
! then we exit the program.                                             04036000
!                                                                       04038000
! Output variables:                                                     04040000
!    RECOVER'FILE - If all criteria is met, then TRUE else FALSE.       04042000
!-----------------------------------------------------------------------04044000
                                                                        04046000
BEGIN                                                                   04048000
RECOVER'FILE := FALSE;    ! Assume that the file is not to be recovered.04050000
IF NOT GOT'WILD AND NUM'STRICT = 0 AND KEEP'SOME THEN                   04052000
   EXIT'PROGRAM;          ! All specified files recovered, no wild cards04054000
                                                                        04056000
IF KEEP'SOME AND NOT MATCHES'LIST THEN                                  04058000
   RETURN;                                                              04060000
                                                                        04062000
NUM'STRICT := NUM'STRICT - 1;                                           04064000
                                                                        04066000
IF KEEPING'FILES AND DUPLICATE'FILE THEN                                04068000
   RETURN;                ! A duplicate file exists.                    04070000
                                                                        04072000
RECOVER'FILE := TRUE;     ! All criteria is met, recover that file.     04074000
END;                                                                    04076000
$PAGE "ANOTHER'TAPE"                                                    04078000
PROCEDURE ANOTHER'TAPE(MESSAGE'NUM);                                    04080000
VALUE MESSAGE'NUM;                                                      04082000
INTEGER MESSAGE'NUM;                                                    04084000
                                                                        04086000
!-----------------------------------------------------------------------04088000
! This  procedure  outputs a message to the user and them prompts him to04090000
! determine  if another tape is available.  It is called when the end of04092000
! a  reel  has been it or if the user mounts the wrong tape when contin-04094000
! uing.  If  the user ever signifies that another tape is not available,04096000
! we will exit the program.                                             04098000
!                                                                       04100000
! Input variable:                                                       04102000
!    MESSAGE'NUM - The message number to print before the prompt.       04104000
!-----------------------------------------------------------------------04106000
                                                                        04108000
BEGIN                                                                   04110000
LOGICAL                                                                 04112000
  ANSWER;      ! Yes or no?                                             04114000
                                                                        04116000
CONTROL(REWIND'UNLOAD,TAPE'REWIND'UNLOAD'ERROR);                        04118000
                                                                        04120000
ANSWER := GET'YES'NO(MESSAGE'NUM);                                      04122000
IF ANSWER = NO                                                          04124000
   THEN EXIT'PROGRAM                                                    04126000
   ELSE PRINT'MESSAGE(MOUNT'NEW'TAPE);                                  04128000
END;                                                                    04130000
$PAGE "TAPE'ERROR'RECOVERY"                                             04132000
PROCEDURE TAPE'ERROR'RECOVERY(NUM'TAPE'ERRORS);                         04134000
INTEGER NUM'TAPE'ERRORS;                                                04136000
                                                                        04138000
!-----------------------------------------------------------------------04140000
! This  procedure  attempts  to  recover from an error while reading the04142000
! file  label  block from tape.  It outputs a message and checks a coun-04144000
! ter. If 5 read errors have occured in a row, then we exit the program.04146000
! If the forward space file fails, we also exit the program.            04148000
!                                                                       04150000
! Input variables:                                                      04152000
!    NUM'TAPE'ERRORS - An  integer by reference containing the number of04154000
!    consecutive read errors encountered.  Again, if the magic number of04156000
!    5 it hit, then rip this joint.                                     04158000
!-----------------------------------------------------------------------04160000
                                                                        04162000
BEGIN                                                                   04164000
PRINT'MESSAGE(TAPE'READ'ERROR,TAPE'FNUM);                               04166000
NUM'TAPE'ERRORS := NUM'TAPE'ERRORS + 1;                                 04168000
IF NUM'TAPE'ERRORS > 4 THEN                                             04170000
   BEGIN                                                                04172000
   PRINT'MESSAGE(CATASTROPHIC'TAPE'ERROR);                              04174000
   EXIT'PROGRAM;                                                        04176000
   END                                                                  04178000
ELSE                                                                    04180000
   CONTROL(FORWARD'SPACE'FILE,TAPE'FSF'ERROR);                          04182000
END;                                                                    04184000
$PAGE "GET'FILE'LIST"                                                   04186000
PROCEDURE GET'FILE'LIST;                                                04188000
                                                                        04190000
!-----------------------------------------------------------------------04192000
! This procedure prompts the user for a list of the file sets to attempt04194000
! to  recover.  It  then  asks  the user if he wants to to keep existing04196000
! copies of the files.                                                  04198000
!                                                                       04200000
! Output global variable:                                               04202000
!    NOTKEEP - True if the user does not want to keep existing copies.  04204000
!-----------------------------------------------------------------------04206000
                                                                        04208000
BEGIN                                                                   04210000
LOGICAL                                                                 04212000
   ANSWER,                   ! TRUE = YES, FALSE = NO.                  04214000
   DONE := TRUE;                                                        04216000
                                                                        04218000
DO BEGIN   ! Until the user gives a legal list of files.                04220000
   PRINT'MESSAGE(ENTER'FILESET);                                        04222000
   PRINT'MESSAGE(TERMINATE'LIST);                                       04224000
   PRINT'MESSAGE(PROMPT,,NOCRLF);                                       04226000
   LEN := FREAD(STDIN'FNUM,IO'BUFFER,-80);                              04228000
   MOVE IO'BUFFER'B(LEN) := CR;                                         04230000
   SCAN IO'BUFFER'B WHILE "  ",1;                                       04232000
   @START := TOS;                                                       04234000
   IF START = CR OR START = "@.@.@" THEN                                04236000
      DONE := TRUE                                                      04238000
   ELSE                                                                 04240000
      BEGIN                                ! Get a real list.           04242000
      MOVE LIST'PT := IO'BUFFER'B,(LEN),2; ! Copy input list.           04244000
      MOVE * := " ",2;                     ! Blank the end of the list. 04246000
      @LIST'PT := TOS - 1;                 ! Points to end of list.     04248000
      @END'OF'LIST := @LIST'PT;                                         04250000
      DO BEGIN                                                          04252000
         PRINT'MESSAGE(PROMPT,,NOCRLF);                                 04254000
         LEN := FREAD(STDIN'FNUM,IO'BUFFER,-80);                        04256000
         MOVE IO'BUFFER'B(LEN) := CR;                                   04258000
         SCAN IO'BUFFER'B WHILE "  ",1;                                 04260000
         @START := TOS;                                                 04262000
         IF START = CR THEN LEN := 0;                                   04264000
         IF @LIST'PT <> @FILE'LIST THEN                                 04266000
            MOVE LIST'PT := ",";                                        04268000
         MOVE LIST'PT(1) := IO'BUFFER'B,(LEN),2;                        04270000
         @LIST'PT := TOS ;                                              04272000
         END                                                            04274000
      UNTIL LEN = 0;                                                    04276000
      @END'OF'LIST := @LIST'PT(-1);                                     04278000
      END'OF'LIST := %0;           ! Null EOL                           04280000
      PRINT'MESSAGE(BLANK'LINE);                                        04282000
                                                                        04284000
      IF NOT CHECK'LIST THEN                                            04286000
         DONE := FALSE                                                  04288000
      ELSE                                                              04290000
         BEGIN                                                          04292000
         KEEP'SOME := TRUE;                                             04294000
         DONE := TRUE;                                                  04296000
         END;                                                           04298000
      END;  ! of blank line or @.@.@ was entered.                       04300000
   END   ! of UNTIL DONE.                                               04302000
UNTIL DONE;                                                             04304000
                                                                        04306000
! Now prompt the user to see if he wants to keep existing files.        04308000
                                                                        04310000
ANSWER := GET'YES'NO(KEEP'FILES);                                       04312000
IF ANSWER = NO                                                          04314000
   THEN NOTKEEP := TRUE                                                 04316000
   ELSE NOTKEEP := FALSE;                                               04318000
END;                                                                    04320000
$PAGE "SET'UP'SHOP"                                                     04322000
PROCEDURE SET'UP'SHOP;                                                  04324000
                                                                        04326000
!-----------------------------------------------------------------------04328000
! This  procedure  does  some  initialization  needed to set up the work04330000
! environment.  It  prints  the  banner, checks if we are running on the04332000
! correct  system  and opens the list files. It then obtains the list of04334000
! file  sets   to recover.  Finally, it opens the mag tape file, fetches04336000
! the JIT DST from the PXGLOBAL area and arms the CONTROL-Y trap.       04338000
!-----------------------------------------------------------------------04340000
                                                                        04342000
BEGIN                                                                   04344000
INTEGER POINTER                                                         04346000
   PCB = 3;                  ! Sysglobal relative pointer to the PCB.   04348000
INTEGER                                                                 04350000
   PCBGLOBLOC;               ! Q relative offset to PCBX global area.   04352000
DOUBLE                                                                  04354000
   CAPABILITIES;             ! User capability mask.                    04356000
LOGICAL                                                                 04358000
   MODE,                     ! Users mode, interactive or duplicative.  04360000
   CAPABILITIES1 = CAPABILITIES;                                        04362000
DEFINE                                                                  04364000
   PCB'SIZE            = PCB(1)#,                                       04366000
   MPEV'PCB'SIZE       = %25#,                                          04368000
   MODE'INTERACTIVE    = MODE.(15:1)#,                                  04370000
   SYSTEM'MANAGER'CAP  = CAPABILITIES1.(0:1)#;                          04372000
                                                                        04374000
PRINT'MESSAGE(BANNER);                                                  04376000
IF PCB'SIZE <> MPEV'PCB'SIZE THEN                                       04378000
   BEGIN   ! Not the correct version of MPE, rip this joint.            04380000
   PRINT'MESSAGE(INVALID'MPE'VERSION);                                  04382000
   TERMINATE;                                                           04384000
   END;                                                                 04386000
                                                                        04388000
LIST'FNUM := FOPEN(LIST'NAME,%14,1);                                    04390000
IF <> THEN                                                              04392000
   BEGIN   ! List file open failed, split city.                         04394000
   PRINT'MESSAGE(LISTFILE'FOPEN'ERROR,LIST'FNUM);                       04396000
   TERMINATE;                                                           04398000
   END;                                                                 04400000
                                                                        04402000
STDIN'FNUM := FOPEN(,%41,0);                                            04404000
IF < THEN                                                               04406000
   BEGIN   ! Stdin file open failed, split city.                        04408000
   PRINT'MESSAGE(STDIN'FOPEN'ERROR,STDIN'FNUM);                         04410000
   TERMINATE;                                                           04412000
   END;                                                                 04414000
                                                                        04416000
! Obtain the original group and account, mode and capabilties.          04418000
                                                                        04420000
WHO(MODE,CAPABILITIES,,,LOGON'GROUP,LOGON'ACCOUNT);                     04422000
IF NOT SYSTEM'MANAGER'CAP THEN                                          04424000
   BEGIN   ! User does not have system manager capability, kill him.    04426000
   PRINT'MESSAGE(USER'LACKS'SM'CAP);                                    04428000
   TERMINATE;                                                           04430000
   END;                                                                 04432000
                                                                        04434000
! Get the list of file sets to recover and open tape file.              04436000
                                                                        04438000
IF MODE'INTERACTIVE THEN                                                04440000
   GET'FILE'LIST;                                                       04442000
                                                                        04444000
PRINT'MESSAGE(OPEN'TAPE'FILE);                                          04446000
TAPE'FNUM := FOPEN(TAPE'NAME,%200,%400,TAPE'REC'SIZE,DEFAULT'DEVICE);   04448000
IF < THEN                                                               04450000
   BEGIN                                                                04452000
   PRINT'MESSAGE(TAPE'FOPEN'ERROR,TAPE'FNUM);                           04454000
   TERMINATE;                                                           04456000
   END;                                                                 04458000
                                                                        04460000
PXGLOBAL;                   ! Set PCBGLOBLOC for PXGLOBAL defines.      04462000
JIT'DST := PXG'JITDST;      ! Save JIT'DST for kludge.                  04464000
                                                                        04466000
XCONTRAP(@CONTROLY,DUMMY);  ! Enable the CONTROL-Y trap procedure.      04468000
END;                                                                    04470000
$PAGE "CHECK'CONTROLY"                                                  04472000
PROCEDURE CHECK'CONTROLY;                                               04474000
                                                                        04476000
!-----------------------------------------------------------------------04478000
! This  procedure  checks  to  see if CONTROL-Y has been hit.  If so, it04480000
! promts  the user to determine if he wants to continue or not.  If not,04482000
! we exit the program.                                                  04484000
!                                                                       04486000
! Global input variable:                                                04488000
!    CONTROL'Y'DETECTED - Set to TRUE when CONTROLY trap is entered.    04490000
!-----------------------------------------------------------------------04492000
                                                                        04494000
BEGIN                                                                   04496000
LOGICAL                                                                 04498000
   ANSWER;                                                              04500000
                                                                        04502000
IF CONTROL'Y'DETECTED THEN                                              04504000
   BEGIN                                                                04506000
   ANSWER := GET'YES'NO(CONTROL'Y'CONTINUE);                            04508000
   IF ANSWER = NO THEN                                                  04510000
      EXIT'PROGRAM;                                                     04512000
   END;                                                                 04514000
CONTROL'Y'DETECTED := FALSE;                                            04516000
END;                                                                    04518000
$PAGE "PARSE'FORMAL'DESIGNATOR"                                         04520000
PROCEDURE PARSE'FORMAL'DESIGNATOR(FLAB);                                04522000
INTEGER ARRAY FLAB;                                                     04524000
                                                                        04526000
!-----------------------------------------------------------------------04528000
! This procedure will parse the file label name into a formal designator04530000
! used  by FOPEN  and a  file name used by the message procedure.  It is04532000
! important  that  the  delimiter of FORMDES  is  a  blank   because the04534000
! procedure DISPLAY'TO'STANDARD expects it that way.                    04536000
!                                                                       04538000
! Input variable:                                                       04540000
!    FLAB - An array containing the file label.                         04542000
!                                                                       04544000
! Output global variables:                                              04546000
!    FILE'NAME - In the form FILE.GROUP.ACCOUNT for message procedure   04548000
!    FORMDES   - In the form FILE/LOCK.GROUP.ACCOUNT for FOPEN          04550000
!-----------------------------------------------------------------------04552000
                                                                        04554000
BEGIN                                                                   04556000
BYTE ARRAY TEMP(0:35);                                                  04558000
                                                                        04560000
MOVE FILE'NAME := (26 (" "));                                           04562000
                                                                        04564000
MOVE FILE'NAME     := FLAB'B    ,(8);   ! File name                     04566000
MOVE FILE'NAME(8)  := ".";                                              04568000
MOVE FILE'NAME(9)  := FLAB'B(8) ,(8);   ! Group name                    04570000
MOVE FILE'NAME(17) := ".";                                              04572000
MOVE FILE'NAME(18) := FLAB'B(16),(8);   ! Account name                  04574000
                                                                        04576000
MOVE TEMP    := (36 (" "));                                             04578000
MOVE FORMDES := (36 (" "));                                             04580000
                                                                        04582000
MOVE TEMP     := FLAB'B    ,(8);        ! File name                     04584000
MOVE TEMP(9)  := FLAB'B(8) ,(8);        ! Group name                    04586000
MOVE TEMP(18) := FLAB'B(16),(8);        ! Account name                  04588000
MOVE TEMP(27) := FLAB'B(32),(8);        ! Lock word                     04590000
                                                                        04592000
                                                                        04594000
MOVE FORMDES := TEMP WHILE AN,1;        ! File name                     04596000
IF TEMP(27) <> " " THEN                                                 04598000
   BEGIN                                ! A lock word exists            04600000
   MOVE * := "/",2;                                                     04602000
   MOVE * := TEMP(27) WHILE AN,1;       ! Move it in                    04604000
   END;                                                                 04606000
MOVE * := ".",2;                                                        04608000
MOVE * := TEMP(9)  WHILE AN,1;          ! Group name                    04610000
MOVE * := ".",2;                                                        04612000
MOVE * := TEMP(18) WHILE AN,1;          ! Account name                  04614000
MOVE * := " ";                          ! Delimiter                     04616000
END;                                                                    04618000
$PAGE "RECOVER'ALL'FILES"                                               04620000
PROCEDURE RECOVER'ALL'FILES;                                            04622000
                                                                        04624000
!-----------------------------------------------------------------------04626000
! This  procedure  controls  all  the  file recovery.  It reads the file04628000
! label  block, determines what needs to be done, ie. continuation file,04630000
! normal recovery or skip the current file.                             04632000
!                                                                       04634000
! Global input variable:                                                04636000
!    CONTINUATION - Set by READ'FILE'FROM'TAPE if a file spans more than04638000
!    one reel of tape.                                                  04640000
!-----------------------------------------------------------------------04642000
                                                                        04644000
BEGIN                                                                   04646000
LOGICAL                                                                 04648000
   SKIP'FILE;        ! Set to true if we have to skip over current file.04650000
INTEGER                                                                 04652000
   RECORD'LEN,       ! Length of first record read.                     04654000
   NUM'READ'ERRORS;  ! If numerous read errors encountered, then quit.  04656000
INTEGER POINTER                                                         04658000
   TAPE'PNTR;        ! Current location of tape pointer in buffer.      04660000
BYTE POINTER                                                            04662000
   TAPE'PNTR'B;                                                         04664000
                                                                        04666000
DO BEGIN             ! Until all the requested files are found.         04668000
   CHECK'CONTROLY;   ! If user wants to quit, we may never return.      04670000
   SKIP'FILE := FALSE;                                                  04672000
   @TAPE'PNTR := @TAPE'BUFFER;                                          04674000
   @TAPE'PNTR'B := @TAPE'PNTR * 2;                                      04676000
   RECORD'LEN := FREAD(TAPE'FNUM,TAPE'PNTR,TAPE'REC'SIZE);              04678000
   IF < THEN                                                            04680000
      TAPE'ERROR'RECOVERY(NUM'READ'ERRORS)                              04682000
   ELSE IF > THEN                                                       04684000
      BEGIN                  ! Ask the user for another tape, if none is04686000
      IF CONTINUATION        ! available, then we will not return.      04688000
         THEN ANOTHER'TAPE(ASK'CONTINUATION'TAPE)                       04690000
         ELSE ANOTHER'TAPE(ASK'ANOTHER'TAPE);                           04692000
      END                                                               04694000
   ELSE                                                                 04696000
      BEGIN                  ! Successful read of 1st. block, what's up?04698000
      NUM'READ'ERRORS := 0;  ! Reset the error counter.                 04700000
      IF CONTINUATION THEN                                              04702000
         BEGIN               ! This is a continution file, read rest.   04704000
         IF RECORD'LEN = CONT'SIZE AND TAPE'PNTR'B = FLAB'B,(24) THEN   04706000
            BEGIN            ! The correct tape was mounted, read it.   04708000
            RECORD'LEN := 0;                                            04710000
            READ'FILE'FROM'TAPE(RECORD'LEN,TAPE'PNTR);                  04712000
            END                                                         04714000
         ELSE                                                           04716000
            BEGIN            ! Wrong continuation tape has been mounted.04718000
            PRINT'MESSAGE(TAPE'CONTINUATION'ERROR);                     04720000
            ANOTHER'TAPE(ASK'CONTINUATION'TAPE);                        04722000
            END;                                                        04724000
         END                                                            04726000
      ELSE IF RECORD'LEN = CONT'SIZE THEN                               04728000
         SKIP'FILE := TRUE   ! Continuation file, skip over it.         04730000
      ELSE                                                              04732000
         BEGIN               ! A normal file, do the needed processing. 04734000
         MOVE FLAB := TAPE'PNTR,(128);       ! Important, save the FLAB.04736000
         PARSE'FORMAL'DESIGNATOR(FLAB);                                 04738000
         DISPLAY'TO'STANDARD(FORMDES'PTR,FORMDES'STD'PTR,ERROR,         04740000
                                                          CHAR'INX);    04742000
         IF NOT RECOVER'FILE OR NOT FOPEN'FILE THEN                     04744000
            SKIP'FILE := TRUE                                           04746000
         ELSE                                                           04748000
            BEGIN            ! We want it and it opened without error.  04750000
            RECORD'LEN := RECORD'LEN - 128;  ! Compensate for FLAB.     04752000
            @TAPE'PNTR := @TAPE'PNTR + 128;                             04754000
            READ'FILE'FROM'TAPE(RECORD'LEN,TAPE'PNTR);                  04756000
            END;                                                        04758000
         END;                                                           04760000
                                                                        04762000
      IF SKIP'FILE THEN                                                 04764000
         CONTROL(FORWARD'SPACE'FILE,TAPE'FSF'ERROR);                    04766000
      END;   ! of successful read of file label block.                  04768000
   END   ! of DO forever.                                               04770000
UNTIL FALSE;                                                            04772000
END;                                                                    04774000
$PAGE "Outer block"                                                     04776000
SET'UP'SHOP;                                                            04778000
RECOVER'ALL'FILES;                                                      04780000
END.                                                                    04782000
