Hi David -
On Wed, 14 Oct 2009 08:27:14 +0200, David FOXWELL
<David.FOXWELL@xxxxxxxxx> wrote:
I would also prefer 2 procedures. But in Ken's example, the code that is set is a variable that is local to the procedure. Surely that is an advantage compared to using a global variable. If I use Set then Get, where would Get find the variable? Could I wrap InzTransactionCode with SetTransactionCode and GetTransactionCode?
I'll state again for the record that in this situation I personally
would just use a global variable.
However given that you want to protect this variable, Kurt's
suggestion of having wrapper procedures around the SetGet procedure is
a good one.
Only the Set procedure needs to be EXPORTed. The Get procedure does
not need to be EXPORTed because it will only be called by other
procedures in the same module. The SetGet procedure does not need to
be EXPORTed because it will only be called by the Set procedure and
the Get procedure.
If using the wrappers, personally I would not use a return value with
the SetGet procedure. I would create the procedure with two required
parameters. The first parameter would be the transaction code. The
second parameter would be a logical indicator where *ON means it is
Set mode and *OFF means it is Get mode. For this procedure the
transaction code would not be CONST (_could_ not be CONST in fact).
The logical indicator would be CONST.
The Set wrapper procedure would have the transaction code as CONST. It
would just have to move the value to an local variable to call the
SetGet procedure in Set mode.
The Get wrapper procedure would still do a RETURN of the transaction
code.
Ken
Opinions expressed are my own and do not necessarily represent the views
of my employer or anyone in their right mind.
As an Amazon Associate we earn from qualifying purchases.