Returns the names of all the layer names registered in the Datasource.
object.GetLayerNames |
Array
DataSource GetLayerNames Example
Displays the names of all layers present in the selected AXF in the Console window.
DataSource GetLayerNames 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 CallGetLayerNames 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 arrNames, strLayerName arrNames = pDS.GetLayerNames If (IsArray(arrNames)) Then For Each strLayerName in arrNames Console.Print strLayerName Next Else Console.Print "No layer names returned" End If pDS.Close Set pDS = Nothing End Sub |
DataSource GetLayerNames 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 CallGetLayerNames() { 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 arrNames = pDS.GetLayerNames().toArray(); if (arrNames != null) { var index; for (index in arrNames) Console.Print(arrNames[index]); } else { Console.Print("No layer names returned"); } pDS.Close(); pDS = null; } |