On 2016-07-12 11:04, Andreas Fischer wrote:
is it possible to retrieve the last ispf command within an edit macro written
in rexx? i had a brief look in ibm's documentation but didn't found anything
helpful. since you can use the retrieve command in panel dialogs the data
must be stored somewhere...
Andi, all,
I've got something using control block chasing which works, well at least sort
of - it was written AD 2007, and although I still use it, it no longer seems to
find all executed commands, maybe someone else can have a look at it and create
a version that works better. It comes from the now defunct mvshelp.net site and
I changed it to make it completely self contained:
/* REXX exec to read the ISPF command stack */
/*** trace ?r ***************************************************** \| *
* (C) Copyright Rainer Bartosch, 2007-2009 *
************************************************************************
* ------------------------------------------------------------------ *
* | Date | By | Remarks | *
* |------------+------+----------------------------------------------| *
* | | | | *
* |------------+------+----------------------------------------------| *
* | 2009-09-16 | RAHP | Modify panel | *
* |------------+------+----------------------------------------------| *
* | 2009-03-16 | RAHP | Replace LISTDSI by BXPWDYN | *
* |------------+------+----------------------------------------------| *
* | 2007-09-24 | RAHP | Remove call to 'GETTEMP' | *
* |------------+------+----------------------------------------------| *
* | 2007-09-04 | RAHP | Enclose URL in '<..>' | *
* |------------+------+----------------------------------------------| *
* | 2007-06-05 | RAHP | Add panel to source | *
* |------------+------+----------------------------------------------| *
* | 2007-06-04 | RB | Initial version | *
* |------------+------+----------------------------------------------| *
************************************************************************
* CMDSTACK is a REXX exec to read the ISPF command stack into a table *
* and display it. *
* *
* Source: <http://mvshelp.net/vbforums/showthread.php?t=23940> *
***********************************************************************/
parse source source
parse value source with . . moi .
"ispexec control errors return"
call load_dynlib
"ispexec libdef ispplib library id("dynlib") stack"
tcb = ptr(132 + ptr(540))
tld = ptr(ptr(24 + ptr(112 + tcb))) /* tld of current screen */
tld = tld + 56
tld1 = d2x(x2d(c2x(storage(d2x(tld), 4))) + 292) /* addr of cmd stack */
size = c2d(right(storage(c2x(storage(tld1, 4)), 40), 4))
cmdstack = storage(c2x(storage(tld1, 4)), size)
if left(cmdstack, 24) <> '** ISPF COMMAND STACK **' then
exit 12
cmds = substr(cmdstack, 84) /* addr of 1st command */
c. = 1
do while cmds \= ''
parse var cmds '000000'x cmds /* ??? */
parse var cmds l 2 cmds /* length of following command */
l = c2d(l)
if l = 0 then
leave
parse var cmds cmd +(l) cmds
if c.cmd then,
do
call fill cmd
c.cmd = 0
end
end
"ispexec tbcreate #cmdtab replace nowrite keys(cmd# cmd) names(sel)"
"ispexec tbsort #cmdtab fields(cmd#,n,d)" /* sort commands lifo */
if rc \= 0 then
exit 12
sel = ''
lines = cmd.0
do cmd# = 1 to lines
cmd = cmd.cmd#
"ispexec tbadd #cmdtab order"
end
"ispexec tbtop #cmdtab"
do forever
"ispexec tbdispl #cmdtab panel(cmdstack)"
if rc > 4 then
call execute_command
if zcmd \= '' then
call execute_command cmd.zcmd
else
if ztdsels > 0 then
if sel \= '' | cmd \= cmd.cmd# then
call execute_command cmd
end
execute_command:
"ispexec tbend #cmdtab"
if arg(1) \= '' then,
do
zcmd = ';'arg(1)
"ispexec control nondispl end"
"ispexec display panel(cmdstack)"
end
"ispexec libdef ispplib"
"free f("dynlib")"
exit
/* --- Set Pointer ------------------------------------------------ */
ptr: return c2d(storage(d2x(arg(1)),4))
/* --- Filling Routine -------------------------------------------- */
fill:
if ^datatype(cmd.0, 'W') then
cmd.0 = 0
parse value cmd.0+1 arg(1) with $z cmd.$z 1 cmd.0 .
return
/***********************************************************************
* LOAD_DYNLIB: *
* *
* This procedure loads the via EPANQ generated panel, message and *
* skeleton code into a library. Note that there is no reason to use *
* different libraries for any of these objects, as long as they are *
* named differently! *
***********************************************************************/
load_dynlib:
dynlib = 'dyn'random(99999)
alloc = "alloc fi("dynlib") rtdsn(sysdsname) " ||,
"lrecl(80) blksize(0) dir(5) " ||,
"new delete reuse " ||,
"space(1,1)"
rc = bpxwdyn(alloc)
if rc = 0 then
ispdyn = sysdsname
else
ispdyn = 'NOT FOUND' /* Needs better error checking! */
"newstack"
member = 'CMDSTACK'
queue ')attr default(%\_)'
queue ' % type(text) intens(high)'
queue ' \ type(text) intens(low)'
queue ' _ type(input) intens(high) caps(on) just' ||,
'(left)'
queue ' 0 type(input) color(green) caps(off)'
queue ' # type(output) color(turq) caps(off) skip(on) just' ||,
'(right)'
queue ' $ type(text) color(blue) hilite(uscore) skip(on)'
queue ')body expand(~~)'
queue ' ~ ~$ISPF Command Stack\ ~ ~'
queue '\'
queue '%Select ==> _zcmd ' ||,
' %Scroll ===>_z'
queue '\=~=~='
queue '%S No | Command'
queue '\------+-~-~-'
queue ')model'
queue '0z#z \|0z'
queue ')init'
queue ' .zvars = ''(zscroll sel cmd# cmd)'''
queue ')proc'
queue ' ver (&zcmd,range,1,&lines)'
queue ' ver (&cmd,nb)'
queue ')end'
put_object:
tfil = 'tfil'random(9999)
"alloc f("tfil") da('"ispdyn"("member")') shr reu"
"execio" queued() "diskw "tfil" (finis"
"free f("tfil")"
"delstack"
return
--
Robert AH Prins
robert(a)prino(d)org
No programming @
https://sites.google.com/site/robertahprins/home/hitchhiking/prino-s-blog
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN