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




I'm responding to MIDRANGE-L because this isn't an RPG question.

The following code (It is the CMD source) works fine except for the fact
that if the user enters only 4 or 5 values for the parameter PRJ1, the
remaining part of the parameter list contains junk value.

PARM       KWD(PRJ1) TYPE(*CHAR) LEN(10) DFT(*BLANKS) +
            MIN(0) MAX(10) PASSVAL(*DFT) +
            PROMPT ('Project ID')

When the data is passed to the CL program, it passes a 2-byte binary integer that contains the number of entries, followed by as many entries and the user supplied. You need to use care that you only access the entries that the user supplied, and not anything that wasn't supplied. That's why it sends you the count in the first 2 bytes.

This is much easier to do in RPG since this type of thing lends itself to a data structure and array setup, but it can be done in CL using %BIN and %SST. Here's an example of processing this type of list in CL:

PGM PARM(&PARM1)

       DCL VAR(&PARM1) TYPE(*CHAR) LEN(102)
       DCL VAR(&COUNT) TYPE(*DEC) LEN(5 0)
       DCL VAR(&ENTRY) TYPE(*CHAR) LEN(10)
       DCL VAR(&POS)   TYPE(*DEC) LEN(5 0)

       /* LOOP THROUGH ALL OF THE ENTRIES RECEIVED */

       CHGVAR VAR(&COUNT) VALUE(%BIN(&PARM1 1 2))
       CHGVAR VAR(&POS) VALUE(3)
LOOP:  IF (&COUNT *GT 0) DO
           CHGVAR VAR(&ENTRY) VALUE(%SST(&PARM1 &POS 10))

           /* &ENTRY NOW CONTAINS ONE OF THE ENTRIES. INSERT +
              CODE HERE TO USE IT.  FOR THE SAKE OF DEMONSTRATION, +
              I'LL DISPLAY IT ON THE SCREEN W/SNDUSRMSG COMMAND */

           SNDUSRMSG MSG(&ENTRY)

           CHGVAR VAR(&POS) VALUE(&POS + 10)
           CHGVAR VAR(&COUNT) VALUE(&COUNT - 1)
           GOTO LOOP
       ENDDO

ENDPGM

Naturally, in V5R3 you'd want to use DOWHILE instead of a GOTO, but I wasn't sure what release you were using, so I gave you code that will work on any release.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.