(tput) 1>/dev/null 2>&1
if [ $? = 1 ]; then
  CLEAR="clear"; export CLEAR
else
  CLEAR="tput clear"; export CLEAR
fi
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

  Demo Program Build and Run Procedure
  ====================================
 
  This Procedure will compile and run the library
  demonstration programs.  The library object archive
  file 'libposix.a' must be created, and the
  library environment variable POSIX must be
  defined, prior to performing this Procedure.
 "
echo "  <CR> to Continue"
read answer
if [ "$SYSID" = "" ]; then
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

       Select System
      ===============
         1. APOLLO
         2. RISC6K
         3. CONVEX
         4. SGIRIX
         5. SUNOS
         6. UNICOS
         7. HP9000
         8. DECOSF
         9. LINUX
 "
read SYSID; export SYSID
fi
LINK="f77 "; export LINK
FORTRAN=FORTRAN;export FORTRAN
LIBX11="libX11.a";export LIBX11
if [ "$SYSID" = "1" ]; then
  LINK="f77 "
fi
if [ "$SYSID" = "2" ]; then
  LINK='xlf '
fi
if [ "$SYSID" = "3" ]; then
  LINK='fc '
fi
if [ "$SYSID" = "4" ]; then
  LINK='f77 '
fi
if [ "$SYSID" = "5" ]; then
  LINK='f77 '
fi
if [ "$SYSID" = "6" ]; then
  LINK='cf77 -Wl"-D DUPENTRY=IGNORE" '
fi
if [ "$SYSID" = "7" ]; then
  LINK='fort77 '
fi
if [ "$SYSID" = "8" ]; then
  LINK='f77 -taso '
  LIBX11='libX11.so'
  echo " "
fi
if [ "$SYSID" = "9" ]; then
  LINK='g77 -Wunused '
fi
$CLEAR
echo "
 
        Creating demo program source files.
 "
echo "  Generating =====> [ ./_posix.tk ]"
cat <<"STOP_CAT"> ././_posix.tk
#!/tmp/tk/usr/X386/bin/wish -f
#
#       Programmer's Reusable Library, Version 0.7      (TM)
#
#            Copyright (C) 1995 Object Access (SM)
#
#     Permission is granted to any individual or institution
#     to use, copy, modify, and distribute this single program
#     unit, provided that this complete copyright and
#     permission notice is maintained, intact, in all copies.
#
#     Object Access Incorporated provides this software
#     "as is" without express or implied warranty.
#
#     PURPOSE: Demonstrate features of the PRL-POSIX library
#
#     NOTES:
#
#     ******************************************************************
#
#                       Define window title
#
set auto_path "$tk_library/demos $auto_path"
wm title . "PRL-POSIX Demonstration"
#
#     ******************************************************************
#
#                       Create the main window, consisting of a menu
#                       bar and a message explaining the basic operation
#                       of the program
#
frame .menu -relief raised -borderwidth 1
#
message .msg -font -Adobe-times-medium-r-normal--*-180* -relief raised \
-width 600 -borderwidth 1 -text \
"This window demonstrates the Programmer's Reuseable Library \
PRL-POSIX, Version 0.7 \
using a graphical user interface provided by the Tk toolkit.
 
To invoke a demonstration, press the left mouse button over one of the \
menu buttons, drag the mouse to the desired menu file, then release the \
mouse button.
 
The Demo menu tells more about using this window.
The More menu has more information about PRL-POSIX.
 
To exit, select the \"Quit\" option in the Demo menu.
 
----------------------------------------------------
 
Copyright (C) 1995 Object Access, Inc.
 
Permission is granted to any individual or institution \
to use, copy, modify, and distribute this single program \
unit, provided that this complete copyright and \
permission notice is maintained, intact, in all copies.
 
Object Access Incorporated provides this software \
\"as is\" without express or implied warranty."
#
pack .menu -side top -fill x
pack .msg -side bottom -expand yes -fill both
#
#     ******************************************************************
#
#                       DEFINE MENUS FOR TOP MENU ROW
#
#     ******************************************************************
#
#                       "Demo" menu
#
menubutton .menu.demo -text "Demo  " -menu .menu.demo.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.demo.m
#
#                       "Tear-off menus" button
.menu.demo.m add command -label "Tear-off menus" -command mkTear
#
#                       "Quit" button
.menu.demo.m add command -label "Quit" -command "destroy ."
#
#     ******************************************************************
#
#                       "FILE" menu
#
menubutton .menu.file -text "FILE  " -menu .menu.file.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.file.m
#
#                       "file1" button
.menu.file.m add command -label "file1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e file1.x }
#
#                       "file2" button
.menu.file.m add command -label "file2" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e file2.x }
#
#                       "file3" button
.menu.file.m add command -label "file3" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e file3.x }
#
#                       "file4" button
.menu.file.m add command -label "file4" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e file4.x }
#
#     ******************************************************************
#
#                       "FILEDAT" menu
#
menubutton .menu.filedat -text "FILEDAT  " -menu .menu.filedat.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.filedat.m
#
#                       "filedat1" button
.menu.filedat.m add command -label "filedat1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e filedat1.x }
#
#     ******************************************************************
#
#                       "PCONS" menu
#
menubutton .menu.pcons -text "PCONS  " -menu .menu.pcons.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.pcons.m
#
#                       "pcons1" button
.menu.pcons.m add command -label "pcons1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e pcons1.x }
#
#     ******************************************************************
#
#                       "POSIX" menu
#
menubutton .menu.posix -text "POSIX  " -menu .menu.posix.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.posix.m
#
#                       "posix1" button
.menu.posix.m add command -label "posix1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e posix1.x }
#
#     ******************************************************************
#
#                       "PRL" menu
#
menubutton .menu.prl -text "PRL  " -menu .menu.prl.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.prl.m
#
#                       "prl1" button
.menu.prl.m add command -label "prl1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e prl1.x }
#
#     ******************************************************************
#
#                       "PROCESS" menu
#
menubutton .menu.process -text "PROCESS  " -menu .menu.process.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.process.m
#
#                       "process1" button
.menu.process.m add command -label "process1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e process1.x }
#
#     ******************************************************************
#
#                       "SIGNAL" menu
#
menubutton .menu.signal -text "SIGNAL  " -menu .menu.signal.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.signal.m
#
#                       "signal1" button
.menu.signal.m add command -label "signal1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e signal1.x }
#
#                       "signal2" button
.menu.signal.m add command -label "signal2" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e signal2.x }
#
#     ******************************************************************
#
#                       "SYSTEM" menu
#
menubutton .menu.system -text "SYSTEM  " -menu .menu.system.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.system.m
#
#                       "system1" button
.menu.system.m add command -label "system1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e system1.x }
#
#                       "system2" button
.menu.system.m add command -label "system2" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e system2.x }
#
#                       "system3" button
.menu.system.m add command -label "system3" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e system3.x }
#
#     ******************************************************************
#
#                       "TERM" menu
#
menubutton .menu.term -text "TERM  " -menu .menu.term.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.term.m
#
#                       "term1" button
.menu.term.m add command -label "term1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e term1.x }
#
#                       "term2" button
.menu.term.m add command -label "term2" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e term2.x }
#
#     ******************************************************************
#
#                       "TIMER" menu
#
menubutton .menu.timer -text "TIMER  " -menu .menu.timer.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.timer.m
#
#                       "timer1" button
.menu.timer.m add command -label "timer1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e timer1.x }
#
#                       "timer2" button
.menu.timer.m add command -label "timer2" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e timer2.x }
#
#                       "timer3" button
.menu.timer.m add command -label "timer3" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e timer3.x }
#
#     ******************************************************************
#
#                       "USER" menu
#
menubutton .menu.user -text "USER  " -menu .menu.user.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.user.m
#
#                       "user1" button
.menu.user.m add command -label "user1" -command { \
exec xterm -rw -cr black -ms black -fg black -bg CadetBlue1 \
-sb -e user1.x }
#
#     ******************************************************************
#
#                       "More" menu
#
menubutton .menu.more -text "More" -menu .menu.more.m
#
#     ------------------------------------------------------------------
#
                        menu .menu.more.m
#
#                       "MENU Definitions" button
.menu.more.m add cascade -label "MENU Definitions" -menu .menu.more.defs
#
#     ------------------------------------------------------------------
#
                        menu .menu.more.defs
