Defining structures

Although you define object-level structures in the painter for a specific object and global structures in the Structure painter, in both cases you define the structure in a Structure view. The following sections describe each of the steps you take to define a new structure:

  1. Open a Structure view.

  2. For object-level structures, name the structure.

  3. Define the variables that make up the structure.

  4. Save the structure.

Opening a Structure view

How you open the Structure view depends on whether you are defining an object-level structure or a global structure.

Figure 9-1: Structure view in a PocketBuilder object painter

The structure view has a text box field for the structure name. Below this is a drop down list for the data type of each variable included in the structure. Each drop down field for data type is paired with a text box for the name of a structure variable.

StepsTo define an object-level structure:

  1. Open the object for which you want to declare the structure.

    You can declare structures for windows, menus, user objects, or applications.

  2. Select Insert>Structure from the menu bar.

    A Structure view opens.

StepsTo define a global structure:

  1. Select Structure from the Objects tab in the New dialog box.

    The Structure painter opens. It has one view, the Structure view. In the Structure painter, there is no Structure Name text box in the Structure view.

Naming the structure

If you are defining an object-level structure, you name it in the Structure Name box in the Structure view. If you are defining a global structure, you name it when you save the structure.

Structure names can have up to 40 characters. For information about valid characters, see “identifier names” in the online Help.

You might want to adopt a naming convention for structures so that you can recognize them easily. A common convention is to preface all global structure names with s_ and all object-level structure names with str_.

Defining the variables

By default, the Structure view displays a single string datatype for the structure’s initial variable. You can change this to any PocketBuilder datatype, including the standard datatypes such as integer and boolean, as well as objects and controls such as Window or MultiLineEdit. The default for subsequent variables is the datatype of the previous variable.

Specifying a defined object as a variable You can specify any object types that you have defined. For example, if you have defined a window named w_calculator and you want the structure to include the window, type w_calculator as the datatype. You cannot select w_calculator from the list, since the list shows only built-in datatypes.

Specifying a structure as a variable A variable in a structure can itself be a structure. Specify the structure's name as the variable's datatype.

Specifying a decimal as a variable If you select decimal as the datatype, the default number of decimal places is 2. You can also select decimal{2} or decimal{4} to specify 2 or 4 decimal places explicitly.

StepsTo define the variables that compose the structure:

  1. Select or enter the datatype of a variable that you want to include in the structure.

  2. Enter the name of the variable.

  3. Repeat until you have entered all the variables.

Saving the structure

How you save the structure depends on whether it is an object-level structure or a global structure.

The names of object-level structures are added to the Structure List view and display in the title bar of the Structure view as soon as you tab off the Structure Name box. As you add variables to the structure, the changes are saved automatically. When you save the object that contains the structure, the structure is saved as part of the object in the library in which the object resides.

NoteComments and object-level structures You cannot enter comments for an object-level structure, because it is not a PocketBuilder object.

StepsTo name and save a global structure:

  1. Select File>Save from the menu bar, or close the Structure painter.

    The Save Structure dialog box displays.

  2. Name the structure.

    See “Naming the structure”.

  3. (Optional) Add comments to describe your structure.

  4. Choose the library where you want to save the structure.

  5. Click OK.

    PocketBuilder stores the structure in the specified library. You can view the structure as an independent entry in the Library painter.