h26214
s 00001/00001/00089
d D 1.15 83/03/06 20:49:34 mjb 15 14
c 
e
s 00001/00001/00089
d D 1.14 83/03/03 22:33:31 mjb 14 13
c 
e
s 00005/00008/00085
d D 1.13 83/03/03 18:46:20 mjb 13 12
c put in check for single graph recalls in multi graph mode
e
s 00001/00001/00092
d D 1.12 83/02/14 18:10:41 mjb 12 11
c 
e
s 00001/00000/00092
d D 1.11 83/02/14 14:08:20 mjb 11 10
c added sflag to tell when absolutely necessary to save current graph
e
s 00002/00002/00090
d D 1.10 83/02/11 12:57:49 mjb 10 9
c fixed common bliock problem
e
s 00006/00002/00086
d D 1.9 83/02/10 23:18:48 mjb 9 8
c 
e
s 00001/00001/00087
d D 1.8 83/02/03 00:51:22 tes 8 7
c modified apdata interface to include last item to display
e
s 00000/00000/00088
d D 1.7 83/02/01 19:29:59 mjb 7 6
c fixed problem with checking for 0 file descriptors
e
s 00016/00051/00072
d D 1.6 83/01/31 16:22:01 mjb 6 5
c fixed and implemented multi file error reporting
e
s 00025/00011/00098
d D 1.5 83/01/30 18:29:53 mjb 5 4
c error reporting bug fixing
e
s 00064/00019/00045
d D 1.4 83/01/29 16:38:11 mjb 4 3
c made changes for save restore of multi files and error reporting
e
s 00001/00001/00063
d D 1.3 83/01/28 23:29:38 tes 3 2
c modified apmenu interface to include a clear screen flag
e
s 00002/00002/00062
d D 1.2 83/01/20 14:44:54 mjb 2 1
c modified for multiple graphs
e
s 00064/00000/00000
d D 1.1 83/01/20 11:15:23 tes 1 0
c date and time created 83/01/20 11:15:23 by tes
e
u
tes
mjb
U
t
T
I 1
D 4
subroutine savrst (mode, buffer, length)
E 4
I 4
D 13
subroutine savrst (mode)
E 13
I 13
subroutine savrst (mode, type)
E 13
E 4
########################################################################
#                                                                      #
#          THIS MATERIAL IS CONFIDENTIAL AND IS FURNISHED UNDER        #
#          A WRITTEN LICENSE AGREEMENT.  IT MAY NOT BE USED,           #
#          COPIED OR DISCLOSED TO OTHERS EXCEPT IN ACCORDANCE          #
#          WITH THE TERMS OF THAT AGREEMENT.                           #
#                                                                      #
#          COPYRIGHT (C) 1982 GRAPHIC SOFTWARE SYSTEMS INC.            #
#          ALL RIGHTS RESERVED.                                        #
#                                                                      #
#     Function: Output Save or Restore menus and then call rdwrit      #
#                                                                      #
#     Input Parameters:                                                #
#            mode - mode to open file in                               #
I 13
#            type - type of file to recall (1 = either, 2 = multi)     #
E 13
D 4
#            buffer - buffer to read or write from                     #
#            length - number of bytes to read or write                 #
E 4
#                                                                      #
#     Output Parameters:                                               #
#            None                                                      #
#                                                                      #
#     Routines Called:                                                 #
#            rdwrit - read or write to a file                          #
#                                                                      #
########################################################################
D 4
SHORTINT buffer(1)
integer mode, length
E 4
I 4
D 13
integer mode
E 13
I 13
integer mode, type
E 13
E 4

