Modifying Values in ArcPad
Letting field-workers "have it their way"
By Craig Gallant, LJB Inc.
Every good form for field data collection needs some user input. However, no matter the amount of front planning, that field crew worker is always going to want one more choice. With the release of ArcPad 8.0 (which now includes ArcPad Studio), it is a good time to optimize existing code or begin planning more efficient code for new projects. This article assumes you already have a project and want to improve the interaction of users with your form using combo boxes and simple INI files. A ComboBox is a commonly used graphical user interface that is a combination of a drop-down list and a text box. It allows the user to either directly type a value in the field or choose a value from a list. A ComboBox could be used on a form for locating fire hydrants. The names of several types of fire hydrants could be stored in a ComboBox so the user chooses rather than enters the name. Values are added to the ComboBox using the List Values tab. The downside to this approach is that every time a new item needs to be added to the combo box, that change must be made in the office, then saved to each field unit. Another solution might be to use an external list from a database. The advantage with this approach is that values aren't added to the form. Any database table can be used as a list for the combo box. However, with both approaches, values can't be easily changed in the field. However, storing all ComboBox values in a list in an INI file will allow users to change the ComboBox values in the field. An INI file is a simple text file with a header in brackets and a list of items. This type of file has been around for a long time. While it might be considered out of date, especially given the popularity of using XML files, an INI file is particularly beneficial in this situation because the end user can open a simple text file editor, such as NotePad, and simply add to the list. The end user doesn't have to worry about the nodes and structure of an XML file. While being able to edit the combo boxes outside ArcPad has its merits, there needs to be a way to edit the values inside the program too. The Solution: Add a Preference Form One way to edit values in ArcPad is to add a preference form to the application. Here's how to do it. Open an existing applet or create a new applet. Click the Forms button on the main toolbar. When the Forms dialog box opens, click the Add button to add a generic form to the applet that is not associated with any layer. Because this form isn't associated with a layer makes it good for a preference form that can be used for several different applications. On the new form, place a label, combo box, check box, text box, and three buttons. This format can be used for multiple pages to help keep a consistent look and feel for the preference dialog box. Now that the controls are on the form, events can be wired up for each control. Onload Event for the Form Let's start with the onload event of the form. (Refer to Listing 1.) First, add a global variable with a value of true. This will be used throughout the form to tell the ComboBox whether to read the INI file every time this control gets the focus. Set the initial status of the controls as shown in Listing 1. Set the enabled property for the Add button, update button, and text box values to false. Then set the check box value to 0. This is the unchecked value.
The properties of the ComboBox controls are shown on the List Values tab.
50 ArcUser Fall 2009
The Hydrant INI file from the sample application is shown in Microsoft Notepad.
The completed Preferences dialog box.
www.esri.com