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



From: David FOXWELL

I have my code like this :


READ MyFile
Proc1 ( DREFNO ) // DREFNO is a field in MyFile


Proc1 B
SRefNo LIKE(aField) CONST

/Free

READ MyFile // The same file

// SRefNo now has the same value as DREFNO from myFile and I have modified
a parameter with CONST!

/end-free

Actually, what happens here is that the compiler simply passes a pointer to
DREFNO to the procedure, but calls it SRefNo. Think of it like this:

D SRefNo s like(global) based(pRefno)
D pRefno s * inz(%addr(DREFNO))

SRefNo does not have its own memory space, it shares it with DREFNO. So
when you modify DREFNO with the READ, you're also modifying SRefno.

You could show this even more easily: just create a global variable in your
D-specs and pass that to a procedure using CONST. In your procedure, modify
the global variable and that will also change the value of the local
variable you passed in.

Joe


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.