J.Beckeringh@xxxxxxxxxxxxxxxxxxxxxxxxxx wrote:
I agree that input paramaters SHOULD use CONST, but not specifying it
won't cause errors.
Yes, that's why I said stated 'The CONST part isn't strictly necessary'
in my message. Thank you for agreeing with me.
As for the 2500 character limit: 'options (*varsize)' pretty much makes
the length of the parameter meaningless (in the prootype). Whether you
specify 2500, 65535 or 1 makes no difference (I prefer 1).
That's not true. When you code something as CONST, the compiler will
sometimes create an intermediate result in memory, and pass the address
of that intermediate result.
For example, if you define the prototype as 1A options(*VARSIZE), and
then try to pass a VARYING character string to it, the compiler will
copy only 1 byte from the VARYING string to an intermediate result, and
then it'll only pass that one byte string to the procedure.
So the difference is NOT meaningless in all situations. It's only
meaningless if the compiler doesn't have to use an intermediate result.
Also, if you're going to code 1A, then the options(*varsize) is totally
meaningless. *varsize only lets you pass variables that are SHORTER
than the prototype. You are ALWAYS allowed to pass variables that are
longer than the prototype -- you don't need *VARSIZE for that.
But, again, the problem with coding 1A is that if you use an expression,
or use a data type that requires conversion, it'll store the result of
the expression (or output of the conversion) into a 1A field, and pass
that, and you won't get all of the data you were expecting. Always make
the parameter the MAXIMUM size, never the minimum size, and you'll avoid
that problem.
As an Amazon Associate we earn from qualifying purchases.