Antonio provided excellent assistance in getting the calling routine setup. First I must do a connection to their program ... and that works fine.
Then I must do a request for a catalog which their program then displays. I find the item I want and "export" it. It is passed to a routine ( CalledBack( cXML, nSize ) ) which is the document ( XMLDoc :LPSTR; Size :INT )
To do a lookup, I use the following routine:
- Code: Select all Expand view RUN
- // Lookup items in the WorldPac catalog
FUNCTION wpacLookUp( cWrkOrd, cVehVin ) // wpac
MEMVAR cRet
LOCAL cFndVin := SUBSTR( cVehVin, 1, 10 )
// Request the catalog
ShowCatalog( cFndVin, "Auto Shop Writer" )
// Now lets parse the data
IF MsgYesNo( "Save the part to the workorder ?" )
ParseCatalog( cRet, cWrkOrd )
ENDIF
RETURN NIL
ShowCatalog( ) passes a VIN to the other program which then pops up the catalog search system. Once I have selected the parts, and press the Export key, it places an XML doc into the CalledBack value which is as follows:
- Code: Select all Expand view RUN
- // Procedure( XMLDoc :LPSTR; Size :INT )
FUNCTION CalledBack( cXML, nSize )
MEMVAR cRet
MsgInfo( cXML )
cRet := cXML
RETURN NIL
here is the embedded c code for callback
- Code: Select all Expand view RUN
- void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize )
{
hb_vmPushSymbol( hb_dynsymGetSymbol( "CALLEDBACK" ) ); // we push the symbol of the function to call
hb_vmPushNil(); // we push nil for a function, a codeblock for Eval, an object for a method
hb_vmPushString( szXML, strlen( szXML ) );
hb_vmPushLong( lSize );
hb_vmFunction( 2 ); // two parameters supplied to CallBack()
}
This works fine, and the value returned by cRet is the xml document with the proper information. The second part of that function sends the document to my parser which decodes it and places the needed values in a database for further use.
So here is the first problem. I have to delay the decoding because I cannot be sure if the xml doc is yet available to CalledBack( ). I use a YesNo message function for an artificial delay. It would be nice to just be able to pause until I know there is a message in called back. Any idea how to do this ? BTW, CalledBack is actually triggered by the other program.
Secondly, apparently they will send multiple documents, one for each item selected in the catalog, instead of combining them into one XML. I need to be able to capture each one.
I know this is perhaps somewhat vague. However, your questions / comments will help get to a solution. I offer this not only for my help, but I'm sure others have to interface with other programs, and decode XML docs, so perhaps this will help them also.,