× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 1/18/2016 2:19 PM, Justin Dearing wrote:
One relatively unique feature of bash, and as of version 5.0 in powershell
is that your command history is saved across sessions. I'd like the same
for my 5250 session.

So is there some kind of API call to read and write from that list? Seems
like if that existed, then one could write a save and retrieve history
program from the signon/signoff program.

The list of commands in your job log is actually a series of messages
called request messages. Decades and decades ago, I wrote my own
programmer menu in CL which handled request messages; you would be sort
of in the same position if you were to keep old messages in a file
somewhere.

The basic idea is that you would somehow retrieve the commands from QCMD
(the command interpreter), or in bulk with QMHLJOBL, and store them in a
table. After you sign on again, you need a way to read the rows from
that table and then send them as request messages, to be processed again.

A slightly easier (subjective!) way is to write your own request
processor. That way you could save/restore commands as you choose to.
Basically, you send yourself a request message and receive it:

/* Turn me into a request processing program */
SNDPGMMSG MSG('BMENU started') TOPGMQ(*SAME) +
MSGTYPE(*RQS)
RCVMSG PGMQ(*SAME) MSGTYPE(*RQS) RMV(*NO)

To retrieve prior commands:

RTV001:
IF (&MSGKEY *EQ '*NONE') DO
RCVMSG PGMQ(*SAME) +
MSGTYPE(&MSGTYPE) +
KEYVAR(&KEYVAR) +
RMV(*NO) +
MSG(&CMD) +
RTNTYPE(&RTNTYPE)
/* redisplay the screen */
MONMSG CPF0000 EXEC(GOTO TAG001)
ENDDO

IF (&MSGKEY *NE '*NONE') DO
RCVMSG PGMQ(*SAME) +
MSGTYPE(&MSGTYPE) +
MSGKEY(&MSGKEY) +
KEYVAR(&KEYVAR) +
RMV(*NO) +
MSG(&CMD) +
RTNTYPE(&RTNTYPE)
MONMSG CPF0000 EXEC(GOTO TAG001)
ENDDO

IF (&RTNTYPE *EQ ' ') DO
CHGVAR &MSGTYPE '*LAST'
CHGVAR &MSGKEY '*NONE'
GOTO TAG001
ENDDO

CHGVAR &MSGKEY &KEYVAR
CHGVAR &MSGTYPE '*PRV'

IF ((&RTNTYPE *NE '08') *AND +
(&RTNTYPE *NE '10')) (GOTO RTV001)

GOTO TAG001

ENDDO

After typing in a command on the screen, it goes in variable &CMD:

CHGVAR &QCMD (&CMD)
IF &IN04 CHGVAR &QCMD ('?' *CAT &QCMD)
CALL &CHKPGM (&QCMD 255)
MONMSG MSGID(CPF0000) EXEC(GOTO TAG001)
/* Send RQS message for info */
SNDPGMMSG MSG(&QCMD) TOPGMQ(*SAME) MSGTYPE(*RQS)
RCVMSG PGMQ(*SAME) MSGTYPE(*RQS) RMV(*NO)
CALL &CMDPGM (&QCMD 255)
CHGVAR &CMD &QCMD
GOTO TAG001

&CMDPGM is 'QCMDEXC to process a command. It's a variable here because
I used to swap between S/38 and AS/400 syntax - this code is that old.
&QCMD is a work variable which allows for a prompt (prepending the
question mark).

I hope that gives you a little idea about request processing programs.
It could be done in RPG just as easily with a few API wrappers.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.