D 4
# ********************************************************
#    following three lines are part of 'mnucom' needed by
#    this routine
# ********************************************************
SHORTINT dtamod
integer crntid, dtaptr, chcptr
SHORTINT dtabfr(FIELDxDATAxSIZE), chcbfr(CHOICExDATAxSIZE)
E 4
I 4
D 6
integer i, kmode, done, length, fildes, sector, offset
SHORTINT fname(14), escape, locbf1(3), locbf2(3), badfil
ifdef(`UNIX',`character*14 ufname')
E 6
I 6
integer i, kmode, done, length, fileck, errnum
SHORTINT fname(14), escape
E 6
E 4

D 4
integer i, kmode, done, rdwrit
SHORTINT fname(14), escape
E 4
I 4
D 6
integer gdopen, gdclos, gdseek, gdread
E 4

E 6
D 4
include(`allcom')
E 4
I 4
include(`gphcom')
E 4

D 4
common /cfddis/ crntid, dtaptr, chcptr, dtamod, dtabfr, chcbfr
E 4
I 4
D 6
equivalence (locbf1(2), length)
E 4

E 6
done = -1
D 4
dtamod = ON
E 4

I 4
D 5
call setmod (ON)
E 5
I 5
kmode = mode
if (mode > 2) kmode = mode - 3
E 5

E 4
repeat {
D 5
   kmode = mode
D 2
   if (mode > 3) kmode = mode - 3
E 2
I 2
   if (mode > 2) kmode = mode - 3
E 5
I 4
D 6

E 6
I 5
   call setmod (ON)

E 5
E 4
E 2
   if (kmode > ASCIIxREAD) i = SAVExFILExNAMExPROMPT
   else                    i = RESTORExFILExNAMExPROMPT
I 4

E 4
D 3
   call apmenu (i)
E 3
I 3
   call apmenu (i, YES)
E 3
D 2
   call apdata
E 2
I 2
D 8
   call apdata (1)
E 8
I 8
   call apdata (1, FOREVER)
E 8
E 2
D 15
   escape = LF
E 15
I 15
   ifdef(`UNIX',`escape = LF',`escape = CR')
E 15
   call managd (escape)
I 4

E 4
   call qgeta (1, fname) # get the user's file name
   if (fname(1) == NUL) return
D 4
   done = rdwrit (mode, fname, buffer, length)
E 4
I 4

D 6
   ifdef(`UNIX',`
      do i = 1,14 {
         ufname(i:i) = char (fname(i))
         }
      ')
   ifdef(`UNIX',
      `fildes = gdopen (ufname, mode)',
      `fildes = gdopen (fname, mode)')
E 6
I 6
D 13
   errnum = fileck (mode, fname, length)
E 13
I 13
   errnum = fileck (mode, type, fname, length)
E 13
E 6

D 5
   if (fildes <= 0) {         # Cannot open file
E 5
I 5
D 6
   if (fildes <= 0) {                 # Cannot open file
E 5
      call errmsg (PAUSE, CANNOTxOPENxFILExERROR)
E 6
I 6
D 13
   if (errnum == CANNOTxOPENxFILExERROR) {    # Cannot open file
      call errmsg (PAUSE, errnum)
E 6
      }
I 5

E 5
D 6
   else {
E 6
I 6
   else if (errnum == CORRUPTxFILExERROR) {   # Corrupted file error
E 13
I 13
D 14
   if (errnum == YES) {    # error occured
E 14
I 14
   if (errnum != YES) {    # error occured
E 14
E 13
      call errmsg (PAUSE, errnum)
      }
E 6
D 5
      if (kmode > ASCIIxREAD) {       # Must be a save
E 5
I 5

D 6
      if (kmode > ASCIIxREAD) {       # Save the appropriate file
E 6
I 6
   else {                                      # Must be ok 
      if (kmode > ASCIIxREAD) {                # Save the appropriate file
I 11
D 12
	 bgsave == NO                          # Set save flag to no
E 12
I 12
	 bgsave = NO                           # Set save flag to no
E 12
E 11
E 6
E 5
         if (multfg > 1)
	    call rdwrit (mode, fname, multfg, MULTxSIZE)
         else
D 10
	    call rdwrit (mode, fname, bgtitl, GPHCOMxSIZE)
E 10
I 10
	    call rdwrit (mode, fname, zlegxy, GPHCOMxSIZE)
E 10
         done = 0
         }
I 5

E 5
D 6
      else {                          # Must be a restore
D 5
         i = gdread (fildes, locbf1, 3)      # Read header
	 sector = length / 128
	 offset = length - (sector * 128)    # Skip over file
E 5
I 5

	 do i = 1, 3 {                # Initialize local buffers 
	    locbf1(i) = NUL           # to some known state 
	    locbf2(i) = NUL  
	    }

         i = gdread (fildes, locbf1, HEADERxLENGTH)      # Read header

	 sector = (length+HEADERxLENGTH) / 128
	 offset = (length+HEADERxLENGTH) - (sector * 128)# Skip over file
E 5
	 i = gdseek (fildes, sector, offset)
D 5
         i = gdread (fildes, locbf2, 3)      # Read trailer
E 5
I 5

         i = gdread (fildes, locbf2, HEADERxLENGTH)      # Read trailer

E 5
	 badfil = NO
	 do i = 1, 3 {                       # Check for corrupted file
	    if (locbf1(i) != locbf2(i)) badfil = YES
	    }
         if (badfil == YES) {
	    call errmsg (PAUSE, CORRUPTxFILExERROR)
	    i = gdclos (fildes)
	    }
D 5
         else {
E 5
I 5

         else {                              # Restore appropriate file
E 5
	    if (multfg > 1)
	       call rdwrit (mode, fname, multfg, length)
	    else
	       call rdwrit (mode, fname, bgtitl, length)
	    done = 0
	    }
E 6
I 6
      else {                                    # Must be a restore
D 9
         if (length < GPHCOMxSIZE)              # restore appropriate file
E 9
I 9
         if (length < GPHCOMxSIZE) {            # restore appropriate file
E 9
            call rdwrit (mode, fname, multfg, length)
D 9
         else   
E 9
I 9
	    }
         else { 
E 9
D 10
	    call rdwrit (mode, fname, bgtitl, length)
E 10
I 10
	    call rdwrit (mode, fname, zlegxy, length)
E 10
I 9
	    multfg = 1
	    mfrmat = 6
	    }
E 9
	 done = 0
E 6
         }
      }
E 4
   } until (done == 0)

D 4
dtamod = OFF
E 4
I 4
call setmod (OFF)
E 4

I 4
return
end
subroutine setmod (mode)
D 5
SHORTINT mode
E 5
I 5
integer mode
E 5
include(`mnucom')
dtamod = mode
E 4
return
end
E 1
