.PROC,GETLIB*I,
R "- Record name (or ALL or *)"        = (ALL=$*$,$*$,*F),
L "- Library file name"                = (*N=#FILE,*F),
UN "- User Name of library file"       = (*N=,*F),
G "- Group file receiving record(s)"   = (*N=,*F),
T "- Type of record(s) being extracted"= (*N=,ABS,CAP,OPL,OPLC,OPLD,OVL,
                                               PP,PPU,PROC,REL,TEXT,ULIB),
E "- Exclude record(s) of this type"   = (*N=,ABS,CAP,OPL,OPLC,OPLD,OVL,
                                               PP,PPU,PROC,REL,TEXT,ULIB),
.
.HELP
 The GETLIB procedure GETs records from a LIBrary file by their type.

 Parameter   Default   Description
   Name       Value

   r                   record name to extract (or ALL or *)
  [l]                  library file containing the record(s)
  [un]                 user name in which library resides
  [g]                  local file to which record(s) are written
  [t]                  type of record(s) being extracted
  [e]                  type of record(s) to exclude when R=ALL

.HELP,R
 The R parameter names the record to extract from a library file.
.HELP,L
 The L parameter names the file containing a library of records.
 The default value is the file containing this procedure.
.HELP,UN
 The UN parameter specifies the User Name location of the file.
 The default value is the User Name in which this procedure executes.
 On NOS/BE, The UN parameter specifies the permanent file ID of the file.
.HELP,G
 The G parameter names a local file to which record(s) are written.
 The default value is GROUP if ALL is specified for the R parameter,
 otherwise the R parameter value is the default.
.HELP,T
 The T parameter specifies the record type extracted from a library.
 The default is to extract all record types.
.HELP,E
 The E parameter names an excluded record type when R=ALL.
 By default all types specified by the T parameter are included.
 This parameter is ignored on NOS/BE.
.ENDHELP
.IFE,$G$.EQ.$L$,ERROR.
  REVERT,ABORT. CANNOT GET G --> L
.ENDIF,ERROR.
.IFE,(($G$.EQ.$$).AND.($R$.EQ.$*$)),ALLGROUP.
  REVERT,EX.GETLIB,R,L,UN,GROUP,T,E.
.ENDIF,ALLGROUP.
.IFE,(($G$.EQ.$$).AND.($R$.NE.$*$)),NOTALL.
  REVERT,EX.GETLIB,R,L,UN,R,T,E.
.ENDIF,NOTALL.
.IFE,FILE(L,.NOT.AS),NOTLOCAL.
  GETFILE,L,L,UN,READ,A=YES.
.ENDIF,NOTLOCAL.
.IFE,$R$.NE.$*$,NOTALL.
  IFE,FILE(G,AS),GOTG.
    REVERT. LOCAL FILE G FOUND
  ELSE,GOTG.
    GETFILE,G,G,UN,READ.
    IFE,FILE(G,AS),GOTGPF.
      NOTE,OUTPUT,NR.+ PERMANENT FILE G FOUND, #UN=UN.
      REVERT. PERMANENT FILE G FOUND
    ENDIF,GOTGPF.
  ENDIF,GOTG.
.ENDIF,NOTALL.
.IFE,(($R$.EQ.$*$).AND.($T$.EQ.$$)),ALLREC.
.*
.* RECORDS = ALL, RECORD TYPE NOT SPECIFIED
.*
  UNLOAD,G.
  .IFE,SYS=NOS,NOSSYS.
    .IFE,$E$.NE.$$,EXCLUDE.
      $NOTE(YYYGETD)+*IGNORE E/*
      $PACK(YYYGETD)
    .ENDIF,EXCLUDE.
    $GTR(L,G)ULIB/*
    $IFE,(FILE(G,AS).AND.($E$.NE.$ULIB$)),GETULIB.
      $LIBEDIT,P=0,N=YYYGETL,B=G,#L=0,I=YYYGETD.
      $RENAME,G=YYYGETL.
    $ELSE,GETULIB.
      $LIBEDIT,P=0,N=G,B=L,#L=0,I=YYYGETD.
    $ENDIF,GETULIB.
    $UNLOAD,YYYGETD.
  .ELSE,NOSSYS.
    COPYBF(L,G)
  .ENDIF,NOSSYS.
.ELSE,ALLREC.
  .IFE,(($T$.NE.$$).AND.($R$.EQ.$*$)),ALLTYPE.
.*
.* RECORDS = ALL, TYPE WAS SPECIFIED
.*
    UNLOAD,G.
    .IFE,$T$.NE.$ULIB$,NOTULIB.
      GTR(L,G)T/*
    .ELSE,NOTULIB.
      GTR(L,G,U)ULIB/*
    .ENDIF,NOTULIB.
    IFE,FILE(G,.NOT.AS),NOTFOUND.
 REVERT,ABORT. NO T RECORDS ON L, #UN=UN.
    ENDIF,NOTFOUND.
  .ELSE,ALLTYPE.
    .IFE,$T$.NE.$$,USERTYPE.
.*
.* RECORD NAME SPECIFIED, TYPE WAS SPECIFIED
.*
      .IFE,$T$.NE.$ULIB$,NOTULIB.
        GTR(L,G)T/R
      .ELSE,NOTULIB.
        GTR(L,G,U)ULIB/R
      .ENDIF,NOTULIB.
    .ELSE,USERTYPE.
.*
.* RECORD NAME SPECIFIED, RECORD TYPE NOT SPECIFIED
.*
      GTR(L,G,,,,NA)ABS/R
      GTR(L,G,,,,NA)CAP/R
      GTR(L,G,,,,NA)OPL/R
      GTR(L,G,,,,NA)OPLC/R
      GTR(L,G,,,,NA)OPLD/R
      GTR(L,G,,,,NA)OVL/R
      GTR(L,G,,,,NA)PP/R
      GTR(L,G,,,,NA)PPU/R
      GTR(L,G,,,,NA)PROC/R
      GTR(L,G,,,,NA)REL/R
      GTR(L,G,,,,NA)TEXT/R
      GTR(L,G,U,,,NA)ULIB/R
      IFE,FILE(G,.NOT.AS),NOTFOUND.
REVERT,ABORT. RECORD R NOT ON L, #UN=UN.
      ENDIF,NOTFOUND.
    .ENDIF,USERTYPE.
  .ENDIF,ALLTYPE.
.ENDIF,ALLREC.
.IFE,FILE(L,.NOT.AS),FILEPRM.
  UNLOAD,L.
.ENDIF,FILEPRM.
SKIP,NOERROR.
  EXIT.
  UNLOAD,YYYGETL,YYYGETD.
  .IFE,FILE(L,.NOT.AS),FILEPRM.
    UNLOAD,L.
  .ENDIF,FILEPRM.
REVERT,ABORT. T R NOT ON L, #UN=UN.
ENDIF,NOERROR.
.IFE,$R$.EQ.$*$,ALLREC.
  REVERT. ALL L T --> G
.ELSE,ALLREC.
  REVERT. L T R --> G
.ENDIF,ALLREC.
/EOR
