Trailing-Edge
-
PDP-10 Archives
-
decuslib10-07
-
43,50433/getfil.mac
There are 2 other files named getfil.mac in the archive. Click here to see a list.
title GETFIL - dirty work for the PROGRAM statement
entry getfn.,ttypr.
search pasunv
twoseg
reloc 400000
maxwd==20 ;number of words used to store user's input
maxlen==5*maxwd
file==maxwd+1
defspc==maxwd+2
t0=0
t1=1
t2=2
t3=3
t4=4
d=16 ;display
p=17 ;main pdl
filnam==14
fileof==1
getfn.:: ;t2 = pointer to file block
push p,d ;standard PASCAL entry sequence
hrls d,p
hrri p,maxwd+4(p)
caig 15,40(p)
jsp t1,corerr##
pushj p,initb.## ;block can't possibly be init yet
movem t3,defspc(d) ;save name as default
move t1,[point 7,(t3)] ;filename is here
movei t4,^D10 ;and is this long
wrloop: ildb t0,t1 ;use it to prompt user
outchr t0
sojg t4,wrloop
outstr [asciz / : /]
getstr: move t1,[point 7,1(16)] ;now read spec from user - put here
movei t4,0 ;t4 = counter of char's
getnew: inchwl t0
caie t0,12 ;check for end of line
cain t0,33
jrst readon
caie t0,32
cain t0,14
jrst readon
caig t0,40 ;otherwise ignore funny char's
jrst getnew ;so t4.gt.0 only if something there
addi t4,1 ;not eol - count it
caile t4,maxlen
jrst toolng ;error if too long
idpb t0,t1 ;else save it away
jrst getnew ;and get next char
toolng: outstr [asciz /
? File spec too long - try again:
/]
clrbfi
jrst getstr
badnam: outstr [asciz /
? Illegal file spec - try again:
/]
clrbfi
jrst getstr
readon: movei t3,1(16) ;starting addr of string
jumple t4,usedef ;null spec - use default
movem t2,file(d)
pushj p,parse## ;other arg's are OK
move t2,file(d)
skipe fileof(t2) ;see if valid name
jrst badnam ;no - try again
done: hrri p,(d) ;standard exit code
pop p,d
popj p,
usedef: ;here if he defaults spec
caie t2,input## ;for input
cain t2,output## ;and output
jrst usedf1 ;default to tty:
move t3,defspc(d) ;saved address of default
movei t4,6 ;length
jrst usedf2
usedf1: movei t3,[asciz /TTY:/]
movei t4,4
usedf2: pushj p,parse## ;convert it
jrst done ;if still error, ignore it
;ttypr. - do initial get for INPUT
ttypr.: move t0,input##+fildev ;t0 _ this device
devnam t0,
jrst ttyprg ;failed, assume not our tty
getlin t1, ;t1 _ controlling terminal
came t0,t1 ;do the prompt only if the same
jrst ttyprg
outstr [asciz /[INPUT, end with ^Z: ]
/]
ttyprg: movei t2,input##
jrst getch##
end