home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpm
/
cug
/
softt-3.lbr
/
PRIM-I.QQQ
/
PRIM-I.
Wrap
Text File
|
1984-07-05
|
8KB
|
266 lines
#-h- index 240 local 09/22/80 15:38:58
# index - find character c in string str
integer function index (str, c)
character str (ARB), c
for (index = 1; str (index) != EOS; index = index + 1)
if (str (index) == c)
return
index = 0
return
end
#-t- index 240 local 09/22/80 15:38:58
#-h- initst 4393 local 09/22/80 15:38:36
# initst - initialize variables and I/O for software tools programs
subroutine initst
character input (FILENAMESIZE),
output (FILENAMESIZE),
errout (FILENAMESIZE),
buf (MAXLINE)
integer i, outacc, erracc
integer getarg, assign, insub, outsub, errsub
filedes open
# include args
## common block used to hold command line argument information
# Put on a file called 'args'
common /args/ nbrarg, ptr (MAXARGS), arg (ARGBUFSIZE)
integer nbrarg #number arguments in list; initialize to 0
integer ptr #pointers (into 'arg') for each argument
character arg #arguments stored as ascii strings terminated
#with EOS markers
# include io
## io - common block holding I/O information for portable primitives
# put on a file called 'io'
common /io/ unit (MAXOFILES), lastc (MAXOFILES), ccnt (MAXOFILES),
filacc (MAXOFILES), mode (MAXOFILES), ftype (MAXOFILES),
filenm (FILENAMESIZE, MAXOFILES),
buffer (MAXLINE, MAXOFILES)
integer unit # fortran unit number
integer lastc # pointer to last character in unit's buffer
integer ccnt # number characters read/written in file
# (used only by seek)
integer filacc # access used to open file
# (READ, WRITE, READWRITE, or APPEND)
integer mode # device mode (DISK or TERMINAL)
integer ftype # file type (LOCAL, ASCII, BINARY)
character filenm # file name associated with unit
character buffer # line buffer for unit
# Set default output and errout access types (WRITE or APPEND)
data outacc /WRITE/
data erracc /WRITE/
#----------------------------------------------------------------
#
# These initializations are done with substitutions rather than
# data or block data statements to avoid the problem of block
# data programs.
#
#----------------------------------------------------------------
# Initialize command line argument count
# (Located in /args/)
nbrarg = 0
# Initialize fortran units for I/O
# (These are located in the 'io' common block
# Change these to units appropriate to your machine
# This is STDIN (1)
unit (STDIN) = STDINUNIT
mode (STDIN) = TERMINAL # TERMINAL or DISK
ftype (STDIN) = LOCAL # File type - LOCAL, ASCII, or BINARY
# This is STDOUT (2)
unit (STDOUT) = STDOUTUNIT
mode (STDOUT) = TERMINAL # TERMINAL or DISK
ftype (STDOUT) = LOCAL # File type - LOCAL, ASCII, or BINARY
# This is ERROUT (3)
unit (ERROUT) = ERROUTUNIT
mode (ERROUT) = TERMINAL # TERMINAL or DISK
ftype (ERROUT) = LOCAL # File type - LOCAL, ASCII, or BINARY
# Any unit is OK here
unit (4) = UNITA
mode (4) = DISK # TERMINAL or DISK
ftype (4) = LOCAL # File type - LOCAL, ASCII, or BINARY
# This is UNITB (any unit)
unit (5) = UNITB
mode (5) = DISK # TERMINAL or DISK
ftype (5) = LOCAL # File type - LOCAL, ASCII, or BINARY
# This is UNITC (any unit)
unit (6) = UNITC
mode (6) = DISK # TERMINAL or DISK
ftype (6) = LOCAL # File type - LOCAL, ASCII, or BINARY
# initialize default standard files
call termin (input)
call trmout (output)
call trmout (errout)
# initialize /io/ common block variables
for (i = 1; i <= MAXOFILES; i = i + 1)
filenm (1, i) = EOS
# set up list of command arguments
call makarg
# pick up file substitutions for standard files
for (i=1; getarg (i, buf, MAXLINE) != EOF; ) {
if (insub (buf,input) == YES |
outsub (buf,output, outacc) == YES |
errsub (buf, errout, erracc) == YES )
call delarg (i)
else
i = i + 1
}
# open standard input, output, and errout files
if (assign (errout, ERROUT, erracc) == ERR)
call endst # can't print error message cause no ERROUT file
if (assign (input, STDIN, READ) == ERR)
call cant (input)
if (assign (output, STDOUT, outacc) == ERR)
call cant (output)
return
end
#-h- initst 4393 local 09/22/80 15:38:36
#-h- inmap 237 local 09/22/80 15:39:00
# inmap - convert hollerith characters to ascii
character function inmap (c)
character c
# You must supply your own version of INMAP here, or
# use the Fortran version developed in the test of COPY
return (c)
end
#-t- inmap 237 local 09/22/80 15:39:00
#-h- insub 276 local 09/22/80 15:38:46
# insub - determine if argument is STDIN substitution
integer function insub (arg, file)
character arg (ARB), file (ARB)
if (arg (1) == LESS & arg (2) != EOS) {
insub = YES
call scopy (arg, 2, file, 1)
}
else
insub = NO
return
end
#-t- insub 276 local 09/22/80 15:38:46
#-h- isatty 1107 local 09/22/80 15:38:37
# isatty - determine if file is a teletype/CRT device
integer function isatty (int)
filedes int
# include io
## io - common block holding I/O information for portable primitives
# put on a file called 'io'
common /io/ unit (MAXOFILES), lastc (MAXOFILES), ccnt (MAXOFILES),
filacc (MAXOFILES), mode (MAXOFILES), ftype (MAXOFILES),
filenm (FILENAMESIZE, MAXOFILES),
buffer (MAXLINE, MAXOFILES)
integer unit # fortran unit number
integer lastc # pointer to last character in unit's buffer
integer ccnt # number characters read/written in file
# (used only by seek)
integer filacc # access used to open file
# (READ, WRITE, READWRITE, or APPEND)
integer mode # device mode (DISK or TERMINAL)
integer ftype # file type (LOCAL, ASCII, BINARY)
character filenm # file name associated with unit
character buffer # line buffer for unit
if (mode (int) == TERMINAL)
isatty = YES
else
isatty = NO
return
end
#-t- initst 4393 local 09/22/80 15:38:36
#-h- itoc 1033 local 09/22/80 15:38:59
# itoc - convert integer int to char string in str
integer function itoc (int, str, size)
integer int, size
character str (ARB)
integer mod
integer d, i, intval, j, k
# string digits "0123456789"
character digits (11)
data digits (1) /DIG0/,
digits (2) /DIG1/,
digits (3) /DIG2/,
digits (4) /DIG3/,
digits (5) /DIG4/,
digits (6) /DIG5/,
digits (7) /DIG6/,
digits (8) /DIG7/,
digits (9) /DIG8/,
digits (10) /DIG9/,
digits (11) /EOS/
intval = iabs (int)
str (1) = EOS
i = 1
repeat { # generate digits
i = i + 1
d = mod (intval, 10)
str (i) = digits (d+1)
intval = intval / 10
} until (intval == 0 | i >= size)
if (int < 0 & i < size) { # then sign
i = i + 1
str (i) = MINUS
}
itoc = i - 1
for (j = 1; j < i; j = j + 1) { # then reverse
k = str (i)
str (i) = str (j)
str (j) = k
i = i - 1
}
return
end
#-t- itoc 1033 local 09/22/80 15:38:59
int, size