Creating a Structure-Valued Property

InstallShield 2022

To create a property whose value is a data structure, add the following to your object script:

A global declaration of the data structure; for example:

typedef STRUCT

begin

    NUMBER Mem1;

    NUMBER Mem2;

end;

A declaration of a read-only property whose data type is OBJECT. (To write values to the property, you will define a method.) For example:

property(get) OBJECT StructProp();

 

Place this declaration in the Properties Section block of the object script.

A declaration of a variable to store the property’s value within the object script. For example:

STRUCT m_structStructProp;

 

Place this declaration in the Local Variables Section block of the object script.

A declaration of a method with an argument of the appropriate data type corresponding to each member of the data structure. For the STRUCT structure defined above, the following is an example of an appropriate method declaration:

method NUMBER SetStructProp(NUMBER, NUMBER);

 

Place this declaration in the Methods Section block of the object script.

Statements, in the InitProperties function block, that initialize the members of the variable that stores the property’s value. For example:

m_structStructProp.Mem1 = 3;

m_structStructProp.Mem2 = 5;

Function calls and statements, in the ReadProperties function block, to retrieve the property member values stored in the property bag object. The function calls have the following syntax:

<ReadxxxxProperty> ( PropertyBag, "<storage name for member value>", <member value variable> );

<ReadxxxxProperty> is the ReadxxxxProperty function that is appropriate to the data type of the property member’s value. For example:

ReadNumberProperty(PropertyBag, "StructProp_Mem1", nStructPropMem1);

 

For each such function call, add below it a statement that sets a member of the property variable equal to the value that the function retrieved. For example:

m_structStructProp.Mem1 = nStructPropMem1;

 

Function calls, in the WriteProperties function block, to save the property member values to the property bag object. The function calls have the following syntax:

<WritexxxxProperty> ( PropertyBag, "<storage name for member value>", <property variable member> );

 

<WritexxxxProperty> is the WritexxxxProperty function that is appropriate to the data type of the property member’s value. For example:

WriteNumberProperty(PropertyBag, "StructProp_Mem1", m_structStructProp.Mem1);

 

A get_<property name> function block defining the property’s get procedure—that is, defining the actions that are executed when the property’s value is read by a project containing the object or by the object’s design-time wizard (if any). For example:

function OBJECT get_StructProp()

begin

    return m_structStructProp;

end;

A function block defining the method that you declared; this method sets the members of the property variable equal to the arguments passed to the method. For example:

function NUMBER SetStructProp( nMem1, nMem2 )

begin

    m_structStructProp.Mem1 = nMem1;

    m_structStructProp.Mem2 = nMem2;

end;