Posted by: Simon Agar
Hello
In the below code I pass and receive data (CallCSPCSV) through a dll written in Delphi. If the connection to the server is terminated and I run this code the TestConnection() fails and the Return FALSE is executed. When the connection to the server is re-established, the TestConnection() succeeds but I get a windows error on the CStructCopyFromFarMem line. I do not execute any other code in-between. Could anybody help please? I tried formally re-establish the connection in my code but that does not work. Attached is the windows error.
I'm using TD3.0.0-PTF4 Build 13612.
Thanks
Simon
!!CB!! 72
If Not TestConnection()
Set p_sErrorMsg = APP_FMISString_CommsError
Return FALSE
Set nPointerToBuffer1 = CStructAllocFarMem(APP_FMISString_ShortStringLength)
Set nPointerToBuffer2 = CStructAllocFarMem(APP_FMISString_ShortStringLength)
Call CStructCopyToFarMem( nPointerToBuffer1, p_sSend1, APP_FMISString_ShortStringLength-1 )
Call CStructCopyToFarMem( nPointerToBuffer2, p_sSend2, APP_FMISString_ShortStringLength-1 )
If Not CallCSPCSV(nPointerToBuffer3, nPointerToBuffer2, nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)
Call SalStrSetBufferLength(p_sReturn, APP_FMISString_ShortStringLength)
Call CStructCopyFromFarMem(nPointerToBuffer3, p_sReturn, APP_FMISString_ShortStringLength-1)
Set p_sErrorMsg = "Error calling FMIS function: "||SalStrTrimX(p_sSend1)
If p_sReturn != STRING_Null
Set p_sErrorMsg = p_sErrorMsg||"- "||SalStrTrimX(p_sReturn)||"."
Else
Set p_sErrorMsg = p_sErrorMsg||"."
Return FALSE
If nPointerToBuffer3 = 0
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)
Set p_sErrorMsg = "Error getting return parameter from FMIS Server."
Return FALSE
Call SalStrSetBufferLength(p_sReturn, APP_FMISString_LongStringLength)
Call CStructCopyFromFarMem( nPointerToBuffer3, p_sReturn, APP_FMISString_LongStringLength-1 )
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)
Simon Agar
Application Development Section
Nelson Mandela Bay Municipality
Tel: +27 41 506 1226
Fax: +27 86 669 7486
Cell: +27 82 491 7862
SAgar@mandelametro.gov.za
Attachment: Doc1.doc