#
#                       "FILE" button
.menu.more.defs add command -label "FILE" -command \
{ mkDialog .modal {-text \
{The FILE menu invokes demonstrations of the PRL-POSIX \
FILE object subprograms.  The FILE object is \
an object that can be written to, read from, or both. \
} -aspect 450 -justify left} {OK {}}
}
#                       "FILEDAT" button
.menu.more.defs add command -label "FILEDAT" -command \
{ mkDialog .modal {-text \
{The FILEDAT menu invokes demonstrations of the PRL-POSIX \
FILEDAT object subprograms.  The FILEDAT object is \
the information written to or read from a file. \
} -aspect 450 -justify left} {OK {}}
}
#                       "PCONS" button
.menu.more.defs add command -label "PCONS" -command \
{ mkDialog .modal {-text \
{The PCONS menu invokes demonstrations of the PRL-POSIX \
PCONS object subprograms.  The PCONS object is \
a string with an associated numeric value. \
} -aspect 450 -justify left} {OK {}}
}
#                       "POSIX" button
.menu.more.defs add command -label "POSIX" -command \
{ mkDialog .modal {-text \
{The POSIX menu invokes demonstrations of the PRL-POSIX \
POSIX object subprograms.  The POSIX object is \
the parent object for all other PRL-POSIX objects. \
} -aspect 450 -justify left} {OK {}}
}
#                       "PRL" button
.menu.more.defs add command -label "PRL" -command \
{ mkDialog .modal {-text \
{The PRL menu invokes demonstrations of the PRL-POSIX \
PRL object subprograms.  The PRL object is \
the grandparent object of all Programmer's Reusable Library objects. \
} -aspect 450 -justify left} {OK {}}
}
#                       "PROCESS" button
.menu.more.defs add command -label "PROCESS" -command \
{ mkDialog .modal {-text \
{The PROCESS menu invokes demonstrations of the PRL-POSIX \
PROCESS object subprograms.  The PROCESS object is \
a single thread of control that executes within an address space. \
} -aspect 450 -justify left} {OK {}}
}
#                       "SIGNAL" button
.menu.more.defs add command -label "SIGNAL" -command \
{ mkDialog .modal {-text \
{The SIGNAL menu invokes demonstrations of the PRL-POSIX \
SIGNAL object subprograms.  The SIGNAL object is \
a mechanism by which a process may be notified or affected by a system event. \
} -aspect 450 -justify left} {OK {}}
}
#                       "SYSTEM" button
.menu.more.defs add command -label "SYSTEM" -command \
{ mkDialog .modal {-text \
{The SYSTEM menu invokes demonstrations of the PRL-POSIX \
SYSTEM object subprograms.  The SYSTEM object is \
an implementation of IEEE Std 1003.1-1990 for a particular machine. \
} -aspect 450 -justify left} {OK {}}
}
#                       "TERM" button
.menu.more.defs add command -label "TERM" -command \
{ mkDialog .modal {-text \
{The TERM menu invokes demonstrations of the PRL-POSIX \
TERM object subprograms.  The TERM object is \
a character special file. \
} -aspect 450 -justify left} {OK {}}
}
#                       "TIMER" button
.menu.more.defs add command -label "TIMER" -command \
{ mkDialog .modal {-text \
{The TIMER menu invokes demonstrations of the PRL-POSIX \
TIMER object subprograms.  The TIMER object is \
a mechanism for detecting events related to the passage of time. \
} -aspect 450 -justify left} {OK {}}
}
#                       "USER" button
.menu.more.defs add command -label "USER" -command \
{ mkDialog .modal {-text \
{The USER menu invokes demonstrations of the PRL-POSIX \
USER object subprograms.  The USER object is \
an external entity known to the system by a unique id and associated password. \
} -aspect 450 -justify left} {OK {}}
}
#     ******************************************************************
#
#                       Pack menus
#
pack .menu.demo \
     .menu.file \
     .menu.filedat \
     .menu.pcons \
     .menu.posix \
     .menu.prl \
     .menu.process \
     .menu.signal \
     .menu.system \
     .menu.term \
     .menu.timer \
     .menu.user \
     .menu.more -side left
#
#     ******************************************************************
#
#                       Set up for keyboard-based menu traversal
#
bind . <Any-FocusIn> {
    if {("%d" == "NotifyVirtual") && ("%m" == "NotifyNormal")} {
	focus .menu
    }
}
tk_menuBar .menu .menu.demo \
           .menu.file \
           .menu.filedat \
           .menu.pcons \
           .menu.posix \
           .menu.prl \
           .menu.process \
           .menu.signal \
           .menu.system \
           .menu.term \
           .menu.timer \
           .menu.user \
           .menu.more
#
#     ******************************************************************
#
#                       Position a dialog box on the screen
#
proc dpos w {
    wm geometry $w +300+300
}
#
STOP_CAT
echo "  Generating =====> [ ./file1.f ]"
cat <<"STOP_CAT"> ././file1.f
C     PROGRAM FILE1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library FILE object
C              for sequential formatted I/O
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       FILE object access programs
      EXTERNAL PXFCLS, PXFOPN, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_FLUSH
C
C                       PCONS object access programs
      EXTERNAL IPXCON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_QUERY, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       File pathname
      CHARACTER*80 FILNAM
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Check actual PRL version vs version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
 
C     ******************************************************************
C
C                       Use TERM functions for user console I/O
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "FILE" Object Demo Program #1'//
     * ' This demo uses FILE PXFOPN to open the file ''test_PXFOPN'''/
     * ' for sequential formatted I/O, WRITEs records to it then READs'/
     * ' them back, closes the file using FILE PXFCLS, and deletes'/
     * ' the file using FILE PXFUNL.'//
     * ' Any error messages generated are real errors and indicate a'/
     * ' problem with the library or this demo program.'/)
C
C                       Wait until user presses a key before continuing
      WRITE (IOUT,410)
  410 FORMAT (/'                         Press <CR> to continue')
      IN = TERM_GETIN ()
      READ (IN,411) STRING
  411 FORMAT (A)
C                       Clear screen using TERM_CLEAR
      CALL TERM_CLEAR (0)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and PCONS IPXCON
C
C                       Print message
      WRITE (IOUT,511)
  511 FORMAT (/' Opening file for formatted sequential I/O using',
     *         ' FILE PXFOPN')
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set read/write mode
      IOPFLG =
     *         IPXCON ('O_RDWR')
C                         Status bits - set for 'create'
     *        +IPXCON ('O_CREAT')
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,561)
  561   FORMAT (' File opened successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
  569     FORMAT(/' ',A)
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Write records to file
C
C                       Print message
      WRITE (IOUT,611)
  611 FORMAT (/' Writing three records to file using FORTRAN WRITE:')
C
C                       Write to file using IFLDES from PXFOPN
C                       and echo to screen
      WRITE (IFILDS,613,ERR=619) 'Record 1'
      WRITE (IOUT,615)           'Record 1'
      WRITE (IFILDS,613,ERR=619) 'Record 2'
      WRITE (IOUT,615)           'Record 2'
      WRITE (IFILDS,613,ERR=619) 'Record 3'
      WRITE (IOUT,615)           'Record 3'
  613 FORMAT (' ',A)
  615 FORMAT (6X,A8)
      GOTO 620
C                       Print message for write errors
  619 WRITE (IER,569) '*** ERROR: error writing records to file'
C
C     ------------------------------------------------------------------
C
C                       Rewind file
C
C                       Print message
  620 WRITE (IOUT,621) ' Rewinding file using FORTRAN REWIND'
  621 FORMAT (/A)
C
C                       Rewind sequential file
      REWIND (IFILDS,ERR=629)
      GOTO 630
C
C                       Print message for rewind errors
  629 WRITE (IER,569) '*** ERROR: error rewinding file'
C
C     ------------------------------------------------------------------
C
C                       Read records from file and echo on screen
C
C                       Print message
  630 WRITE (IOUT,631)
  631 FORMAT (/' Reading three records from file using FORTRAN READ:')
C
C                       Read from file using IFLDES from PXFOPN
      DO 635 I=1,3
        READ (IFILDS,632,END=633,ERR=639) STRING
  632   FORMAT (A)
C                       Write records to standard out
  633   WRITE (IOUT,634) STRING
  634   FORMAT (6X,A8)
  635 CONTINUE
      GOTO 700
C
C                       Print message for read errors
  639 WRITE (IER,569) '*** ERROR: error reading file'
C
C     ******************************************************************
C
C                       Use FILE PXFCLS to close file
C
C                       Print message
  700 WRITE (IOUT,701)
  701 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File closed successfully'
  711 FORMAT (' ',A)
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Use FILE PXFUNL to delete file
C
C                       Print message
      WRITE (IOUT,721)
  721 FORMAT (/' Deleting file using FILE PXFUNL')
C
C                       Set file pathname and delete file
      CALL PXFUNL (FILNAM,0,IERROR)
C                       Evaluate PXFUNL error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File deleted successfully'
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFUNL'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFUNL'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFUNL'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFUNL'
      ENDIF
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 FILE Demo Program #1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./file2.f ]"
cat <<"STOP_CAT"> ././file2.f
C     PROGRAM FILE2
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library FILE object
C              for sequential unformatted I/O
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       FILE object access programs
      EXTERNAL PXFCLS, PXFOPN, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_FLUSH
C
C                       PCONS object access programs
      EXTERNAL IPXCON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_QUERY, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       File pathname
      CHARACTER*80 FILNAM
C                       Character string
      CHARACTER*80 STRING
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Use TERM functions to write demo program
C                       introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "FILE" Object Demo Program #2'//
     * ' This demo uses FILE PXFOPN to open the file ''test_PXFOPN'''/
     * ' for sequential unformatted I/O in write-only mode, WRITEs'/
     * ' records to it, closes it using FILE PXFCLS, reopens it using'/
     * ' FILE PXFOPN in read-only mode, READs the records back,'/
     * ' closes the file using FILE PXFCLS, and deletes the file'/
     * ' using DIR PXFUNL.'//
     * ' Any error messages generated are real errors and indicate a'/
     * ' problem with the library or this demo program.')
C
C                       Wait until user presses a key before continuing
      WRITE (IOUT,410)
  410 FORMAT (/'                         Press <CR> to continue')
      IN = TERM_GETIN ()
      READ (IN,411) STRING
  411 FORMAT (A)
C                       Clear screen using TERM_CLEAR
      CALL TERM_CLEAR (0)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and
C                       PCONS IPXCON in write-only mode
C
C                       Print message
      WRITE (IOUT,511)
  511 FORMAT (/' Opening file for unformatted sequential write-only',
     *         ' I/O using FILE PXFOPN')
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set write-only
      IOPFLG =
     *         IPXCON ('O_WRONLY')
C                         Status bits - set all that apply
     *        +IPXCON ('O_CREAT')
C                         Set if file is unformatted
     *        +IPXCON ('UNFORM')
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,521)
  521   FORMAT (' File opened successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
  569     FORMAT(/' ',A/)
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Write records to file and echo on screen
C
C                       Print message
      WRITE (IOUT,611)
  611 FORMAT (/' Writing three records to file using FORTRAN WRITE:')
C
C                       Write to file using IFLDES from PXFOPN
C                       and echo to screen
      WRITE (IFILDS,ERR=619) 'Record 1'
      WRITE (IOUT,615)       'Record 1'
      WRITE (IFILDS,ERR=619) 'Record 2'
      WRITE (IOUT,615)       'Record 2'
      WRITE (IFILDS,ERR=619) 'Record 3'
      WRITE (IOUT,615)       'Record 3'
  615 FORMAT (6X,A8)
      GOTO 700
C                       Print message for write errors
  619 WRITE (IER,569) '*** ERROR: error writing records to file'
C
C     ******************************************************************
C
C                       Close file using FILE PXFCLS
C
C                       Print message
  700 WRITE (IOUT,701)
  701 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,711)
  711   FORMAT (' File closed successfully')
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and
C                       PCONS IPXCON in read-only mode
C
C                       Print message
      WRITE (IOUT,531)
  531 FORMAT (/' Opening file for unformatted sequential read-only',
     *         ' I/O using FILE PXFOPN')
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set read-only
      IOPFLG =
     *         IPXCON ('O_RDONLY')
