DEFINE CLASS Executor AS Session OLEPUBLIC
*!* Original example
PROCEDURE SqlCommand( tcCommand as String ) as String
local lcReturn
lcReturn = ""
Close Databases all
&tcCommand
If Empty( Alias() ) or Reccount() = 0
* Nothing to do
Else
CursorToXML( Alias(), "lcReturn", 1, 1 + 8, 0, "1")
endif
Return lcReturn
ENDPROC
*!* My contribution
PROCEDURE ScriptCommand( tcCommand as String, ;
tuParam1 as Variant, ;
tuParam2 as Variant, ;
tuParam3 as Variant, ;
tuParam4 as Variant ;
) as String
Return=EXECSCRIPT( tcCommand, ;
tuParam1, ;
tuParam2, ;
tuParam3, ;
tuParam4 )
ENDPROC
ENDDEFINE
The string passed as parameter (tcCommand) is generated in the client side with
TEXT TO lcText NOSHOW TEXTMERGE PRETEXT 7
.....
.....
.....
ENDTEXT
The idea is to have a kind of running a little process,
and not only a single command, on the server´s machine.
In fact, it works.
I know that I must be care of using any visual object, and kept it stateless.
The first is quite simple, but I’m not so sure how to keep the component stateless.
If I declare some local variables, am I going against the stateless rule?
And what about error handling? Can I do it inside the process,
or I have to catch it and inform the client, with a return string,
that something wrong has happened?
In a word, am I against some rule of thumb?
What other considerations do you believe must I take
in mind when writing the process
TIARicardo Aidelman
Software Developer
Praxis Computación
Buenos Aires, Argentina