To use the following sample code, you must download the Group.xml
file and copy it in your application directory. Click here to download the
Group.xml
file.
In your VFP application, add a module with the following code :
* TASK: Create a Group master entry using SendXMLFileToServer()
*-------------------------------------------------------------------------------------------------
Declare Integer SendXMLFileToServer in
RTSlink.dll String
Declare String GetLastErrorMessage
in RTSLink.dll
Declare Integer Open in RTSlink.dll
Private nResult,cXMLfile,cErrorMsg
Do while .t.
*Specify the XML file with full path if not in application
directory
cXMLfile = "GROUP.XML"
*Connect to the Tally software. Returns zero if
successful
nResult=Open()
if nResult=0
*If Tally software is running
nResult=SendXMLFileToServer
(cXMLfile)
IF nResult != 0
cErrorMsg=GetLastErrorMessage() *You may provide an Error-handling
routine here
=MessageBox(cErrorMsg,0,"Error")
Endif
Else *If Tally software is NOT running
cErrorMsg=GetLastErrorMessage()
*You may provide an Error-handling
routine here
=MessageBox(cErrorMsg,0,"Error")
Endif
exit
Enddo
*Unload the DLL from memory
Clear DLLs
Alternatively, you can use AddXMLTag() & SendXMLTagsToServer():
*Example 2: Use functions AddXMLTag() and SendXMLTagsToServer()
*=======================================================
Declare String GetLastErrorMessage
in RTSLink.dll
Declare Integer Open in RTSlink.dll
Declare Integer AddXMLTag in RTSLINK.DLL
String
Declare Integer SendXMLTagsToServer in
RTSlink.dll
Private nResult,cErrorMsg
*Check whether the Tally software is running
or not ? Returns zero if running
*otherwise error code
nResult=Open()
if nResult=0
*If Tally software is
running
nResult=SendXMLTagsToServer()
IF nResult != 0
cErrorMsg=GetLastErrorMessage() *You
may provide an Error-handling routine here
=MessageBox(cErrorMsg,0,"Error")
Endif
Else *If Tally software is
NOT running
cErrorMsg=GetLastErrorMessage() *You may provide an Error-handling
routine here
=MessageBox(cErrorMsg,0,"Error")
Endif
exit
Enddo
Clear DLLs
Notes:
AddXMLTag() function reserves memory space to store data (i.e. XML tags).
SendXMLTagsToServer() sends the XML message/tags to the [Tally] Server.
Whenever you invoke the AddXMLTag() function, make sure that you invoke the
SendXMLTagsToServer() function also. Failing to do so would result in
memory leaks.
Using the DLL in Foxpro 2.6 for DOS
You cannot directly invoke RTSlink functions from 16-bit Foxpro 2.6. However, a
wrapper (exe) is provided which allows you to send XML-File to the [Tally]
server.
You can try out the above from the MS-DOS command prompt. Ensure that the XML-file
is in the same directory as that of Wrapper.exe. You can also use it in a
BATCH file.