C                         Set if file is unformatted
     *        +IPXCON ('UNFORM')
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,521)
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Read records from file and echo on screen
C
C                       Print message
      WRITE (IOUT,631)
  631 FORMAT (/' Reading three records from file using FORTRAN READ:')
C
C                       Read from file using IFLDES from PXFOPN
      DO 635 I=1,3
        READ (IFILDS,END=633,ERR=639) STRING(1:8)
C                       Write records to standard out
  633   WRITE (IOUT,634) STRING(1:8)
  634   FORMAT (6X,A8)
  635 CONTINUE
      GOTO 720
C
C                       Print message for read errors
  639 WRITE (IER,569) '*** ERROR: error reading file'
C
C     ******************************************************************
C
C                       Use FILE PXFCLS to close file
C
C                       Print message
  720 WRITE (IOUT,721)
  721 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,731)
  731   FORMAT (' File closed successfully')
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Use DIR PXFUNL to delete file
C
C                       Print message
      WRITE (IOUT,741)
  741 FORMAT (/' Deleting file using DIR PXFUNL')
C
C                       Set file pathname and delete file
      CALL PXFUNL (FILNAM,0,IERROR)
C                       Evaluate PXFUNL error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,751)
  751   FORMAT (' File deleted successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFUNL'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFUNL'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFUNL'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFUNL'
      ENDIF
 
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 FILE Demo Program #2 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./file3.f ]"
cat <<"STOP_CAT"> ././file3.f
C     PROGRAM FILE3
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library FILE object
C              for random formatted I/O
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       FILE object access programs
      EXTERNAL PXFCLS, PXFOPN, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_FLUSH, FILEDAT_RECL
C
C                       PCONS object access programs
      EXTERNAL IPXCON, PXCON,  PXICON
      LOGICAL  PXICON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_QUERY, TERM_BELL, TERM_READ, TERM_SETSIO,
     *         TERM_WRITE
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       File pathname
      CHARACTER*80 FILNAM
C                       Character string
      CHARACTER*80 STRING
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Use TERM functions for user console I/O
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "FILE" Object Demo Program #3'//
     * ' This demo uses FILE PXFOPN to open the file ''test_PXFOPN'''/
     * ' for random formatted I/O, WRITEs records to it then READs'/
     * ' them back in reverse order, closes the file using FILE'/
     * ' PXFCLS, and deletes the file using FILE PXFUNL.'//
     * ' Any error messages generated are real errors and indicate a'/
     * ' problem with the library or this demo program.')
C
C                       Wait until user presses a key before continuing
      WRITE (IOUT,410)
  410 FORMAT (/'                         Press <CR> to continue')
      IN = TERM_GETIN ()
      READ (IN,411) STRING
  411 FORMAT (A)
C                       Clear screen using TERM_CLEAR
      CALL TERM_CLEAR (0)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and PCONS IPXCON
C
C                       Print message
      WRITE (IOUT,511)
  511 FORMAT (/' Opening file for random access formatted I/O using',
     *         ' FILE PXFOPN')
C
C                       Compute record length of random access files
C                         Number of machine words per record
      NWDS = 3
C                         Record length for input to PXFOPN
      CALL FILEDAT_RECL (NWDS,LREC)
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set one only
      IOPFLG =
     *         IPXCON ('O_RDWR')
C                         Status bits - set all that apply
     *        +IPXCON ('O_CREAT')
C                         Set if file is direct access
     *        +IPXCON ('DIRECT') + LREC*256
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,561)
  561   FORMAT (' File opened successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
  569     FORMAT(/' ',A/)
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Write records to file
C
C                       Print message
      WRITE (IOUT,611)
  611 FORMAT (/' Writing three records to file using FORTRAN WRITE:')
C
C                       Write to file using IFILDS from PXFOPN
C                       and echo to screen
      WRITE (IFILDS,613,REC=1,ERR=619) ' Record 1'
      WRITE (IOUT,615)                 ' Record 1'
      WRITE (IFILDS,613,REC=2,ERR=619) ' Record 2'
      WRITE (IOUT,615)                 ' Record 2'
      WRITE (IFILDS,613,REC=3,ERR=619) ' Record 3'
      WRITE (IOUT,615)                 ' Record 3'
  613 FORMAT (A9)
  615 FORMAT (6X,A9)
      GOTO 630
C                       Print message for write errors
  619 WRITE (IER,569) '*** ERROR: error writing records to file'
C
C     ------------------------------------------------------------------
C
C                       Read records from file and echo on screen
C
C                       Print message
  630 WRITE (IOUT,631)
  631 FORMAT (/' Reading three records from file using FORTRAN READ:')
C
C                       Read from file using IFLDES from PXFOPN
      DO 635 I=3,1,-1
        READ (IFILDS,632,REC=I,ERR=639) STRING(1:9)
  632   FORMAT (A)
C                       Write records to standard out
        WRITE (IOUT,634) STRING
  634   FORMAT (6X,A9)
  635 CONTINUE
      GOTO 700
C
C                       Print message for read errors
  639 WRITE (IER,569) '*** ERROR: error reading file'
C
C     ******************************************************************
C
C                       Use FILE PXFCLS to close file
C
C                       Print message
  700 WRITE (IOUT,701)
  701 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File closed successfully'
  711 FORMAT (' ',A)
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Use FILE PXFUNL to delete file
C
C                       Print message
      WRITE (IOUT,721)
  721 FORMAT (/' Deleting file using FILE PXFUNL')
C
C                       Set file pathname and delete file
      CALL PXFUNL (FILNAM,0,IERROR)
C                       Evaluate PXFUNL error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File deleted successfully'
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFUNL'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFUNL'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFUNL'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFUNL'
      ENDIF
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 FILE Demo Program #3 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./file4.f ]"
cat <<"STOP_CAT"> ././file4.f
C     PROGRAM FILE4
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library FILE object
C              form random unformatted I/O
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       FILE object access programs
      EXTERNAL PXFCLS, PXFOPN, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_FLUSH, FILEDAT_RECL
C
C                       PCONS object access programs
      EXTERNAL IPXCON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_QUERY, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       File pathname
      CHARACTER*80 FILNAM
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Programs as Needed
C
C     ******************************************************************
C
C                       Use TERM functions for user console I/O
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "FILE" Object Demo Program #4'//
     * ' This demo uses FILE PXFOPN to open the file ''test_PXFOPN'''/
     * ' for random unformatted I/O in write-only mode, WRITEs'/
     * ' records to it, closes it using FILE PXFCLS, reopens it using'/
     * ' FILE PXFOPN in read-only mode, READs the records back in'/
     * ' reverse order, closes the file using FILE PXFCLS, and'/
     * ' deletes the file using FILE PXFUNL.'//
     * ' Any error messages generated are real errors and indicate a'/
     * ' problem with the library or this demo program.')
C
C                       Wait until user presses a key before continuing
      WRITE (IOUT,410)
  410 FORMAT (/'                         Press <CR> to continue')
      IN = TERM_GETIN ()
      READ (IN,411) STRING
  411 FORMAT (A)
C                       Clear screen using TERM_CLEAR
      CALL TERM_CLEAR (0)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                        Open files using FILE PXFOPN and
C                        PCONS IPXCON in write-only mode
C
C                       Print message
      WRITE (IOUT,511)
  511 FORMAT (/' Opening file for unformatted random write-only',
     *         ' I/O using FILE PXFOPN')
C
C                       Compute record length of random access files
C                         Number of machine words per record
      NWDS = 3
C                         Record length for input to PXFOPN
      CALL FILEDAT_RECL (NWDS,LREC)
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set write-only
      IOPFLG =
     *         IPXCON ('O_WRONLY')
C                         Status bits - set all that apply
     *        +IPXCON ('O_CREAT')
C                         Set if file is unformatted
     *        +IPXCON ('UNFORM')
C                         Set if file is direct access
     *        +IPXCON ('DIRECT')  + LREC*256
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,521)
  521   FORMAT (' File opened successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
  569     FORMAT(/' ',A/)
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Write records to file and echo on screen
C
C                       Print message
      WRITE (IOUT,611)
  611 FORMAT (/' Writing three records to file using FORTRAN WRITE:')
C
C                       Write to file using IFLDES from PXFOPN
C                       and echo to screen
      WRITE (IFILDS,REC=1,ERR=619) ' Record 1'
      WRITE (IOUT,615)             ' Record 1'
      WRITE (IFILDS,REC=2,ERR=619) ' Record 2'
      WRITE (IOUT,615)             ' Record 2'
      WRITE (IFILDS,REC=3,ERR=619) ' Record 3'
      WRITE (IOUT,615)             ' Record 3'
  615 FORMAT (6X,A9)
      GOTO 700
C                       Print message for write errors
  619 WRITE (IER,569) '*** ERROR: error writing records to file'
C
C     ******************************************************************
C
C                       Close file using FILE PXFCLS
C
C                       Print message
  700 WRITE (IOUT,701)
  701 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,711)
  711   FORMAT (' File closed successfully')
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and
C                       PCONS IPXCON in read-only mode
C
C                       Print message
      WRITE (IOUT,531)
  531 FORMAT (/' Opening file for unformatted random read-only',
     *         ' I/O using FILE PXFOPN')
C
C                       Compute record length of random access files
C                         Number of machine words per record
      NWDS = 3
C                         Record length for input to PXFOPN
      CALL FILEDAT_RECL (NWDS,LREC)
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set read-only
      IOPFLG =
     *         IPXCON ('O_RDONLY')
C                         Set if file is unformatted
     *        +IPXCON ('UNFORM')
C                         Set if file is direct access
     *        +IPXCON ('DIRECT')  + LREC*256
C
C                       Set file pathname and open file
      FILNAM = 'test_PXFOPN.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,521)
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Read records from file and echo on screen
C
C                       Print message
      WRITE (IOUT,631)
  631 FORMAT (/' Reading three records from file using FORTRAN READ:')
C
C                       Read from file using IFLDES from PXFOPN
      DO 635 I=3,1,-1
        READ (IFILDS,REC=I,ERR=639) STRING(1:9)
C                       Write records to standard out
        WRITE (IOUT,634) STRING(1:9)
  634   FORMAT (6X,A9)
  635 CONTINUE
      GOTO 720
C
C                       Print message for read errors
  639 WRITE (IER,569) '*** ERROR: error reading file'
