Microsoft DirectX 8.1 (Visual Basic)

Saving to an X File

Use the following procedure to save .x file templates and data to an .x file.

  1. Use the DirectX8.DirectXFileCreate method to create a DirectXFile object.
  2. Use the DirectXFile.RegisterTemplates method to inform the Microsoft® DirectX® file system about any templates that you will use.
  3. Use the DirectXFile.CreateSaveObject method to create an DirectXFileSave object.
  4. Use the DirectXFileSave.SaveTemplates method to save templates, if desired.
  5. Loop through the objects to save. For each top-level object, perform the following steps.
    1. Use the DirectXFileSave.CreateDataObject method to create a DirectXFileData object as a top-level object in the file. If the top-level data object has optional child objects, add them to the object by using the appropriate method as defined in the next step.
    2. Each DirectXFileData object can have optional child objects if its template allows it. The child objects can be any of the three types of objects: DirectXFileData, DirectXFileReference, or DirectXFileBinary. Loop through the objects you need to save, adding each optional child member to the object list in the manner appropriate to its type, as illustrated in the following steps. Then, if the object type is Data, call the DirectXFileSave.CreateDataObject method to create an DirectXFileData object, and then call the DirectXFileData.AddDataObject method to add it as a child of the object. If the object type is Data Reference, call the DirectXFileData.AddDataReference method to create and add the data reference object as a child of the object. Or, if the object type is Binary, call the DirectXFileData.AddBinaryObject method to create and add the binary object as a child of the object.
    3. Call the DirectXFileSave.SaveData method to save the data object and all its children.
    4. Set the DirectXFileData object variable to Nothing.
  6. Set the DirectXFileSave object variable to Nothing.
  7. Set the DirectXFileobject to Nothing.