ArcPad Scripting Object Model
Close Method
See Also  Example  Send comments on this topic.
DataSource Object : Close Method

Glossary Item Box

Description

Closes the Datasource.

Syntax

object.Close

Example

Opens a DataSource and reads its properties.
DataSource Get Properties Example (VBScript)Copy Code
Function OpenAXF(p_strAXFPath)
      Dim pDS
      Set pDS = Application.CreateAppObject("DataSource")
      pDS.Open(p_strAXFPath)
      If (pDS.IsOpen) Then
            Set OpenAXF = pDS
      Else
            Set OpenAXF = Nothing
      End If
End Function

Function GetFileNameUI(p_extension, p_filter, p_title, p_flags) 
      GetFileNameUI = CommonDialog.ShowOpen(p_extension, p_filter, p_title, p_flags)
      If (IsEmpty(GetFileNameUI)) Then
            GetFileNameUI = ""
      End If
End Function

Sub GetDataSourceProperties
      Dim strFileName
      strFileName = GetFileNameUI("axf", "ArcPad AXF Files|*.axf","Select AXF File",       &H1000)
      If ("" = strFileName) Then Exit Sub

      Dim pDS
      Set pDS = OpenAXF(strFileName)
      If (pDS Is Nothing) Then
            Console.Print "Open DataSource failed"
            Exit Sub
      End If

      Dim strFilePath
      strFilePath = pDS.FilePath
      Console.Print "FilePath: " & strFilePath
      Dim lNumLayers
      lNumLayers = pDS.Properties("LAYERCOUNT")
      Console.Print "Num Layers: " & lNumLayers
      Dim strVersion
      strVersion = pDS.Properties("AXF_SCHEMA_VERSION")
      Console.Print "AXF_SCHEMA_VERSION: " & strVersion
      Dim lCount, strLayerName, lLayerID, strFolder 
      For lCount = 1 To lNumLayers
            strLayerName = pDS.LayerProperties(lCount,"NAME")
            lLayerID = pDS.LayerProperties(lCount,"LAYERID")
            strFolder = pDS.LayerProperties(lCount,"FOLDER")
            Console.Print "Layer " & lCount & " NAME: " & strLayerName
            Console.Print "Layer " & lCount & " ID: " & lLayerID
            Console.Print "Layer " & lCount & " FOLDER: " & strFolder
      Next
      pDS.Close
      Set pDS = Nothing
End Sub
DataSource Get Properties Example (JScript)Copy Code
function OpenAXF(p_strAXFPath)
{
      var pDS = Application.CreateAppObject("DataSource");
      pDS.Open(p_strAXFPath)
      if (pDS.IsOpen)
            return pDS
      else
            return null;
}

function GetFileNameUI(p_extension, p_filter, p_title, p_flags)
{
      var resOpen = CommonDialog.ShowOpen(p_extension, p_filter, p_title, p_flags);
      if (resOpen == null)
            return "";
      else
            return resOpen;
}

function GetDataSourceProperties()
{
      var strFileName = GetFileNameUI("axf", "ArcPad AXF Files|*.axf","Select AXF File", 0x1000);
      if ("" == strFileName)
            return;

      var pDS = OpenAXF(strFileName);
      if (null == pDS)
      {
            Console.Print("Open DataSource failed");
            return;
      }

      var strFilePath = pDS.FilePath;
      Console.Print("FilePath: " + strFilePath);
      var lNumLayers = pDS.Properties("LAYERCOUNT");
      Console.Print("Num Layers: " + lNumLayers);
      var strVersion = pDS.Properties("AXF_SCHEMA_VERSION");
      Console.Print("AXF_SCHEMA_VERSION: " + strVersion);
      var lCount, strLayerName, lLayerID, strFolder   
      for (lCount=1;lCount<=lNumLayers;lCount++)
      {
            strLayerName = pDS.LayerProperties(lCount,"NAME");
            lLayerID = pDS.LayerProperties(lCount,"LAYERID");
            strFolder = pDS.LayerProperties(lCount,"FOLDER");
            Console.Print("Layer " + lCount + " NAME: " + strLayerName);
            Console.Print("Layer " + lCount + " ID: " + lLayerID);
            Console.Print("Layer " + lCount + " FOLDER: " + strFolder);
      }
      pDS.Close();
      pDS = null;
}

See Also

© 2013 All Rights Reserved.