C
C     ******************************************************************
C
C                       Use FILE PXFCLS to close file
C
C                       Print message
  720 WRITE (IOUT,721)
  721 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,731)
  731   FORMAT (' File closed successfully')
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Use FILE PXFUNL to delete file
C
C                       Print message
      WRITE (IOUT,741)
  741 FORMAT (/' Deleting file using FILE PXFUNL')
C
C                       Set file pathname and delete file
      CALL PXFUNL (FILNAM,0,IERROR)
C                       Evaluate PXFUNL error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,751)
  751   FORMAT (' File deleted successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFUNL'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFUNL'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFUNL'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFUNL'
      ENDIF
 
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 FILE Demo Program #4 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./filedat1.f ]"
cat <<"STOP_CAT"> ././filedat1.f
C     PROGRAM FILEDAT1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program FILEDAT_FLUSH
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       FILE object access programs
      EXTERNAL PXFCLS, PXFOPN, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_FLUSH
C
C                       PCONS object access programs
      EXTERNAL IPXCON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_QUERY, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       File pathname
      CHARACTER*80 FILNAM
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Programs as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "FILEDAT1" Object Demo Program'//
     * ' This demo uses FILEDAT_FLUSH to flush to the end of the file'/
     * ' ''test_FILEDAT_FLUSH'' (opened by FILE PXFOPN) so records may'/
     * ' be appended to the file.  The records are READ back, the file'/
     * ' closed using FILE PXFCLS, then deleted using FILE PXFUNL.'//
     * ' Any error messages generated are real errors and indicate a'/
     * ' problem with the library or this demo program.')
C
C                       Wait until user presses a key before continuing
      WRITE (IOUT,410)
  410 FORMAT (/'                         Press <CR> to continue')
      IN = TERM_GETIN ()
      READ (IN,411) STRING
  411 FORMAT (A)
C                       Clear screen using TERM_CLEAR
      CALL TERM_CLEAR (0)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                       Open files using FILE PXFOPN and PCONS IPXCON
C
C                       Print message
      WRITE (IOUT,511)
  511 FORMAT (/' Opening file using FILE PXFOPN')
C
C                       Process POSIX constants for input to PXFOPN
C                         Mode bits - set one only
      IOPFLG =
     *         IPXCON ('O_RDWR')
C                         Status bits - set all that apply
     *        +IPXCON ('O_CREAT')
C
C                       Set file pathname and open file
      FILNAM = 'test_FILEDAT_FLUSH.dat'
      CALL PXFOPN (FILNAM,0,IOPFLG,0,IFILDS,IERROR)
C
C                       Evaluate PXFOPN error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
        WRITE (IOUT,561)
  561   FORMAT (' File opened successfully')
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFOPN'
  569     FORMAT(/' ',A)
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFOPN'
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
          WRITE (IER,569) '*** ERROR: ENFILE error from PXFOPN'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFOPN'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFOPN'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFOPN'
      ENDIF
C
C     ******************************************************************
C
C                       Read and write to files
C
C                       Loop for each record
      DO 650 I=1,4
C
C     ------------------------------------------------------------------
C
C                       Rewind file
C
C                       Print message
      WRITE (IOUT,569) ' Rewinding file using FORTRAN REWIND'
C
C                       Rewind sequential file
      REWIND (IFILDS,ERR=629)
      GOTO 623
C
C                       Print message for rewind errors
  629 WRITE (IER,569) '*** ERROR: error rewinding file'
C
C                       Branch based on loop count
  623 GOTO (610,611,612,630), I
C
C     ------------------------------------------------------------------
C
C                       Write records to file
C
C                       Store string to be written
  610 STRING = 'Record 1'
      GOTO 617
  611 STRING = 'Record 2'
      GOTO 617
  612 STRING = 'Record 3'
C
C                       Print message
  617 WRITE (IOUT,621) 'Flushing to end of file using FILEDAT_FLUSH'
  621 FORMAT (' ',A)
C
C                       Flush to end of file
      CALL FILEDAT_FLUSH (IFILDS,IERROR)
C                       Check for FILEDAT_FLUSH error
      IF (IERROR .NE. 0) THEN
        WRITE (IER,569) '*** ERROR: error flushing to end of file'
      ENDIF
C
C                       Print message
      WRITE (IOUT,621) 'Writing record to file using FORTRAN WRITE'
C
C                       Write to file using IFLDES from PXFOPN,
C                       and echo to screen
      WRITE (IFILDS,613,ERR=619) STRING
      WRITE (IOUT,615) STRING
  613 FORMAT (A)
  615 FORMAT (6X,A8)
      GOTO 650
C                       Print message for write errors
  619 WRITE (IER,569) '*** ERROR: error writing records to file'
      GOTO 650
C
C     ------------------------------------------------------------------
C
C                       Read records from file and echo on screen
C
C                       Print message
  630 WRITE (IOUT,631)
  631 FORMAT (/' Reading three records from file using FORTRAN READ:')
C
C                       Read from file using IFLDES from PXFOPN
      DO 635 J=1,3
        READ (IFILDS,632,END=633,ERR=639) STRING
  632   FORMAT (A)
C                       Write records to standard out
  633   WRITE (IOUT,634) STRING
  634   FORMAT (6X,A8)
  635 CONTINUE
      GOTO 650
C
C                       Print message for read errors
  639 WRITE (IER,569) '*** ERROR: error reading file'
C
C     ------------------------------------------------------------------
C
C                       Repeat for next record
  650 CONTINUE
C
C     ******************************************************************
C
C                       Use FILE PXFCLS to close file
C
C                       Print message
      WRITE (IOUT,701)
  701 FORMAT (/' Closing file using FILE PXFCLS')
C
C                       Close file
      CALL PXFCLS (IFILDS,IERROR)
C                       Evaluate PXFCLS error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File closed successfully'
  711 FORMAT (' ',A)
C                         Check for logical unit error
        ELSE IF (IERROR .EQ. IPXCON('EBADF') ) THEN
          WRITE (IER,569) '*** ERROR: EBADF error from PXFCLS'
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR') ) THEN
          WRITE (IER,569) '*** ERROR: EINTR error from PXFCLS'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFCLS'
      ENDIF
C
C     ******************************************************************
C
C                       Use FILE PXFUNL to delete file
C
C                       Print message
      WRITE (IOUT,721)
  721 FORMAT (/' Deleting file using FILE PXFUNL')
C
C                       Set file pathname and delete file
      CALL PXFUNL (FILNAM,0,IERROR)
C                       Evaluate PXFUNL error return code
C                         Check for no errors
      IF (IERROR .EQ. 0) THEN
      WRITE (IOUT,711) 'File deleted successfully'
C                         Check for name length error
        ELSE IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
          WRITE (IER,569) '*** ERROR: ENAMETOOLONG error from PXFUNL'
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
          WRITE (IER,569) '*** ERROR: EACCES error from PXFUNL'
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
          WRITE (IER,569) '*** ERROR: ENOENT error from PXFUNL'
C                         Check for unspecified error
        ELSE
          WRITE (IER,569) '*** ERROR: unspecified error from PXFUNL'
      ENDIF
 
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 FILEDAT1 Demo Program Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./pcons1.f ]"
cat <<"STOP_CAT"> ././pcons1.f
C     PROGRAM PCONS1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library PCONS object
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       PCONS object access programs
      EXTERNAL IPXCON, PXCON,  PXICON
      LOGICAL  PXICON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_GETERR, TERM_GETIN, TERM_GETOUT,
     *         TERM_READ, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C                       Number of POSIX constants in DATA arrays
      PARAMETER (NPC = 15)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*12 STRING
C                       POSIX Constants
      CHARACTER*12 PCONST(NPC)
C
      DATA PCONST /
     * 'DOS-ERROR   ','O_RDONLY    ','O_WRONLY    ','O_RDWR      ',
     * 'O_APPEND    ','O_CREAT     ','EACCES      ','ENFILE      ',
     * 'EINTR       ','ENOENT      ','ENONAME     ','ENAMETOOLONG',
     * 'DIRECT      ','UNFORM      ','EBADF       '/
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Programs as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "PCONS1" Object Demo Program'//
     * ' This demo prints a list of the POSIX symbolic constants'/
     * ' supported by PRL-POSIX, plus an error message for a string'/
     * ' that is not a valid POSIX constant, as verified by PCONS'/
     * ' IPXCON, PXCON, and PXICON'/)
C
C                       Get LUN of standard error using TERM_GETERR
      IER = TERM_GETERR ()
C
C     ******************************************************************
C
C                       Check validity of POSIX constants
C                       using PCONS IPXCON, PXCON and PXICON
C
C                       Check validity of POSIX symbolic constants
C                       using PCONS PXCON and IPXCON
C
C                       Loop for each POSIX constant in DATA arrays
      DO 590 I=1,NPC
      STRING = PCONST(I)
C
C                       Get system's value of specified POSIX constant
      CALL PXCON (STRING,IVALUE,IERROR)
C                       Evaluate PXCON error return code
C                         Check for errors
      IF (IERROR .NE. 0) THEN
C                         Check for invalid constant error
        IF (IERROR .EQ. IPXCON('ENONAME') ) THEN
          WRITE (IOUT,513) STRING
  513     FORMAT (' PXCON: ',A,' is not a POSIX symbolic constant')
C
C                         Check for unspecified error
        ELSE
          WRITE (IER,514)
  514     FORMAT (/' *** ERROR: unspecified error in PCONS PXCON'/)
        ENDIF
      ENDIF
C
C     ------------------------------------------------------------------
C
C                         Obtain the value of POSIX symbolic constant
C                         using PCONS PXCON and PXICON
C
C                         Check if STRING is a valid POSIX constant
      IF (PXICON (STRING)) THEN
C                         Get system's value of specified POSIX constant
C                         (IERROR should always be zero on return)
        CALL PXCON (STRING,IVALUE,IERROR)
C                         Print message if valid constant
        IF (IERROR .EQ. 0) THEN
          WRITE (IOUT,521) STRING
  521     FORMAT (' PXCON: ',A,' is a valid POSIX symbolic constant')
        ENDIF
C                         STRING is not a valid POSIX constant
      ELSE
        WRITE (IOUT,523) STRING
  523   FORMAT (' PXICON: ',A,' is not a POSIX symbolic constant')
      ENDIF
