_MAC

VFPXMLProgID

This property of the _VFP object, new to VFP 7, allows you to specify a COM component to override the default functionality of VFP's internal XML functions: CursorToXML(), XMLToCursor(), and XMLUpdateGram(). If you don't like the way these functions work, you can roll your own and put them in your own COM object.

Usage

CProgID = _VFP.VFPXMLProgID _VFP.VFPXMLProgID = cProgID
Initially, you can query _VFP.VFPXMLProgID and it returns an empty string (""). Setting this property to the empty string tells VFP to use the internal VFP functions.

When you set the property to the ProgID of a specially designed COM object, VFP uses the methods in the COM object instead of the internal functions.

So how do you define this COM object? It must implement Visual FoxPro's IVFPXML interface. You can write it in Visual C++, Visual Basic, Visual FoxPro, or any other language that can create COM objects with the ability to implement interfaces. (For more on implementing interfaces in VFP, see "Face to Face with COM Interfaces" in "It Was Automation, You Know.") In VFP, the easiest way to do this is to open the Object Browser, then open the Microsoft Visual FoxPro 7.0 type library. Scroll down and expand the Interfaces node, then drag the IVFPXML icon to a new program. You'll get something like:

x=NEWOBJECT("myclass")   DEFINE CLASS myclass AS session OLEPUBLIC     IMPLEMENTS IVFPXML IN ;            "c:\program files\microsoft visual foxpro 7\vfp7.exe"     PROCEDURE IVFPXML_CursorToXML( ;       bstrAlias AS STRING, nOutputFormat AS Number, nFlags AS Number, ;        nRecords AS Number, bstrOutputFile AS STRING, bstrSchema AS STRING, ;       bstrSchemaLocation AS STRING, bstrNameSpace AS STRING, ;       pVFP AS VARIANT) AS VARIANT;     HELPSTRING "Converts from a Cursor to XML"     * add user code here   ENDPROC     PROCEDURE IVFPXML_XMLToCursor( ;       pvarXMLSource AS VARIANT, bstrCursorName AS STRING, ;       nFlags AS Number, pVFP AS VARIANT) AS Number;       HELPSTRING "Converts from XML to a Cursor"     * add user code here   ENDPROC     PROCEDURE IVFPXML_XMLUpdateGram(;       nFlags AS Number, bstrCursorList AS STRING, ;       pVFP AS VARIANT) AS VARIANT;       HELPSTRING "Generates an XML UpdateGram"     * add user code here   ENDPROC   ENDDEFINE
At this point, you're on your own. You're free to develop whatever replacement you'd like for CursorToXML(), XMLToCursor(), and XMLUpdateGram(). So if the built-in functions don't do things the way you want, or you've got some customized routines that are written in another language that you'd like to use, the VFPXMLProgID property lets you choose an alternative.

Example

* Assumption: You have a COM object that does the conversions, * and it's based on the above code, and has the ProgID of * "AlternateXML.MyClass".   _VFP.VFPXMLProgId = "AlternateXML.MyClass"

See Also

CursorToXML(), Define Class, _VFP, XMLToCursor(), XMLUpdateGram()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net