Structures

Definition and declaration of structures

Defining a structure in the Structure painter or an object painter is supported:

  • If the structure is defined in the Structure painter, the structure is global structure, and instances of the structure can be declared in a script or in an object's instance variable.

  • If the structure is defined in an object painter, the structure is an object structure, and instances of the structure can only be declared in the object's instance variables and script. An object structure can be defined in any of the following painters: Application, Window, Menu, Function or UserObject.

Declaring global or local instances for global structures is supported. Declaring instance and local instances for object structures is also supported. Several instances for a structure can be declared at one time.

For example:

str_emp_data str_emp1, str_emp2

Declaring structure arrays is supported.

The arrays can be single or multi-dimensional, variable-sized or fixed sized. The supported features for structure arrays are the same as the supported features for any other arrays.

For example:

s_ employee lstr_temp[10] s_ employee lstr_employee[]

If an object structure's name is identical to that of a global structure, the object structure has higher priority than the global structure (same as in PowerBuilder).

Referring to structure variables

The following syntaxes are supported:

structurename.variable   //referring to a structure variable by using dot notations
objectname.structurename.variable   //referring to a variable of an object structure

For example:

str_emp1.emp_lname = "Jones" 
This.str_cust1.name
w_customer.str_cust1.name

Initialization and assignment of structure variables

For each variable of a structure, the variable will be initialized with default values according to its data type. If it is a string type variable, the default value is ""; if it is numeric type variable, the default value is 0.

A structure instance can be assigned when it is declared or after it is declared.

For example:

s_employee lstr_ouremployee1, lstr_outemployee2
s_employee lstr_youremployee = lstr_ouremployee1
lstr_youremployee = lstr_ouremployee2

As in PowerBuilder, when assigning one structure to another, the whole structure is copied so that there are two copies of the structure.

Passing structures as arguments

Passing structures as arguments by value, by reference, or as read-only is supported.

Complex structures

The following types of complex structures are supported:

  • Structures which have one or more of their structure variables being referred to another structure.

  • One or more structure variables which are autoinstantiated or non-autoinstantiated objects.

    For example:

    s_employee lstr_employee[]    //the structure
    s_employee is defined with a DataWindow type variable
    long ll_employee
    lstr_employee[1].adw_employee=w_employee.dw_1
    ll_employee=lstr_employee[1].adw_employee.Retrieve()
    
  • One or more structure variables which are arrays that have no unsupported features.

Unsupported

  • Cross-definition of structures. For example, structure A has a structure variable that is structure B, while structure B has a structure variable that is structure A.

  • Inheritance of an object structure is unsupported; inheritance of an object structure instances is unsupported as well.

  • If one or more member variables in the structure are unsupported data types, Appeon still supports the structure as long as unsupported variables are not used.

  • If there are member variables of enumerated data type in the structure, the default values of the enumerated variables are unsupported.

  • Comments of the structure are unsupported.