C                       Loop for next POSIX constants in DATA array
  590 CONTINUE
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 PCONS1 Demo Program Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./posix1.f ]"
cat <<"STOP_CAT"> ././posix1.f
C     PROGRAM POSIX
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program POSIX_INIT
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C     ------------------------------------------------------------------
C
      CHARACTER*80 STRING
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Write intro message
C                       (use * for logical unit since TERM_SETSIO will
C                       not be called in this demo)
      WRITE (*,401)
  401 FORMAT (
     * '                   PRL-POSIX "POSIX1" Object Demo Program'//
     * ' POSIX_INIT must be used to initialize the PRL-POSIX library'/
     * ' prior to invoking any other PRL-POSIX subprograms.  Failure'/
     * ' to initialize the library will cause erroneous program'/
     * ' operation.'/
     * ' '/
     * ' POSIX_INIT was called before printing this message'/)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C                       Wait until user presses a key before exiting
C
      WRITE (*,810)
  810 FORMAT (/
     * '                 Demo Program POSIX1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      READ (*,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./prl1.f ]"
cat <<"STOP_CAT"> ././prl1.f
C     PROGRAM PRL1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program PRL_LIBVER
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
      INTRINSIC INDEX,LEN
C
C                       PRL object access programs
      EXTERNAL PRL_LIBVER
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C     ------------------------------------------------------------------
C
      PARAMETER (MAXVER=9)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERSQ(MAXVER)
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERSQ /'0.7     ',
     2            '0.6     ',
     3            '0.6.10  ',
     4            '0.7.1   ',
     5            '0.8     ',
     6            '0.8.1   ',
     9            '1.6     ',
     7            '1.7     ',
     8            '1.8     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Write intro message
C                       (use * for logical unit since TERM_SETSIO will
C                       not be called in this demo)
      WRITE (*,401)
  401 FORMAT (
     * '                   PRL "PRL1" Object Demo Program'//
     * ' PRL_LIBVER should be used to check the version of the'/
     * ' Programmer''s Reusable Library being used and print the'/
     * ' following types of WARNING or ERROR messages if the'/
     * ' version is not correct.')
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Loop for each test case
      DO 200 IVER=1,MAXVER
C
C                       Get actual PRL version being used
C                       but do not perform check
      CALL PRL_LIBVER (VERAQ,' ')
C
C                       Compare actual & required major release numbers
      LOCAQ = INDEX (VERAQ,'.')
      LOCRQ = INDEX (VERSQ(IVER),'.')
      LENAQ = LEN (VERAQ)
      LENRQ = LEN (VERSQ(IVER))
      IF (VERAQ(1:LOCAQ) .NE. VERSQ(IVER)(1:LOCRQ)) THEN
        WRITE (*,213) VERAQ,VERSQ(IVER)
  213   FORMAT (/
     *  ' SAMPLE MESSAGE FOR INCORRECT LIBRARY VERSION:'/
     *  ' ERROR: Incompatible version of Programmer''s Reusable Library'
     *  /' Program is using version ',A,'but requires version ',A)
        GOTO 200
C
C                       Compare actual & reqd secondary release numbers
      ELSE IF (VERAQ(LOCAQ+1:LENAQ) .LT.
     *         VERSQ(IVER)(LOCRQ+1:LENRQ)) THEN
        WRITE (*,223) VERAQ,VERSQ(IVER)
  223   FORMAT (/
     *   ' SAMPLE MESSAGE FOR OUT-OF-DATE LIBRARY VERSION:'/
     *   ' WARNING: Old version of Programmer''s Reusable Library'/
     *   ' Program is using version ',A,'but requires version ',A)
C                       Print message for acceptable version
      ELSE
        WRITE (*,233) VERAQ,VERSQ(IVER)
  233   FORMAT (/
     *   ' NO MESSAGE PRINTED WHEN LIBRARY VERSION IS ACCEPTABLE:'/
     *   ' (Program is using version ',A,'and requires version ',A,' )')
      ENDIF
  200 CONTINUE
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C                       Wait until user presses a key before exiting
C
      WRITE (*,810)
  810 FORMAT (/
     * '                 Demo Program PRL1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      READ (*,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./process1.f ]"
cat <<"STOP_CAT"> ././process1.f
C     PROGRAM PROCESS1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program PROCESS_EXIT
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C     ------------------------------------------------------------------
C
      CHARACTER*80 STRING
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Write intro message
C                       (use * for logical unit since TERM_SETSIO will
C                       not be called in this demo)
      WRITE (*,401)
  401 FORMAT (
     * '                PRL-POSIX "PROCESS" Object Demo Program #1'//
     * ' PROCESS_EXIT may be used to terminate execution of programs'/
     * ' that use the PRL-POSIX library.  PROCESS_EXIT will be used'/
     * ' to exit from this demo after you press the Carriage Return'/
     * ' or Enter key <CR>.')
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C                       Wait until user presses a key before exiting
C
      WRITE (*,810)
  810 FORMAT (/
     * '                 Demo Program PROCESS1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      READ (*,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./signal1.f ]"
cat <<"STOP_CAT"> ././signal1.f
C     PROGRAM SIGNAL1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program SIGNAL_SHELL
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SIGNAL object access programs
      EXTERNAL SIGNAL_SHELL
C
C                       SYSTEM object access program
      EXTERNAL SYSTEM_TYPE
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT,
     *         TERM_READ, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Operating system user command
      CHARACTER*80 OSCMD
C                       Character string
      CHARACTER*4 STRING
      CHARACTER*6 SYTYP
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "SIGNAL" Object Demo Program #1'//
     * ' This demo uses SIGNAL_SHELL to signal the command shell to'/
     * ' print the calendar for the year you enter using the UNIX'/
     * ' ''cal'' command.'/)
C
C     ******************************************************************
C
C                       Use TERM functions for user console I/O
C
C                       Write prompt to standard out
      CALL TERM_WRITE (' Enter a year (e.g., 1776):',0)
C                       Read value from standard in
      CALL TERM_READ (STRING,0)
C
C     ******************************************************************
C
C                       Execute operating system user commands as needed
C                       using SIGNAL function
C
C                       Get system type
      CALL SYSTEM_TYPE (SYTYP)
      IF (SYTYP .NE. 'DECVAX') THEN
C
C                       Define O/S user command on UNIX
        OSCMD = 'cal '//STRING
C
C                       Execute O/S user command
        CALL SIGNAL_SHELL (OSCMD)
C
C                       Write message to standard out on VMS
      ELSE
        CALL TERM_WRITE (' No calendar command under VMS.',0)
      ENDIF
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 SIGNAL Demo Program #1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./signal2.f ]"
cat <<"STOP_CAT"> ././signal2.f
C     PROGRAM SIGNAL2
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program SIGNAL_SHELL
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SIGNAL object access programs
      EXTERNAL SIGNAL_SHELL
C
C                       SYSTEM object access program
      EXTERNAL SYSTEM_TYPE
C
C                       TERM object access programs
      EXTERNAL TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Operating system user command
      CHARACTER*80 OSCMD
C                       Character string
      CHARACTER*80 STRING
      CHARACTER*6 SYTYP
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "SIGNAL" Object Demo Program #2'//
     * ' This demo uses SIGNAL_SHELL to signal the command shell to'/
     * ' list the contents of the current directory.'/)
C
C     ******************************************************************
C
C                       Execute operating system user commands as needed
C                       using SIGNAL function
C
C                       Get system type
      CALL SYSTEM_TYPE (SYTYP)
C
C                       Define O/S user command
      IF (SYTYP .EQ. 'DECVAX') THEN
        OSCMD = 'DIR'
      ELSE
        OSCMD = 'ls -Cs'
      ENDIF
C                       Execute O/S user command
      CALL SIGNAL_SHELL (OSCMD)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 SIGNAL Demo Program #2 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./skeleton.f ]"
cat <<"STOP_CAT"> ././skeleton.f
C     PROGRAM SKELETON
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate use of PRL-POSIX library
C
C     LOCAL VARIABLES:
C
C
C     NOTES:
C       1. This is a program skeleton that may be used for development
C          of any program that uses the PRL-POSIX library.  Customize
C          to your needs by retaining desired lines.
C
C       2. Steps 1 through 2 must be performed first in sequence, and
C          step  5 must be performed last.  Other steps may be mixed
C          as necessary.
C
C     ******************************************************************
C
C     INTRINSIC
C
C                       FILE object access programs
      EXTERNAL PXFOPN, PXFCLS, PXFUNL
C
C                       FILEDAT object access programs
      EXTERNAL FILEDAT_RECL, FILEDAT_FLUSH
C
C                       PCONS object access programs
      EXTERNAL IPXCON, PXCON, PXICON
      INTEGER IPXCON
      LOGICAL PXICON
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT
C
C                       PRL object access programs
      EXTERNAL PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SIGNAL object access programs
      EXTERNAL SIGNAL_SHELL
C
C                       SYSTEM object access programs
      EXTERNAL SYSTEM_INFO, SYSTEM_BPW, SYSTEM_SYSTUM, SYSTEM_TYPE
C
C                       TERM object access programs
      EXTERNAL TERM_SETSIO, TERM_QUERY, TERM_GETERR, TERM_GETIN
     *        , TERM_GETOUT, TERM_WRITE, TERM_BELL, TERM_CLEAR
     *        , TERM_READ
      INTEGER TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C                       TIMER object access programs
      EXTERNAL TIMER_SLEEP, TIMER_DATE, TIMER_TIME, TIMER_WAIT
C
C                       USER object access programs
      EXTERNAL USER_NAME
C
C     ------------------------------------------------------------------
C
C                       Integer variables and arrays
      INTEGER ISCOPE, IN, IOUT, IERR, KTYPE, NCHRS, KTYP, NCHRR, ILEN
     *        , IOPFLG, IMODE, IFILDS, IERROR, IFLDS, IERR01, IERR02
     *        , NWDS, LREC, IUNIT, IERR03, IVAL, IERR04, IBPW, ISEC
     *        , ILEFT, IERR00, MILLI
      INTEGER IRETRN
C
C                       Real variables and arrays
C     REAL
C
C                       Double precision variables and arrays
C     DOUBLE PRECISION
C
C                       Complex variables and arrays
C     COMPLEX
C
C                       Logical variables and arrays
      LOGICAL LRETRN
C
C                       Character variables and arrays
      CHARACTER VERAQ*8, VERRQ*8, KEBUFS*1, KEBUFF*1, PATH*1, CONNAM*12
     *        , KOMAND*1, FUNC1*4, HOSTID*1, FUNC2*4, STR1*10, STR2*6
     *        , STR3*10, STR4*8, USRNAM*1
C
C                       Program required PRL version (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1  - Initialize the library
C
C     ------------------------------------------------------------------
C
C                       Use POSIX_INIT object access program
C
C                       Initialize the PRL-POSIX library
      ISCOPE = 0
      CALL POSIX_INIT (ISCOPE)
C
C     ******************************************************************
C
C                       STEP 2  - Check the Programmer's Reusable
C                       Library version
C
C     ------------------------------------------------------------------
C
C                       Use PRL_LIBVER object access program
C
C                       Return the version of the Programmer's Reusable
C                       Libr
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3  - Set the standard I/O LUNs and the
C                       terminal type
C
C     ------------------------------------------------------------------
C
C                       Use TERM_SETSIO object access program
C
C                       Set or change values of standard I/O logical
C                       unit numbers
      IN = 5
      IOUT = 6
      IERR = 6
      CALL TERM_SETSIO (IN,IOUT,IERR)
C
C     ------------------------------------------------------------------
C
C                       Use TERM_QUERY object access program
C
C                       Query user for user console device selection
      KTYPE = 0
      CALL TERM_QUERY (KTYPE)
C
C     ******************************************************************
C
C                       STEP 4  - Use FORTRAN-callable system objects as
C                       needed
C
C     ------------------------------------------------------------------
C
C                       Use TERM object access programs
C
C                       Set or change values of standard I/O logical
C                       unit numbers
C     IN =
C     IOUT =
C     IERR =
      CALL TERM_SETSIO (IN,IOUT,IERR)
C
C                       Query user for user console device selection
C     KTYPE =
      CALL TERM_QUERY (KTYPE)
C
C                       Get value of standard error logical unit number
      IRETRN = TERM_GETERR ()
C
C                       Get value of standard input logical unit number
      IRETRN = TERM_GETIN ()
C
C                       Get value of standard output logical unit number
      IRETRN = TERM_GETOUT ()
C
C     ------------------------------------------------------------------
C
C                       How to use TERM to produce a nicer character-
C                       based user interface with less code syntax
C
C                       Clear the screen on the user console
C     KTYP =
      CALL TERM_CLEAR (KTYP)
C
C                       Ring the bell on the user console
      CALL TERM_BELL ()
C
C                       Send character string to standard output
C     KEBUFS =
C     NCHRS =
      CALL TERM_WRITE (KEBUFS,NCHRS)
C
C                       Read character string from standard input
C     NCHRR =
      CALL TERM_READ (KEBUFF,NCHRR)
C
C     ------------------------------------------------------------------
C
C                       Use FILEDAT object access programs
C
C                       Flush to end of a sequential file
C     IUNIT =
      CALL FILEDAT_FLUSH (IUNIT,IERR03)
C                       Check for FILEDAT_FLUSH error
      IF (IERR03 .NE. 0) THEN
C         :
      ENDIF
C
C                       Determine record length for random access file
C     NWDS =
      CALL FILEDAT_RECL (NWDS,LREC)
C
C     ------------------------------------------------------------------
C
C                       Use FILE object access programs
C
C                       Open a file
C     PATH =
C     ILEN =
      IOPFLG =
     *         IPXCON ('O_RDWR')
C    *         IPXCON ('O_RDONLY')
C    *         IPXCON ('O_WRONLY')
C                         Status bits - set all that apply
C    *        +IPXCON ('O_CREAT')
C    *        +IPXCON ('O_APPEND')
C                         Set if file is unformatted
C    *        +IPXCON ('UNFORM')
C                         Set if file is direct access
C    *        +IPXCON ('DIRECT') + LREC*256
C     IMODE =
      CALL PXFOPN (PATH,ILEN,IOPFLG,IMODE,IFILDS,IERROR)
C                       Evaluate PXFOPN error return code
C                         Check for errors
      IF (IERROR .NE. 0) THEN
C                         Check for name length error
        IF (IERROR .EQ. IPXCON('ENAMETOOLONG') ) THEN
C         :
C                         Check for access error
        ELSE IF (IERROR .EQ. IPXCON('EACCES') ) THEN
C         :
C                         Check for LUN assignment error
        ELSE IF (IERROR .EQ. IPXCON('ENFILE') ) THEN
C         :
C                         Check for file operation error
        ELSE IF (IERROR .EQ. IPXCON('EINTR')  ) THEN
C         :
C                         Check for file existence error
        ELSE IF (IERROR .EQ. IPXCON('ENOENT') ) THEN
C         :
C                         Check for unspecified error
        ELSE
C         :
        ENDIF
      ENDIF
C
C
C                       Close a file
C     IFLDS =
      CALL PXFCLS (IFLDS,IERR01)
C                       Evaluate PXFCLS error return code
C                         Check for errors
      IF (IERR01 .NE. 0) THEN
C                         Check for logical unit error
        IF (IERR01 .EQ. IPXCON('EBADF') ) THEN
C         :
C                         Check for file operation error
        ELSE IF (IERR01 .EQ. IPXCON('EINTR') ) THEN
C         :
C                         Check for unspecified error
        ELSE
C         :
        ENDIF
      ENDIF
C
C
C                       Remove a directory entry
C     PATH =
C     ILEN =
      CALL PXFUNL (PATH,ILEN,IERR02)
C                       Evaluate PXFUNL error return code
C                         Check for errors
      IF (IERR02 .NE. 0) THEN
C                         Check for name length error
        IF (IERR02 .EQ. IPXCON('ENAMETOOLONG') ) THEN
C         :
C                         Check for access error
        ELSE IF (IERR02 .EQ. IPXCON('EACCES') ) THEN
C         :
C                         Check for file existence error
        ELSE IF (IERR02 .EQ. IPXCON('ENOENT') ) THEN
C         :
C                         Check for unspecified error
        ELSE
C         :
        ENDIF
      ENDIF
C
C     ------------------------------------------------------------------
C
C                       Use PCONS object access programs
C
C                       Get integer value associated with POSIX constant
C                       string
C     CONNAM =
      IRETRN = IPXCON (CONNAM)
C
C
C                       Get integer value associated with POSIX constant
C                       string
C     CONNAM =
      CALL PXCON (CONNAM,IVAL,IERR04)
C                       Evaluate PXCON error return code
C                         Check for errors
      IF (IERR04 .NE. 0) THEN
C                         Check for invalid constant error
        IF (IERR04 .EQ. IPXCON('ENONAME') ) THEN
C         :
C                         Check for unspecified error
        ELSE
C         :
        ENDIF
      ENDIF
C
C
C                       Determine if given string is a defined POSIX
C                       constant
C     CONNAM =
      LRETRN = PXICON (CONNAM)
C
C     ------------------------------------------------------------------
C
C                       Use SIGNAL object access programs
C
C                       Execute system user command during program
C                       execution
C     KOMAND =
      CALL SIGNAL_SHELL (KOMAND)
C
C     ------------------------------------------------------------------
C
C                       Use SYSTEM object access programs
C
C                       Obtain system node name during program execution
C     FUNC1 =
      CALL SYSTEM_INFO (FUNC1,HOSTID)
C
C                       Return number of bits per machine word
      CALL SYSTEM_BPW (IBPW)
C
C                       Get system-related info.: system type, date,
C                       time, or bytes per word
C     FUNC2 =
      CALL SYSTEM_SYSTUM (FUNC2,STR1)
C
C                       Return host system type
      CALL SYSTEM_TYPE (STR2)
C
C     ------------------------------------------------------------------
C
C                       Use TIMER object access programs
C
C                       Delay process execution
C     ISEC =
      CALL TIMER_SLEEP (ISEC,ILEFT,IERR00)
C                       Check if specified time has elapsed
      IF (ILEFT .EQ. 0) THEN
C       :
C                       Delay interrupted before specified time elapsed
      ELSE
C       :
      ENDIF
C
C
C                       Get system date
      CALL TIMER_DATE (STR3)
C
C                       Get system time
      CALL TIMER_TIME (STR4)
C
C                       Delay process execution
C     MILLI =
      CALL TIMER_WAIT (MILLI)
C
C     ------------------------------------------------------------------
C
C                       Use USER object access programs
C
C                       Get the user's user name from the system
      CALL USER_NAME (USRNAM)
C
C     ******************************************************************
C
C                       STEP 5  - Terminate program execution using
C                       PROCESS_EXIT
C
C     ------------------------------------------------------------------
C
C                       Use PROCESS_EXIT object access program
C
C                       Silently terminate program execution
      CALL PROCESS_EXIT ()
      END
STOP_CAT
echo "  Generating =====> [ ./system1.f ]"
cat <<"STOP_CAT"> ././system1.f
C     PROGRAM SYSTEM1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program SYSTEM_INFO
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SYSTEM object access programs
      EXTERNAL SYSTEM_INFO
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*40 STRING,STRNG1
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "SYSTEM" Object Demo Program #1'//
     * ' This demo uses SYSTEM_INFO to obtain the system node name.'/)
C
C     ******************************************************************
C
C                       Retrieve system information as needed using
C                       SYSTEM functions
C
C                       Get system node name
      CALL SYSTEM_INFO ('NAME',STRING)
C                       Append leading blank for carriage control
      STRNG1 = ' '//STRING
C
C                       Write system information to standard out
      CALL TERM_WRITE (' The system node name is:',0)
      CALL TERM_WRITE (STRNG1,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 SYSTEM Demo Program #1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./system2.f ]"
cat <<"STOP_CAT"> ././system2.f
C     PROGRAM SYSTEM2
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program SYSTEM_BPW
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SYSTEM object access programs
      EXTERNAL SYSTEM_BPW
C
C                       TERM object access programs
      EXTERNAL TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "SYSTEM" Object Demo Program #2'//
     * ' This demo uses SYSTEM_BPW to obtain the number of bits per'/
     * ' machine word.'/)
C
C     ******************************************************************
C
C                       Retrieve system information as needed using
C                       SYSTEM functions
C
C                       Get number of bits per machine word
      CALL SYSTEM_BPW (NBITPW)
C
C                       Write system information to standard out
      WRITE (IOUT,411) NBITPW
  411 FORMAT (' The number of bits per machine word is:',I4)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 SYSTEM Demo Program #2 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./system3.f ]"
cat <<"STOP_CAT"> ././system3.f
C     PROGRAM SYSTEM3
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program SYSTEM_TYPE
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       SYSTEM object access programs
      EXTERNAL SYSTEM_TYPE
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*40 STRING,STRNG1
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "SYSTEM" Object Demo Program #3'//
     * ' This demo uses SYSTEM_TYPE to obtain the host system type.'/)
