ArcPad Scripting Object Model
Open Method
See Also  Example  Send comments on this topic.
FileName
Required. A String that specifies the complete filepath of the Datasource.
Username
Optional. A String that specifies the username for the Datasource, if the Datasource is password protected.
Password
Optional. A String that specifies the password for the Datasource, if the Datasource is password protected.
DataSource Object : Open Method

Glossary Item Box

Description

Opens a Datasource without adding it to the map

Syntax

object.Open ( FileName [,UserName] [,Password] )

Parameters

FileName
Required. A String that specifies the complete filepath of the Datasource.
Username
Optional. A String that specifies the username for the Datasource, if the Datasource is password protected.
Password
Optional. A String that specifies the password for the Datasource, if the Datasource is password protected.

Return Type

Boolean

Example

Opens a DataSource and sets some of its properties.
DataSource Set 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 SetDataSourceProperties
      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 lNumLayers
      lNumLayers = pDS.Properties("LAYERCOUNT")
      pDS.UserProperties("MyProp1") = "Craig"
      Dim strMyProp1
      strMyProp1 = pDS.UserProperties("MyProp1")
      Console.Print "MyProp1 user property: " & strMyProp1
      Dim lCount, strLayerName, strFolder   
      For lCount = 1 To lNumLayers
            pDS.LayerProperties(lCount,"NAME") = "New Name" & lCount
            strLayerName = pDS.LayerProperties(lCount,"NAME")
            pDS.LayerProperties(lCount,"FOLDER") = "New Folder" & lCount
            strFolder = pDS.LayerProperties(lCount,"FOLDER")
            Console.Print "Layer " & lCount & " NAME: " & strLayerName
            Console.Print "Layer " & lCount & " FOLDER: " & strFolder
      Next
      pDS.Close
      Set pDS = Nothing
End Sub
DataSource Set 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 SetDataSourceProperties()
{
      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 lNumLayers = pDS.Properties("LAYERCOUNT");
      pDS.UserProperties("MyProp1") = "Craig";
      var strMyProp1 = pDS.UserProperties("MyProp1");
      Console.Print("MyProp1 user property: " + strMyProp1);
      var lCount, strLayerName, strFolder ;
      for (lCount = 1; lCount<=lNumLayers; lCount++)
      {
            pDS.LayerProperties(lCount,"NAME") = "New Name" + lCount;
            strLayerName = pDS.LayerProperties(lCount,"NAME");
            pDS.LayerProperties(lCount,"FOLDER") = "New Folder" + lCount;
            strFolder = pDS.LayerProperties(lCount,"FOLDER");
            Console.Print("Layer " + lCount + " NAME: " + strLayerName);
            Console.Print("Layer " + lCount + " FOLDER: " + strFolder);
      }
      pDS.Close();
      pDS = null;
}

See Also

© 2012 All Rights Reserved.