Customization style guide

Customization style is a personal preference, and you have a near limitless choice of how to write commands and scripts that are used to interact with ArcPad.

Each scripting language has its own notation, but there are style choices that can be made, regardless of language, that help you read and reuse script code.

Hungarian notation

Apparent in ArcPad documentation is the use of Hungarian notation. Language independent, Hungarian notation is the convention of naming variables and functions based on their type or intended use.

The name of a variable is usually comprised of two parts, a defining prefix and a given name. Common prefixes in Hungarian notation are obj, txt, cbo, and lbl (denoting object, text, combo box, and label respectively). These prefixes pre-pend the descriptive name of the variable whose first character is capitalized. The following are common variables:

Prefixes are not used with function names; however, the first letter of each word is capitalized. The following are common functions:

Using Hungarian notation makes commands and scripts easier to read.

Recommended coding style

For example, to reference a control (in this case a text box), the following VBScript coding styles all achieve the same outcome.

The first style may be considered simple because it lists the complete command, on just one line.

declaring a script object, and setting it to the txtName control

Dim objControl
Set objControl = Application.Applets("CustomSettings").Forms("frmSettings").Pages("pgPage1").Controls("txtName")

The second style may be considered better because each portion of the command is separate and would be easier to troubleshoot if there were errors.

declaring a script object, and setting it to the txtName control

Dim objApplet, objEditForm, objPage, objControl
Set objApplet   = Application.Applets("CustomSettings")
Set objEditForm = objApplet.Forms("frmSettings")
Set objPage     = objEditForm.Pages("pgPage1")
Set objControl  =  objPage.Controls("txtName")

By declaring and setting each object alternately, the third example is easy to work with, typographical errors stand out (because variables align), and commands and their declarations can easily be duplicated to grow the script.

declaring a script object, and setting it to the txtName control

Dim objApplet
Set objApplet   = Application.Applets("CustomSettings")
Dim objEditForm
Set objEditForm = objApplet.Forms("frmSettings")
Dim objPage
Set objPage     = objEditForm.Pages("pgPage1")
Dim objControl
Set objControl  = objPage.Controls("txtName")

In this Help system, the third style is predominately used.

It is common practice for ArcPad users to copy and clone samples for use in their own projects, and this kind of development is encouraged. By making samples easier to read, a broader group of people are able to make use of them, and the samples can be used for a broader range of activities.

Modular customization

ArcPad customization is completed using one or both of the following file types: ArcPad XML files and script files (VBScript, JScript, or Python). Although ArcPad Studio provides a user interface that allows you to enter script code inside an ArcPad XML file, it is recommended to store scripted functions in a separate script file that's associated with your ArcPad XML file. This makes troubleshooting and code sharing easier. Only a reference (or call) to the script function should be entered inside the ArcPad XML.

For example, in the Redlands tree sample installed with ArcPad, the Tree.apl file contains XML that describes the contents of the tree layers' edit form. It also denotes that a script file, Tree.vbs, is associated with the tree layer. The Tree.vbs file contains all of the scripted functions that are referenced in the Tree.apl file.

Calls to functions differ slightly in each scripting language. The following three examples show how to call the function CalculateArea in VBScript, JScript, or Python.


Call CalculateArea





A call to a script function can optionally contain parameters. When parameters are included, they are listed at the end of the function name, inside closed parenthesis. When no parameters are included and scripting with JScript, the parenthesis are still required. When no parameters are included and scripting with VBScript or Python, the parenthesis are optional.

Grouping all script functions into a single file enhances code readability and can reduce the complexity of your customization by allowing reuse and optimization.

Separating scripts from XML is a recommended general practice when using VBScript and JScript. For Python, separation is a requirement. When using Python in the ArcPad Studio event script window, only the first line of code is recognized by the Python interpreter. Python code that can be contained on a single line can be used, but it is recommended to use the single line to reference Python code in another file.