home *** CD-ROM | disk | FTP | other *** search
- /* POP.rexx */
-
- /*
- Format
-
- POP [TO <n>] [LIST] [CLEAR]
-
- List directories on stack, or "pop to" a given number on the stack.
- Can clear stack as well
-
- */
-
- signal off failure; signal off error; signal on syntax; signal on break_c
- call addlib 'rexxextra.library',-20,-30,0
-
- facility = 'POP'
- retcode = 0
-
- dtemplate = 'TO/K,CLEAR/S'
- template = 'TO/K,CLEAR/S'
- args. = ''
-
- parse arg g_c
- do while g_c='?'
- options prompt dtemplate': ' /* this template is */
- parse pull g_c /* displayed to the user */
- if g_c='?' then do
- g_s=sourceline(3)
- if pos('/*',g_s)=0 then break; if pos('*/',g_s)>0 then break
- say
- g_s=sourceline(4)
- do i=5 while pos('*/',g_s)=0; say g_s; g_s=sourceline(i); end
- say
- end
- end
- interpret Cparse(g_c,template,'args')
- if args.ERRCODE > 1 then do; say facility'-E-BADARGS,' args.ERRTEXT; exit 5; end
-
- 'cd | Execio var odir'
- cd. = odir
-
- if args.CLEAR then do
- do until rc > 0
- 'popcd >NIL:'
- end
- 'cd' odir
- signal GetOut
- end
-
- n = 0
- 'popcd >NIL:'
- if rc > 0 then do
- say 'Nothing to "pop"'
- exit 5
- end
- do while rc = 0
- 'cd | Execio var x'
- n = n + 1
- cd.n = x
- 'popcd >NIL:'
- end
-
- if args.TO ~= '' then do
- do i = n-1 to 1 by -1
- 'pushcd' cd.i
- end
- i = args.TO
- 'pushcd' odir
- 'pushcd' cd.i
- end
- else do
- say right(n,4)||' '||cd.n
- do i = n-1 to 1 by -1
- say right(i,4)||' '||cd.i
- 'pushcd' cd.i
- end
- 'pushcd' odir
- end
-
- GetOut:
- exit retcode
-
- break_c:
- break_d:
- break_e:
- break_f:
- say facility'-E-BREAK, Control-C interrupt'
- exit 20
- failure:
- say facility'-E-FAIL, Line:' sigl', Error:' rc; retcode = rc; signal GetOut
- syntax:
- say facility'-E-SYNTAX, Line:' sigl', Error:' rc; retcode = rc; signal GetOut
- error:
- say facility'-E-ERROR, Line:' sigl', Error:' rc; retcode = rc; signal GetOut
-
-