Procedure: Creating extended composites

Follow this checklist to create an extended composite data type and field.

  1. Create the data types for the components.

Determine the maximum number of components that will be in the composite and create an individual data type for each component. Data types used for components of a composite shouldn’t be used for other fields.

  1. Create a field for each component of the composite.

 

  1. Create the composite’s data type.

Open the Data Type Definition window. Enter the name for the data type, select Composite from the Control Type list, then click the Composite lookup button; the Composite Lookup window will open.

Click New to open the Composite Definition window. Name the composite, then highlight each component in the Fields list and click Insert to add it to the composite definition. The order of the components is significant; the first field in the Components list is the first component of the composite, the second field is the second component, and so on. Be sure that all fields that will be components of the composite have been inserted into the composite. Also, no component can be used in more than one composite. When you are finished adding components, click OK to save the composite.

  1. Apply a format to the composite.

Create and apply a basic format with a format string to the first few components of the composite, just as you would for a standard composite. The number of components in the format string isn’t critical; the format string just has to exist. This “starting” format will be overridden at runtime.

  1. Create a field that uses the composite data type.

 

  1. Add the composite field to the main window of the Main Menu form for your application.

The field should be made invisible and display only by setting the Visible and Editable properties for the field to False.

  1. Override the composite format.

In the Main Menu form pre script, use the override field statement to specify the separator character for the composite and whether scroll arrows will be displayed. Use the override component statement to indicate how many components of the composite will be displayed, the size of the individual components and the character that will be used as the width base for each component.

An extended composite can have only one type of separator character. This character can be the “empty” character (""). When using the override component statement to set the number of components to display and the component length, remember that the total length of the composite must not exceed 128 characters, including separators. Components at the end of the composite are the only ones that can have their length set to 0, indicating they won’t be displayed by the composite.

  1. Use the extended composite field.

The extended composite field can be used in any windows except windows associated with the Main Menu form, because it won’t have the proper format in those windows.

When you add the extended composite field to a window, you must set the size of the field in the window manually, since Dexterity has no way of knowing how large to make the field.


Example

This example describes how to create and use an extended composite for a customer number with up to 12 components. Twelve string data types and fields were created for the extended composite, one for each component. The following “starting” format string was used when the format for the composite was created:

11111-22222-33333

 

The starting format string serves only as a placeholder. The structure and number of components aren’t critical because the format will be overridden at runtime.

A field was created using the composite data type, placed on the main window of the Main Menu form and made invisible and display only by setting the Visible and Editable properties for the field to false.

The customer number composite will have the following characteristics:

[spacer]

Number of components to display

6

Separator character

:

Length of the components

Component 1

5

Component 2

4

Component 3

4

Components 4 to 12

2

Display scroll arrows

Yes


The following is the Main Menu form pre script used to specify the characteristics of the customer number composite:

local integer segment;
local string separator, width_char;
local integer maximum_num_segments, num_segments;
local integer seg_length[12];
local boolean scroll_arrows;
maximum_num_segments = 12;
{Specify how long each segment will be when it's stored and displayed. In an actual application, this information would be stored in a table.}
seg_length[1] = 5;
seg_length[2] = 4;
seg_length[3] = 4;
seg_length[4] = 2;
seg_length[5] = 2;
seg_length[6] = 2;
seg_length[7] = 2;
seg_length[8] = 2;
seg_length[9] = 2;
seg_length[10] = 2;
seg_length[11] = 2;
seg_length[12] = 2;

{A colon will be used as the separator character.}
separator = ":";

{Turn the scroll arrows on for the composite.}
scroll_arrows = true;

{Six segments will be displayed.}
num_segments = 6;

{W will be used as the base width character.}
width_char = "W";

{Use the override field statement to set the separator and turn 
on scroll arrows for the composite.}
override field 'Customer Number' of window 'Main Window', separator, scroll_arrows;

{Use the override component statement to set the storage and display length of each component of the composite. If a segment at the end of the composite won't be used, set its length to 0.}

for segment equals 1 to maximum_num_segments do
	if segment <= num_segments then
		override component segment of field 'Customer Number' of window 'Main Window', seg_length[segment], width_char;
	else
		override component segment of field 'Customer Number' of window 'Main Window, 0, width_char;
	end if;
end for;


Documentation Feedback