open-insight/LSL2/STPROC/TEST_REVCAPI.txt
2024-05-22 14:06:46 -07:00

117 lines
3.1 KiB
Plaintext

Function TEST_REVCAPI(inContextFlag)
/*
** Purpose: Test calling revCapi
**
** Usage:
** run TEST_REVCAPI 'SUB' to test callsubroutine
* rjc 12-07-10 Created
*/
$Insert revcapi_equates
$Insert Msg_Equates
If Assigned(method) Else method = ''
* Connect to an oinsight
* make a unique name
declare Function getCurrentPRocessId
processid = getcurrentprocessID()
serverSpec = "\\.\O":date()+time()
debug
databasename = 'LSL2'
username = 'LSL2'
password = 'LSL22022'
queueName = ''
flags = 65
shutdownSessions = 1
engine = 0
queue = 0
error = 0
returnvalue = ''
statustext = ''
Error = CreateEngine(Engine, ServerSpec, DatabaseName, Flags, ShutdownSessions)
If Not(error) then
Error = CreateQueue(Queue, Engine, QueueName, DatabaseName, UserName, Password)
End
oiFuncName = 'TEST_REVCAPI_SUB'
oiParam = databasename : ' ' : timedate()
method = 'Func'
Begin Case
Case error
Case indexc(method, 'Func', 1)
Call WinYield()
Error = CallFunction(Queue, returnvalue, oiFuncName, oiParam)
Call WinYield()
Case indexc(method, 'Sub', 1)
Call WinYield()
Error = CallSubroutine(Queue, oiFuncName, oiParam)
Call WinYield()
Case 1
script = "RUN " : oiFuncName : " '" : oiParam : "'";
statusText = "";
request = 0;
Status = ''
statusText = ''
returnvalue = ''
this_reply = ''
Error = CreateRequest(request, Queue, Script, '')
if ( request ne 0 ) then
loop
Error = PollForReply(Request, Status)
begin case
case Status eq UNPROCESSED$ // Server has not begun request.
null
case Status eq PROCESSING$ // Server is processing request.
null
case Status eq DATA_AVAILABLE$ // Server has data available.
Error = GetReply(Request, this_reply)
returnvalue := this_Reply
case Status eq COMPLETED$ // Server has completed request, status information is available.
Error = GetStatusText(Request, @vm, StatusText)
case Status eq PROC_ERROR$ // Server process failed, status information is available.
// Get the status data
// Get the status data
Error = GetStatusText(Request, @vm, StatusText)
case Status eq INFO_AVAILABLE$ // Server has intermediate status information available.
this_Text = ''
Error = GetStatusText(Request, @vm, this_Text)
Call send_dyn(this_text)
case Status eq INFO_REQUEST$ // Server is requesting info
this_Text = ''
Error = GetStatusText(Request, @vm, this_Text)
def = ''
def<mType$> = 'RC'
def<mCaption$> = 'Info Needed'
def<mText$> = this_text
ans = Msg(@window, def)
end case
while ( (Status ne COMPLETED$) and ( Status ne PROC_ERROR$) )
repeat
CloseRequest(Request)
end
End case
// Clean Up
if queue then x = CloseQueue(Queue)
if engine then x = CloseEngine(Engine)
Call Send_Dyn(' Response = ' : Quote(returnvalue))
Call Send_Dyn(' Status = ' : Quote(statustext))
Call Send_Dyn(' error = ' : Quote(error))
Return ''