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



Scott,

In practice I find a combination of *BASED and *DEFINED is the right answer. For an API that returns a list and each element in the list is a number of fields I use *DEFINED to build the 'record layout' and then use *BASED to roll through the list. Maybe this is what you meant, but here is parts of an example from a program I wrote recently:

/* Define the 'record' and needed pointers. */

DCL &Cptr *PTR /* Pointer for &Cinf */
DCL &Cofs *INT 4 /* Pointer Offset &Cinf */
DCL &Cinf *CHAR 112 STG(*BASED) BASPTR(&Cptr) /* Cartridge Information*/
DCL &CID *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 1 ) /* Cartridge ID */
DCL &VID *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 7 ) /* Volume ID */

/* Call the actual API Here */

CHGVAR &Cptr %ADDRESS(&RCTG) /* Point to beginning of cartridge information */
CHGVAR &Cofs %OFFSET(&Cptr) /* Initialize the offset */
CHGVAR &Cofs (&Cofs + &Offs) /* Initialize the offset */
/* This places &Cinf in the same memory as the first row returned in &RCTG */
/* All *DEFINED variables are now automatically updated with corresponding values. */

DOFOR &Cnum FROM(1) TO(&NCat) /* Loop through all available tapes */
CHGVAR %OFFSET(&Cptr) &Cofs

/* Process each entry here using &CID, &VID etc. */

CHGVAR &Cofs (&Cofs + &LCat) /* Point to next cartridge */
/* This places &Cinf in the same memory as the NEXT row returned in &RCTG */
/* All *DEFINED variables are now automatically updated with corresponding values. */
ENDDO

Larry "DrFranken" Bolhuis


On 5/14/2012 1:26 PM, Scott Klement wrote:
Hiya Folks,

Consider using STG(*DEFINED) fields instead of *BASED for this type of
logic. No need to do pointer math that way, and aside from the pointer
stuff, they work the same as *BASED. Save *BASED for times when you
need to be able to change the address in memory where the variables point.

As for Joel's initial question, a *MSGF/RTVMSG might be an easier
solution. But, ultimately, the problem is that CL just isn't that good
at string manipulation. Using a better language like RPG or REXX would
almost certainly work better. Why force a square peg through a round hole?

-SK


On 5/14/2012 9:49 AM, DrFranken wrote:
I'm going to guess no, but in some cases you might be able to simplify
by declaring&P_CLIENT,&P_SEQ etc as *BASED fields of a longer
character variable thus building the VALUES( clause there. It could
look as simple as VALUES(&VALUES) avoiding all those *cats in your program.

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.