× 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 28-Jan-2014 06:22 -0800, John Allen wrote:
CRPence on Friday, January 17, 2014 7:17 AM wrote:
<<SNIP>>
Seems the intent is to effect the same as "F16=Remove all except
unanswered" from the Display Messages panel.?
<<SNIP>>

<<SNIP>>
This sounds like it will work. I will try it and see.


I have some code in CL using RCVMSG and RMVMSG [instead of the APIs], that already does effectively what "F16=Remove all except unanswered" does, and is at least somewhat tested. There is a simplistic version, and then there is a slightly more complex version.

The latter version ensures the order of processing mimics the visual presentation of messages in the queue. That is, replies are processed directly after their inquiries, because each inquiry is checked to see if there is a reply to that inquiry message, rather than the replies being processed in the order each reply was\if eventually sent. The ordering could be significant, for example, if the intent is to make an effective copy of the DSPMSG presentation; that is what my original code did, for some testing purposes.

When the order is irrelevant however, looking for a reply to any particular inquiry message is moot. The reply messages will eventually get removed when they are encountered later [per order by time of receipt rather than immediately after the inquiry], and thus also their corresponding inquiry will be deleted, as the implicit side effect of having removed the reply. In that processing, all inquiries can simply be ignored, such that all inquiries without a reply will remain in the MSGQ. My code doing just that, follows in a code snippet below, just after some necessary setup to effect a test. Obviously the work behind the CpyMsg label is optional, and could be replaced by whatever work might be required for the context of the OP:

setup: crtmsgq qtemp/qfrom
crtmsgq qtemp/qcopy
snd... /* populate qtemp/qfrom with test messages */

<code>

dcl &mq *char 10 qfrom
dcl &ml *char 10 qtemp
dcl &cq *char 10 qcopy
dcl &cl *char 10 qtemp
dcl &msgkey *char 4
dcl &curkey *char 4
dcl &msgtyp *char 2
dcl &curtyp *char 2
dcl &msgtxt *char 132
dcl &rpytxt *char 32
TopMsg:
rcvmsg () (&ml/&mq) (*NEXT) (*TOP) rmv(*no) +
keyvar(&MSGKEY) msg(&MSGTXT) rtntype(&MSGTYP)
PrcMsgs: /* for every message in from-msgq */
DoWhile (&MsgKey *NE ' ') /* inputs: MsgKey MsgTyp MsgTxt */
CpyMsg: /* Copy Msg Txt of this message to the other MsqQ */
sndpgmmsg () (cpf9897) (qcpfmsg) (&msgtyp *bcat &msgtxt) +
tomsgq(&cl/&cq) msgtype(*info)
CurMsg: /* save details about the current msg being processed */
chgvar &curkey &msgkey
chgvar &curtyp &msgtyp
NxtMsg: /* get next relative message; must be done before RmvMsg! */
rcvmsg msgq(&ml/&mq) msgtype(*next) msgkey(&CURKEY) rmv(*no) +
keyvar(&MSGKEY) msg(&MSGTXT) rtntype(&MSGTYP)
RmvMsg: /* remove any non-Inqmsg; deleting a Rpy removes its Inq */
if (&curtyp *ne '05') then(do) /* Do not delete Inquiries! */
rmvmsg msgq(&ML/&MQ) msgkey(&CURKEY) clear(*bykey)
enddo
EndDo /* EndWhile MsgKey is found */
NoMore:
return

</code>

The revision to the above latter version of the code to effect the former [more complex] version of the code which orders processing of the reply message immediately after its corresponding inquiry, adds the code snippet immediately following just before the NxtMsg label and the replaces the activity under the CpyMsg label with the next code snippet that simply conditions the SNDPGMMSG to avoid copying a duplicate of the reply:

<code>

if (&curtyp *eq '05') then(do) /* processing an Inq msg */
GetRpy: /* look for a reply to this inquiry */
rcvmsg () (&ml/&mq) (*RPY) (&CURKEY) rmv(*no) msg(&RPYTXT) +
rtntype(&msgtyp)
if (&msgtyp *eq ' ') then(do) /* blank means no *rpy msgtype */
NfyRpyPnd: /* no rpy to copy; indicate reply is pending */
sndpgmmsg () (cpf9897) (qcpfmsg) ('** awaiting reply **') +
tomsgq(&cl/&cq) msgtype(*info)
enddo
else do
CpyRpy: /* like CpyMsg; copy reply to the other msgq */
sndpgmmsg () (cpf9897) (qcpfmsg) (&msgtyp *bcat &rpytxt) +
tomsgq(&cl/&cq) msgtype(*info)
enddo
enddo /* An inquiry message */

</code>

<code>

if ( *not ( (%sst(&msgtyp 1 1) *eq '2') *and +
(%sst(&msgtyp 2 1) *ge '1') *and +
(%sst(&msgtyp 2 1) *le '6') ) ) then(do)
/* Rpy msgs ignored here else copied both in GetRpy and here */
sndpgmmsg () (cpf9897) (qcpfmsg) (&msgtyp *bcat &msgtxt) +
tomsgq(&cl/&cq) msgtype(*info)
enddo

</code>


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 copyright@midrange.com.

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