C
C     ******************************************************************
C
C                       Retrieve system information as needed using
C                       SYSTEM functions
C
C                       Get host system type
      CALL SYSTEM_TYPE (STRING)
C                       Append leading blank for carriage control
      STRNG1 = ' '//STRING
C
C                       Write system information to standard out
      CALL TERM_WRITE (' The host system type is:',0)
      CALL TERM_WRITE (STRNG1,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 SYSTEM Demo Program #3 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./term1.f ]"
cat <<"STOP_CAT"> ././term1.f
C     PROGRAM TERM1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access programs TERM_GETERR,
C              TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_GETERR, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETERR, TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "TERM" Object Demo Program #1'/)
C
C     ------------------------------------------------------------------
C
C                       Get standard I/O logical unit numbers for
C                       use in console READ and WRITE statements
C                       explaining the use of standard I/O
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write prompt to standard out
      WRITE (IOUT,411,ERR=440) IOUT
  411 FORMAT (
     * ' POSIX TERM_SETSIO sets the FORTRAN logical unit numbers'/
     * ' of the standard input, output, and error devices (usually the'/
     * ' user console) on the given host system.'//
     * ' This message is being written to standard output on logical'/
     * ' unit number',I3, ' as set by TERM_SETSIO when the program'/
     * ' started.'/
     * ' '/
     * ' TERM_GETIN, TERM_GETOUT, and TERM_GETERR retrieve the'/
     * ' FORTRAN logical unit numbers of the standard input, output,'/
     * ' and error devices for use in FORTRAN I/O statements.'//
     * ' Please type any string of up to 80 characters:'/)
C
C     ------------------------------------------------------------------
C
C                       Get LUN of standard in using TERM_GETIN
      IN = TERM_GETIN ()
C                       Read value from standard in
      READ (IN,421,ERR=440) STRING
  421 FORMAT (A)
C
      WRITE (IOUT,431,ERR=440) STRING,IN
  431 FORMAT (/' The string you just typed:'//1X,A/
     * ' was read from standard input on logical unit number',I3,' as'/
     * ' set by TERM_SETSIO, then retrieved by TERM_GETIN for use in'/
     * ' the FORTRAN READ statement.'/)
C
C     ------------------------------------------------------------------
C
C                       Get LUN of standard error using TERM_GETERR
  440 IER = TERM_GETERR ()
      WRITE (IER,441) IER
  441 FORMAT (
     * ' Had anything gone wrong with the above input or output, this'/
     * ' error message would have been written to standard error on'/
     * ' logical unit',I3, ' as set by TERM_SETSIO, then retrieved'/
     * ' by TERM_GETERR for use in the FORTRAN WRITE statement.'/)
C
      WRITE (IOUT,451,ERR=440)
  451 FORMAT (
     * ' TERM_SETSIO can also redirect standard input, output, and'/
     * ' error data to a file rather than the user console by changing'/
     * ' the FORTRAN logical unit numbers assigned to standard input,'/
     * ' output, and error to those of one or more open files.')
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 TERM Demo Program #1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      READ (IN,811) STRING
  811 FORMAT(A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./term2.f ]"
cat <<"STOP_CAT"> ././term2.f
C     PROGRAM TERM2
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access programs TERM_CLEAR,
C              TERM_QUERY, TERM_WRITE, TERM_BELL, TERM_READ
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_CLEAR, TERM_GETIN, TERM_GETOUT, TERM_QUERY,
     *         TERM_WRITE, TERM_BELL, TERM_READ, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C                       Set terminal type of user console
      CALL TERM_QUERY (0)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
      CALL TERM_WRITE (
     * '                   PRL-POSIX "TERM" Object Demo Program #2',0)
C
C     ------------------------------------------------------------------
C
C                       How to use TERM to produce simple character-
C                       based user interfaces with less code syntax
C
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C                       Write message
      CALL TERM_WRITE (
     * ' You were just queried for a Console Device type to support',0)
      CALL TERM_WRITE (
     * ' clearing the screen later in the demo.',0)
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C                       Write message
      CALL TERM_WRITE (
     * ' TERM_WRITE can be used to write short messages like these.',0)
C
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C                       Write prompt
      CALL TERM_WRITE (
     * ' TERM_READ can be used to read text from standard input.',0)
      CALL TERM_WRITE (
     * ' Please type any string of up to 80 characters:',0)
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C
C                       Read string
      CALL TERM_READ (STRING,80)
C
C                       Clear the screen
      CALL TERM_CLEAR (0)
C                       Alert user
      CALL TERM_BELL
C                       Write message
      CALL TERM_WRITE (
     * ' The screen has just been cleared using TERM_CLEAR',0)
      CALL TERM_WRITE (
     * ' and the terminal bell was rung using TERM_BELL.',0)
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C                       Write message
      CALL TERM_WRITE (
     * ' The string you typed was read using TERM_READ',0)
      CALL TERM_WRITE (
     * ' and is being echoed back to you using TERM_WRITE:',0)
C                       Skip a line
      CALL TERM_WRITE (' ',1)
C                       Echo typed string
      CALL TERM_WRITE (' '//STRING,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 TERM Demo Program #2 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT(A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./timer1.f ]"
cat <<"STOP_CAT"> ././timer1.f
C     PROGRAM TIMER1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program TIMER_DATE
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C                       TIMER object access programs
      EXTERNAL TIMER_DATE
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*40 STRING,STRNG1
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "TIMER" Object Demo Program #1'//
     * ' This demo uses TIMER_DATE to obtain the system date.'/)
C
C     ******************************************************************
C
C                       Retrieve system information and affect process
C                       execution as needed using TIMER functions
C
C                       Get system date
      CALL TIMER_DATE (STRING)
C                       Prepend blank for carriage control
      STRNG1 = ' '//STRING
C
C                       Write system information to standard out
      CALL TERM_WRITE (' The system date is:',0)
      CALL TERM_WRITE (STRNG1,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 TIMER Demo Program #1 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./timer2.f ]"
cat <<"STOP_CAT"> ././timer2.f
C     PROGRAM TIMER2
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program TIMER_TIME
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C                       TIMER object access programs
      EXTERNAL TIMER_TIME
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*40 STRING,STRNG1
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "TIMER" Object Demo Program #2'//
     * ' This demo uses TIMER_TIME to obtain the system time.'/)
C
C     ******************************************************************
C
C                       Retrieve system information and affect process
C                       execution as needed using TIMER functions
C
C                       Get system time
      CALL TIMER_TIME (STRING)
C                       Prepend blank for carriage control
      STRNG1 = ' '//STRING
C
C                       Write system information to standard out
      CALL TERM_WRITE (' The system time is:',0)
      CALL TERM_WRITE (STRNG1,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 TIMER Demo Program #2 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./timer3.f ]"
cat <<"STOP_CAT"> ././timer3.f
C     PROGRAM TIMER3
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program TIMER_SLEEP
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_GETERR,
     *         TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT, TERM_GETERR
C
C                       TIMER object access programs
      EXTERNAL TIMER_SLEEP
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*80 STRING
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "TIMER" Object Demo Program #3'//
     * ' This demo uses TIMER_SLEEP to delay process execution.')
C
C     ******************************************************************
C
C                       Use TERM functions to query for time delay
C
C                       Write prompt to standard out
  410 WRITE (IOUT,411,ERR=413) 'Enter number of seconds to delay (1-9):'
  411 FORMAT (/' ',A)
C
C                       Get LUN of standard in using TERM_GETIN
      IN = TERM_GETIN ()
C                       Read value from standard in
      READ (IN,412,ERR=413) ISEC
  412 FORMAT (I1)
      GOTO 420
C                       Get LUN of standard error using TERM_GETERR
  413 IER = TERM_GETERR ()
      WRITE (IER,411) 'Value must be a number from 1 to 9'
      GOTO 410
C
C                       Write message
  420 WRITE (IOUT,421) ISEC
  421 FORMAT (' Commencing delay of',I3,' seconds')
C
C     ******************************************************************
C
C                       Use TIMER functions to delay process execution
C
C                       Delay process execution for specified number of
C                       seconds (IERROR always zero on return)
      CALL TIMER_SLEEP (ISEC,ILEFT,IERROR)
C                       Specified time elapsed
      IF (ILEFT .EQ. 0) THEN
C                       Write message when delay completed
        WRITE (IOUT,521) ISEC
  521   FORMAT (' Delay of',I3,' seconds completed')
C                       Delay interrupted before specified time elapsed
      ELSE
        WRITE (IOUT,531) ISEC,ILEFT
  531   FORMAT (
     *  ' Delay of',I3,' seconds interrupted with ',I3,' seconds to go')
      ENDIF
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 TIMER Demo Program #3 Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  Generating =====> [ ./user1.f ]"
cat <<"STOP_CAT"> ././user1.f
C     PROGRAM USER1
C
C       Programmer's Reusable Library, Version 0.7      (TM)
C
C            Copyright (C) 1995 Object Access (SM)
C
C     Permission is granted to any individual or institution
C     to use, copy, modify, and distribute this single program
C     unit, provided that this complete copyright and
C     permission notice is maintained, intact, in all copies.
C
C     Object Access Incorporated provides this software
C     "as is" without express or implied warranty.
C
C     PURPOSE: Demonstrate and test access program USER_NAME
C
C     LOCAL VARIABLES:
C
C
C     NOTES:  None
C
C     ******************************************************************
C
C                       POSIX object access programs
      EXTERNAL POSIX_INIT, PRL_LIBVER
C
C                       PROCESS object access programs
      EXTERNAL PROCESS_EXIT
C
C                       USER object access programs
      EXTERNAL USER_NAME
C
C                       TERM object access programs
      EXTERNAL TERM_WRITE, TERM_GETIN, TERM_GETOUT, TERM_SETSIO
C
      INTEGER  TERM_GETIN, TERM_GETOUT
C
C     ------------------------------------------------------------------
C
C                       Standard input logical unit for the system
      PARAMETER (LUNSI=5)
C                       Standard output logical unit for the system
      PARAMETER (LUNSO=6)
C                       Standard error logical unit for the system
      PARAMETER (LUNSE=6)
C
C                       Library version numbers (actual & required)
      CHARACTER*8  VERAQ,VERRQ
C                       Character string
      CHARACTER*80 STRING,STRNG1
C
C                       Required PRL version number (update DATA value
C                       when program updated to new version of library)
      DATA VERRQ /'0.7     '/
C
C     ******************************************************************
C
C                       STEP 1 - Initialize library
C
      CALL POSIX_INIT (0)
C
C     ******************************************************************
C
C                       STEP 2 - Check PRL version
C
C                       Get actual PRL version being used
      CALL PRL_LIBVER (VERAQ,VERRQ)
C
C     ******************************************************************
C
C                       STEP 3 - Set standard I/O LUNs and terminal type
C
C                       Set standard I/O LUNs for the system
      CALL TERM_SETSIO (LUNSI,LUNSO,LUNSE)
C
C                       (TERM_QUERY not used to get terminal type of
C                       user console since TERM_CLEAR is not used
C                       to clear the screen in this demo)
C
C     ******************************************************************
C
C                       STEP 4 - Use Library Objects as Needed
C
C     ******************************************************************
C
C                       Write demo program introduction message
C
C                       Get LUN of standard out using TERM_GETOUT
      IOUT = TERM_GETOUT ()
C                       Write intro message
      WRITE (IOUT,401)
  401 FORMAT (
     * '                   PRL-POSIX "USER1" Object Demo Program'//
     * ' This demo uses USER_NAME to obtain the user login name.'/)
C
C     ******************************************************************
C
C                       Retrieve system information as needed using
C                       USER functions
C
C                       Get username associated with executing process
      CALL USER_NAME (STRING)
C                       Prepend blank for carriage control
      STRNG1 = ' '//STRING
C
C                       Write system information to standard out
      CALL TERM_WRITE (' The user login name is:',0)
      CALL TERM_WRITE (STRNG1,0)
C
C     ******************************************************************
C
C                       STEP 5 - Terminate program execution
C
C                       Wait until user presses a key before exiting
      IOUT = TERM_GETOUT ()
      WRITE (IOUT,810)
  810 FORMAT (/
     * '                 USER1 Demo Program Execution Completed'/
     * '                         Press <CR> to exit demo')
      IN = TERM_GETIN ()
      READ (IN,811) STRING
  811 FORMAT (A)
C                       Exit demo
      CALL PROCESS_EXIT
      END
STOP_CAT
echo "  <CR> to Continue"
read answer
cat <<STOP_CAT> ./compile
echo "
 
  Compiling and linking demo programs.
 "
echo "  Compiling ======> [ ./file1.f ]"
$LINK ./file1.f -o ./file1.x $POSIX
chmod 0770 ./file1.x
echo "  Compiling ======> [ ./file2.f ]"
$LINK ./file2.f -o ./file2.x $POSIX
chmod 0770 ./file2.x
echo "  Compiling ======> [ ./file3.f ]"
$LINK ./file3.f -o ./file3.x $POSIX
chmod 0770 ./file3.x
echo "  Compiling ======> [ ./file4.f ]"
$LINK ./file4.f -o ./file4.x $POSIX
chmod 0770 ./file4.x
echo "  Compiling ======> [ ./filedat1.f ]"
$LINK ./filedat1.f -o ./filedat1.x $POSIX
chmod 0770 ./filedat1.x
echo "  Compiling ======> [ ./pcons1.f ]"
$LINK ./pcons1.f -o ./pcons1.x $POSIX
chmod 0770 ./pcons1.x
echo "  Compiling ======> [ ./posix1.f ]"
$LINK ./posix1.f -o ./posix1.x $POSIX
chmod 0770 ./posix1.x
echo "  Compiling ======> [ ./prl1.f ]"
$LINK ./prl1.f -o ./prl1.x $POSIX
chmod 0770 ./prl1.x
echo "  Compiling ======> [ ./process1.f ]"
$LINK ./process1.f -o ./process1.x $POSIX
chmod 0770 ./process1.x
echo "  Compiling ======> [ ./signal1.f ]"
$LINK ./signal1.f -o ./signal1.x $POSIX
chmod 0770 ./signal1.x
echo "  Compiling ======> [ ./signal2.f ]"
$LINK ./signal2.f -o ./signal2.x $POSIX
chmod 0770 ./signal2.x
echo "  Compiling ======> [ ./system1.f ]"
$LINK ./system1.f -o ./system1.x $POSIX
chmod 0770 ./system1.x
echo "  Compiling ======> [ ./system2.f ]"
$LINK ./system2.f -o ./system2.x $POSIX
chmod 0770 ./system2.x
echo "  Compiling ======> [ ./system3.f ]"
$LINK ./system3.f -o ./system3.x $POSIX
chmod 0770 ./system3.x
echo "  Compiling ======> [ ./term1.f ]"
$LINK ./term1.f -o ./term1.x $POSIX
chmod 0770 ./term1.x
echo "  Compiling ======> [ ./term2.f ]"
$LINK ./term2.f -o ./term2.x $POSIX
chmod 0770 ./term2.x
echo "  Compiling ======> [ ./timer1.f ]"
$LINK ./timer1.f -o ./timer1.x $POSIX
chmod 0770 ./timer1.x
echo "  Compiling ======> [ ./timer2.f ]"
$LINK ./timer2.f -o ./timer2.x $POSIX
chmod 0770 ./timer2.x
echo "  Compiling ======> [ ./timer3.f ]"
$LINK ./timer3.f -o ./timer3.x $POSIX
chmod 0770 ./timer3.x
echo "  Compiling ======> [ ./user1.f ]"
$LINK ./user1.f -o ./user1.x $POSIX
chmod 0770 ./user1.x
echo "
 
  All demo programs have been compiled.
 "
Proceed="No"
while [ "\$Proceed" = "No" ]
do
echo "
 
  Delete demo program source?
  ( Y or N )
 "
read answer
if [ "\$answer" = "y" ]; then
  Proceed="Yes"
  echo "
  All demo programs are being deleted"
  rm ./*.f
  rm ./*.uuu 2>/dev/null
  rm ./*.INC 2>/dev/null
else
  if [ "\$answer" = "Y" ]; then
    Proceed="Yes"
    echo "
  All demo programs are being deleted"
    rm ./*.f
    rm ./*.uuu 2>/dev/null
    rm ./*.INC 2>/dev/null
  fi
fi
if [ "\$answer" = "n" ]; then
  Proceed="Yes"
else
  if [ "\$answer" = "N" ]; then
    Proceed="Yes"
  fi
fi
echo "  <CR> to Continue"
read answer
done
STOP_CAT
chmod 770 ./compile
cat <<"STOP_CAT"> ./run_demo
(tput) 1>/dev/null 2>&1
if [ $? = 1 ]; then
  CLEAR="clear"; export CLEAR
else
  CLEAR="tput clear"; export CLEAR
fi
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

 
  PRL-POSIX demonstration programs. These programs
  test and demonstrate the capabilities of the
  PRL-POSIX library.
 
  <CR> to Continue"
read answer
while [ 1 -eq 1 ]; do
$CLEAR
echo "
 Select Demo Program
 ===================
   1 ./_posix.tk   2 ./file1       3 ./file2       4 ./file3                    
   5 ./file4       6 ./filedat1    7 ./pcons1      8 ./posix1                   
   9 ./prl1       10 ./process1   11 ./signal1    12 ./signal2                  
  13 ./system1    14 ./system2    15 ./system3    16 ./term1                    
  17 ./term2      18 ./timer1     19 ./timer2     20 ./timer3                   
  21 ./user1                                                                    
 
   x. Exit, delete demo executables
   s. Exit, save demo executables"
read answer
$CLEAR
case "$answer" in
  "x") rm ./*.o ./*.x ./*.tk ./*.dat ./*.inp 2>/dev/null; break;;
  "s") rm ./*.o 2>/dev/null; break;;
  1) wish -f ./_posix.tk;;
  2) ./file1.x;;
  3) ./file2.x;;
  4) ./file3.x;;
  5) ./file4.x;;
  6) ./filedat1.x;;
  7) ./pcons1.x;;
  8) ./posix1.x;;
  9) ./prl1.x;;
 10) ./process1.x;;
 11) ./signal1.x;;
 12) ./signal2.x;;
 13) ./system1.x;;
 14) ./system2.x;;
 15) ./system3.x;;
 16) ./term1.x;;
 17) ./term2.x;;
 18) ./timer1.x;;
 19) ./timer2.x;;
 20) ./timer3.x;;
 21) ./user1.x;;
  *) echo "Invalid Choice
 
  <CR> to Continue"
read answer;;
esac
done
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

 
       For more information contact:
 
         Object Access
         2023 Leisure Lane
         League City, TX  77573
 
         e-mail:   oa@iah.com
         homepage: http://www.iah.com/oa
         phone:    713-332-7281, 713-554-7617
 
 "
STOP_CAT
chmod 770 ./run_demo
if [ "$SYSID" = "" ]; then
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

  If you had selected a supported system, the demos
  would be installed automatically now.  Since you
  did not, you must perform the following procedures
  to complete the demo installation:
 
  1. Compile the demo programs using the FORTRAN command
     for your system, or by executing the 'compile' 
     script by typing its name.
 
  2. Execute the demo programs by typing 'run_demo'
 
  "
else
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

  All files required to run the demo programs are
  prepared.  If you wish to continue, press ENTER.
  To stop and continue manually, type any character
  and press ENTER.
 
  <CR> to Continue"
read answer
$CLEAR
if [ "$answer" = "" ]; then
  ./compile
  rm ./compile
  ./run_demo
else
$CLEAR
echo "
                    Object Access
            Programmer's Reusable Library
                        POSIX
 

  If you had elected to proceed, the demos
  would be installed automatically now.  Since you
  did not, you must perform the following procedures
  to complete the demo installation:
 
  1. Compile the demo programs using the FORTRAN command
     for your system, or by executing the 'compile' 
     script by typing its name.
 
  2. Execute the demo programs by typing 'run_demo'
 
  "
fi
fi
