× 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.



John,

Again, the CL program SHOULD work... try debugging that a little
more... otherwise, the QMHSNDM API should also work.

Just in case it's useful... here's a function to place in a QShell script that uses QMHSNDM:

function log_sysopr() {
doubledquotes="${1//'/''}"
cmd=$(printf "CALL QMHSNDM (CPF9897 'QCPFMSG *LIBL' '%s' \
x'%08x' *INFO *SYSOPR x'00000001' ' ' x'00000000' \
x'00000000')" "$doubledquotes" ${#doubledquotes})
system "$cmd"
}

The API call is a bit ugly, IMHO, that's why I wrapped it up in a function. As you can see, this function also doubles-up any apostrophes you pass to it, to escape those properly...

To log something, you'd do this:

log_sysopr "John's message for QSYSOPR"

Alternately, if you want to do this from CL there will be a bit of a challenge dealing with the length of a string, since CL expects the length of the parameter to be known at compile-time (which is an alien concept in QShell). But QShell does add a null (x'00') character to the end of the parameter, so a loop can be used to work around the issue.

PGM PARM(&MSG)

DCL VAR(&MSG) TYPE(*CHAR) LEN(80)
DCL VAR(&LEN) TYPE(*INT) LEN(4)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X'00')

CHGVAR VAR(&LEN) VALUE(1)
DOWHILE (&LEN *LE 80 *AND %SST(&MSG &LEN 1) *NE &NULL)
CHGVAR VAR(&LEN) VALUE(&LEN + 1)
ENDDO
CHGVAR VAR(&LEN) VALUE(&LEN - 1)

SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) +
MSGDTA(%SST(&MSG 1 &LEN)) +
TOMSGQ(*SYSOPR)
ENDPGM

See what I mean? I have to use the DOWHILE loop to find the x'00'. Otherwise, I'd run the risk of getting "garbage" at the end of the string. And if QShell didn't pass at least 80 chars (in this example) changing the contents of &MSG would corrupt memory.... so I can't just "strip off the garbage" -- not safely, at any rate. Thus the loop, above... it should solve that problem.

Then you call it from QSH like this:

/qsys.lib/mylib.lib/logqsysopr.pgm "This is a test message"

I have to admit, I like the API example better than the CL example... Neither example is as pretty as I'd like it to be, but I think the API call is slightly less ugly than the CL program approach.

I know you've already figured it out on your end, so this may be academic at this point... but I had a minute, so I thought I'd try the options.

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.