Description
Loads all values from the ArcPadPrefs.apx file into ArcPad.
Syntax
Example
A subroutine that turns point averaging on and sets it to the input value in ArcPad:
Preferences Object Example (VBScript) | Copy 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 |
See Also