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



Here's another approach...

In ILE, one ILE language can call procedures from any other ILE language. It's one of the advantages of the ILE environment. In this case, you'd like to work in CL, and assuming that ILE CL is acceptable, that means that you can call procedures in another ILE language. Parts of the operating system are written in C, so the C functions are always available. You could write your program as follows:


PGM

DCL VAR(&FILENO) TYPE(*INT) LEN(4)
DCL VAR(&TEMP) TYPE(*CHAR) LEN(11)
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(10)

DOFOR VAR(&FILENO) FROM(1) TO(350)
CALLPRC PRC('sprintf') PARM(&TEMP 'XREF%-6d' +
(&FILENO *BYVAL))
CHGVAR VAR(&FILENAME) VALUE(%SST(&TEMP 1 10))
/* at this point, &FILENAME='XREF1' or 'XREF2', etc */
ENDDO

ENDPGM

The first time through the loop, &FILENAME will be 'XREF1 '
the second time through it'll be 'XREF2 ', and so on until
you have 'XREF350 '.

Since this is ILE CL, the source member type should be CLLE (not CLP)
and since you need to use a routine from the ILE C runtime library,
you should compile the preceding program as follows:

CRTCLMOD QTEMP/TESTPGM SRCFILE(xxx/QCLSRC)
CRTPGM TESTPGM MODULE(QTEMP/TESTPGM) BNDDIR(QC2LE)

The BNDDIR(QC2LE) is what gives you access to the C functions (in this case, sprintf).

This program does require V5R3 or later, but since your sample code is
using DOWHILE, I didn't think that was a problem...

Is this better than looping through and manually pulling the zeroes off? I dunno. But it's shorter, and it's another alternative.

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.