× 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 06-May-2016 23:11 -0500, Bily Rowe wrote:
Can a variable in a CLLE program be updated using pointers?

The Change Variable (CHGVAR) statement command, just like would be done to change variables that are not addressed via pointers.? And, that is mostly the same, irrespective of ILE CL (CLLE) vs OPM CL (CLP).

Perhaps I do not understand the question; not even after reading ahead. Nevertheless, I will offer:


I know how to access (i.e. read) columns from a variable using
pointer (i.e. %address, %offset)


So something like the following which only /reads/ the value of the variable (&elem) to build the output string?:

<code>
dcl &inputDta *char 30 /* 3 10-byte elements */+
value('First Second Third')
/* ______'....+....1....+....2....+....3 */
dcl &elemSiz *int 4 value(10)
dcl &elemPtr *ptr address(*null)
dcl &elem *char 10 stg(*based) basptr(&elemPtr)
dcl &elemNbr *int 2
dcl &elemPos *int 2
dcl &elemSST *char 10
dcl &outputStr *char 36 /* parenthetical 10-byte elements */
byADR:
chgvar &outputStr ' '
chgvar &elemPtr %addr(&inputDta)
dofor &elemNbr 1 3
chgvar &outputStr +
(&outputStr *tcat '(' *cat %trim(&elem) *cat ')')
chgvar %ofs(&elemPtr) (%ofs(&elemPtr) + &elemSiz)
enddo
sndpgmmsg () cpf9897 qcpfmsg &outputStr +
topgmq(*prv) tomsgq(*topgmq) msgtype(*info)
</code>



and how to loop through a variable's characters using %sst.


So, something like the following [as addendum to the above]?:

<code>
bySST:
chgvar &outputStr ' '
dofor &elemNbr 1 3
chgvar &elemPos ( (&elemNbr - 1) * &elemSiz + 1 )
chgvar &elemSST %sst(&inputDta &elemPos &elemSiz)
chgvar &outputStr +
(&outputStr *tcat '(' *cat %trim(&elemSST) *cat ')')
chgvar %ofs(&elemPtr) (%ofs(&elemPtr) + &elemSiz)
enddo
sndpgmmsg () cpf9897 qcpfmsg &outputStr +
topgmq(*prv) tomsgq(*topgmq) msgtype(*info)
</code>


I would just like to figure out how to use pointer to update a cl
program variable if it's even possible.

Perhaps something like the following [as addendum to the above]?:

<code>
if1stPass: /* chg input data, then re-perform prior code */
if (%sst(&inputDta 1 &elemSiz) *eq 'First') then(do)
chgByADR: /* change value of &ELEM via basing pointer */
chgvar &elemPtr %addr(&inputDta)
dofor &elemNbr 1 3
chgvar &elem ('<' *tcat &elem *tcat '>')
chgvar %ofs(&elemPtr) (%ofs(&elemPtr) + &elemSiz)
enddo
goto byADR /* perform second pass of data */
enddo
</code>

The above three sections of <code></code> can be placed into source, in that order, and then compiled as either CLP or CLLE. The output from the CALL should be:

(First)(Second)(Third)
(First)(Second)(Third)
(<First>)(<Second>)(<Third>)
(<First>)(<Second>)(<Third>)

If none of that is helpful, then perhaps code an example CL, and then explain in words and in pseudo-code the desired effect.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.