Caution: Character Parameters ....

Posted by jmls on 19-Feb-2010 15:16

Just came across this in the online help for 10.2B, DEFINE PARAMETER statement:

Caution: For CHARACTER parameters, the AVM always passes the routine a pointer to the character or character string value

rather than the value itself. If the routine modifies the value, it can also modify the AVM memory outside the bounds of

the CHARACTER value with unpredictable results. For this reason, ABL does not allow you to use OUTPUT or RETURN for

CHARACTER or LONGCHAR parameters, as well as CHARACTER or LONGCHAR array parameters,

and does not recommend you use INPUT-OUTPUT for CHARACTER or LONGCHAR parameters.

Rather, pass the character string as a MEMPTR parameter. For more information, see OpenEdge Development: Programming Interfaces.

Since when is it considered bad practice to use a char as an INPUT-OUTPUT parameter ?

Or am I misreading this ? [in my defence, I've only had 1 beer ...]

Julian

All Replies

Posted by Thomas Mercer-Hursh on 19-Feb-2010 15:59

Isn't this specific to the GUI for .NET context?  I.e., if ABL to ABL, how could it ever be outside the context of the AVM?

You read better with more beers?

Posted by jmls on 19-Feb-2010 16:04

Doh!

Obviously, I do read better with more beer - just reread it, and you are absolutely correct

What was I thinking ?

Don't answer that ...

Posted by Admin on 19-Feb-2010 21:47

Rather, pass the character string as a MEMPTR parameter. For

more information, see OpenEdge Development: Programming Interfaces.

Since it refers to the Programming Interfaces doc I guess this is for DLL or Unix Shared Libraries access.

I can't think how a .NET objects could modify the pointer and get access to memory sections it shouldn't get.

This thread is closed