HOW TO
There is no direct access to most of the ArcPad preferences from VBScript. These preferences are stored in ArcPadPrefs.apx and exposed to the user in the ArcPad Options dialog box.
A few preferences can be accessed via the Properties property of the Application object, but most require reading from and/or writing to ArcPadPrefs.apx directly.
Warning:
The MSXML DOM is present on all Windows 9x/NT/2000/XP and Pocket PC devices; however it is not present on CE 2.x and some CE 3.0 devices. If the MSXML DOM is not present on your CE 3.0 device, please contact the device manufacturer and ask for it to be included.
Code:
Sub SetPointAveraging (p_AvgTime)
'Path to ArcPadPrefs.apx file
Dim strArcPadAPX
strArcPadAPX = Application.System.Properties("PersonalFolder") & "\My ArcPad\ArcPadPrefs.apx"
'Attempt to create a reference to the MSXML DOM
On Error Resume Next
Dim pXML
Set pXML = CreateObject("Microsoft.XMLDOM")
If Err.Number <> 0 Then
MsgBox "MSXML is not present on this device.", vbCritical, "No MSXML"
Exit Sub
End If
On Error GoTo 0
'Read in ArcPadPrefs.apx
Dim blnExists
blnExists = pXML.Load(strArcPadAPX)
Dim pNewElement ' Used for new elements that may need to be created alongthe way
'If it doesn't exist, create one
If Not blnExists Then
Set pNewElement = pXML.createNode(1,"ArcPad","")
Set pXML.documentElement = pNewElement
Set pNewElement = pXML.createNode(1,"PREFERENCES","")
pXML.documentElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Get the GPS and PREFERENCES element
Dim pPREFSElement, pGPSElement
Set pPREFSElement = pXML.documentElement.selectSingleNode("PREFERENCES")
Set pGPSElement = pPREFSElement.selectSingleNode("GPS")
'If the GPS element doesn't exist, create it
If pGPSElement Is Nothing Then
Set pNewElement = pXML.createNode(1,"GPS","")
Set pGPSElement = pPREFSElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Get the AVERAGING element
Dim pAVGElement
Set pAVGElement = pGPSElement.selectSingleNode("AVERAGING")
'If it doesn't exist, create it
If pAVGElement Is Nothing Then
Set pNewElement = pXML.createNode(1,"AVERAGING","")
Set pAVGElement = pGPSElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Set the attributes of the AVERAGING element
pAVGElement.setAttribute "enabled", "true"
pAVGElement.setAttribute "point", p_AvgTime
'Save the changes to ArcPadPrefs.apx
pXML.Save strArcPadAPX
'Free resources
Set pXML = Nothing
Set pPREFSElement = Nothing
Set pGPSElement = Nothing
Set pAVGElement = Nothing
'Force ArcPad to reload the settings from ArcPadPrefs.apx
Dim blnSuccess
blnSuccess = Preferences.Read
End Sub
Code:
Sub SetPointAveraging (p_AvgTime)
'Path to ArcPadPrefs.apx file
Dim strArcPadAPX
strArcPadAPX = Application.System.Properties("PersonalFolder") & "\ArcPadPrefs.apx"
'Attempt to create a reference to the MSXML DOM
On Error Resume Next
Dim pXML
Set pXML = CreateObject("Microsoft.XMLDOM")
If Err.Number <> 0 Then
MsgBox "MSXML is not present on this device.", vbCritical, "No MSXML"
Exit Sub
End If
On Error GoTo 0
'Read in ArcPadPrefs.apx
Dim blnExists
blnExists = pXML.Load(strArcPadAPX)
Dim pNewElement ' Used for new elements that may need to be created alongthe way
'If it doesn't exist, create one
If Not blnExists Then
Set pNewElement = pXML.createNode(1,"ArcPad","")
Set pXML.documentElement = pNewElement
Set pNewElement = pXML.createNode(1,"PREFERENCES","")
pXML.documentElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Get the GPS and PREFERENCES element
Dim pPREFSElement, pGPSElement
Set pPREFSElement = pXML.documentElement.selectSingleNode("PREFERENCES")
Set pGPSElement = pPREFSElement.selectSingleNode("GPS")
'If the GPS element doesn't exist, create it
If pGPSElement Is Nothing Then
Set pNewElement = pXML.createNode(1,"GPS","")
Set pGPSElement = pPREFSElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Get the AVERAGING element
Dim pAVGElement
Set pAVGElement = pGPSElement.selectSingleNode("AVERAGING")
'If it doesn't exist, create it
If pAVGElement Is Nothing Then
Set pNewElement = pXML.createNode(1,"AVERAGING","")
Set pAVGElement = pGPSElement.appendChild(pNewElement)
Set pNewElement = Nothing
End If
'Set the attributes of the AVERAGING element
pAVGElement.setAttribute "enabled", "true"
pAVGElement.setAttribute "point", p_AvgTime
'Save the changes to ArcPadPrefs.apx
pXML.Save strArcPadAPX
'Free resources
Set pXML = Nothing
Set pPREFSElement = Nothing
Set pGPSElement = Nothing
Set pAVGElement = Nothing
'Force ArcPad to reload the settings from ArcPadPrefs.apx
Dim blnSuccess
blnSuccess = Application.Properties("Load")
End Sub
Get help from ArcGIS experts
Download the Esri Support App