Table Of Contents

Creating a Custom Data Type Using a G Type Document

Last Modified: February 19, 2020

Create a type definition, or custom data type, to reuse a control or constant throughout your project. You define the type definition with the control you add to the panel of a G Type document.

An example of when a type definition would be useful is keeping state enums of a state machine in sync. Because instances of a type definition share a source file, you can update the source enum, the type definition, with additional states as needed and propagate the changes to all instances rather than having to update each copy individually.

  1. From the Project Files tab, expand the New menu and select Type Definition to create a G Type document.
  2. In the G Type document, add a single control, array of controls, or cluster of controls that you want to reuse throughout your application. The data type of the control you add to the G Type document panel defines the data type of the type definition.

    Adding more than one control outside of an array or cluster or more than one array or cluster of controls to a G Type document makes the type definition unusable.

  3. In the Item tab, configure the control with the settings you want to persist to each instance of the type definition.

    When you place an instance of a type definition onto the panel, the type definition control is identical in type, appearance, and configuration to the control you use to define the type definition in the G Type document. Make sure the control you add to the G Type document is of sufficient size to display all necessary data. If you need to adjust the size or configuration of a type definition instance, you must modify the control in the G Type document.

  4. Save the G Type document.
Drag the type definition from the Project Files tab to the panel or diagram to add an instance of the type definition to your code.

Recently Viewed Topics