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



Hi David,

OPTIONS(*VARSIZE) is used to turn off the compiler's variable size checking
code. So when passing by reference you can pass a larger/smaller field than
that defined on the prototype. However, within your subprocedure you MUST
check the length actually passed, otherwise simply setting the parameter to
blanks when a smaller field was passed can corrupt data. To inform the
subprocedure of the actual length you can pass a second parameter
designating the length passed or by passing operational descriptors.
Personally I prefer the second approach as you don't have to rely on the
author of the calling code to put the length in the field. howver, if your
code may be called from other languages you can't always depend on
operational descriptors either (subject of another thread).

Your code compiles because you have specified CONST for your first
parameter. When you do this, during the call, the runtime will create a
temporary variable with the same type/length as that defined on the
prototype. The value in your field will then be copied to this temporary and
the data truncated/padded accordingly. It is the temporary variable which is
actually passed on the call.

There have been several discussions on this, one only recently.

Regarding CONST, here is a thread I started a few weeks ago:
http://archive.midrange.com/rpg400-l/200710/msg00762.html

Regarding CONST and/or OPTIONS(*VARSIZE), here is the start of a really good
thread initiated by Charles Wilt:
http://archive.midrange.com/rpg400-l/200605/msg00162.html

In this thread I wrote a program to check all of the variations of CONST
OPTIONS(*VARSIZE) and VARYING. You should follow the whole thread from
Charle's initial post. But you can take a quick peek at my findings here:
http://archive.midrange.com/rpg400-l/200605/msg00224.html Pay particular
interest to the notes at the foot of the post.

Cheers

Larry Ducie




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.