Call local proc parameterized
Author: bschmidt@arz-emmendingen.de (BenjaminSchmidt)
Hi,
from time to time I need to write unit-tests for local procs. So I write an operation as interface to the local proc and then call the operation.
By this I´m getting a lot of operations, which are not needed for the final apllication! My thought was to implement only one operation, in which I could set the local function as parameter.
Something like:
string ps_LocalFunc
string ps_FunctionParameters
....
Then I would like to call the local function:
call ps_LocalFunc(ps_FunctionParameters)
I know this is possible for Operations:
newinstance ps_Service, "SOME_NAME"
activate "SOME_NAME"."%%ps_Operation%%%"(sParamstring)
But is this also possible for local functions?
Thanks a lot.
greets
3 Comments
Local Administrator
Hi Benjamin,
no, it isn't.
I use a dispatcher routine which makes use of 3 containers (aka uniface lists).
the first container is some kind of envelope and holds informations what is requires
the second container contains all the input parameters
the third container holds all information which needs to be returned.
second and third conatiner are only important for the sender and the processor;
all parties in between just pass this string
this entry uses a selectcase to link to the processing utilities.
Very fast, very easy, extremely flexible (even for delegations) and a one-signature-only option.
Uli
Author: ulrich-merkel (ulrichmerkel@web.de)
Local Administrator
This doesn't help with needing to create lots of operations but it may be of some help. One way to have these test operations in your code, but remove them when compiling for production is to use some pre-compiler directives and a global constant. If you wrap the test code with something like:
#if (<ENVIRONMENT> != "DEVELOPMENT")
...
#endif
Then in your development environment create a global constant called "ENVIRONMENT" with the value "DEVELOPMENT". In your build environment either remove the constant or have it set to "PRODUCTION".
This should allow you to create a "Testable" version and a "Production" version of your source.
Regards,
James
Author: James Rodger (james.r.rodger@gmail.com)
Local Administrator
Hi Benjamin
There is no way to call a local entry dynamically at runtime.
But you can use your operation and then use a SELECTCASE statement to call the needed entry.
Something like this:
OPERATION DISPATCH
params
string v_ENTRY:IN
string v_VALUES:INOUT
endparams
SELECTCASE v_ENTRY
CASE "ENTRY1"
call LP_ENTRY1(v_VALUES)
RETURN($status)
CASE "ENTRY2"
call LP_ENTRY2(v_VALUES)
RETURN($status)
...
ELSECASE
RETURN(-1109)
ENDSELECTACSE
END
Gruß Ingo
Author: istiller (i2stiller@gmx.de)