Variant (PRIM_VAR)

Variant component can be used to store a variant value

Ancestors - Data Class (PRIM_DC) Object (PRIM_OBJT)

Details

A Variant is used to represent a value whose data type is unknown when compiling.
 
The ValueType property is used to test the data type.
 
LANSA is a strongly typed environment. Normally the fields and variables used in an application relate to specific database table columns where the type of data is fixed. Unless the application requires complex generic programming, PRIM_VAR is unlikely to be required for most development purposes.

Example

In this example, the EditorChanged event is returning the value when data is changed in the grid. As the event is defined for any column type, its value must be a variant.
 
Prim_Var is used here to provide feedback as to the kind of data value being changed.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(440) Clientwidth(975) Height(479) Layoutmanager(#TableLayout_1) Left(152) Top(225) Width(991)
 
   Define_Com Class(#PRIM_TBLO) Name(#TableLayout_1)
   Define_Com Class(#PRIM_TBLO.Row) Name(#Row_1) Displayposition(1) Parent(#TableLayout_1)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column_1) Displayposition(1) Parent(#TableLayout_1)
   Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Column(#Column_1) Manage(#Grid) Parent(#TableLayout_1) Row(#Row_1)
 
   Define_Com Class(#PRIM_GRID) Name(#Grid) Captionnoblanklines(True) Columnscroll(False) Componentversion(1) Displayposition(1) Height(440) Left(0) Parent(#COM_OWNER) Showselection(True) Showselectionhilight(False) Showsortarrow(True) Tabposition(1) Top(0) Width(975) Columnbuttonheight(22) Rowheight(22)
   Define_Com Class(#PRIM_GDCL) Name(#GridColumn1) Displayposition(1) Parent(#Grid) Source(#EMPNO) Width(12) Widthtype(Fixed)
   Define_Com Class(#PRIM_GDCL) Name(#GridColumn2) Displayposition(2) Parent(#Grid) Source(#SURNAME) Width(25) Widthtype(Fixed) Readonly(False)
   Define_Com Class(#PRIM_GDCL) Name(#GridColumn3) Displayposition(3) Parent(#Grid) Source(#GIVENAME) Width(25) Widthtype(Fixed) Readonly(False)
   Define_Com Class(#PRIM_GDCL) Name(#GridColumn4) Displayposition(4) Parent(#Grid) Source(#SALARY) Width(25) Widthtype(Fixed) Readonly(False)
 
   Evtroutine Handling(#Com_owner.CreateInstance)
 
      #Com_owner.Load
 
   Endroutine
 
   Mthroutine Name(Load)
 
      Select Fields(*All) From_File(PSLMST)
 
         Add_Entry To_List(#Grid)
 
      Endselect
 
   Endroutine
 
   Evtroutine Handling(#Grid.EditorChanged) Value(#Value)
 
      Define_Com Class(#prim_var) Name(#VariantValue)
 
      #VariantValue := #Value
 
      #Com_owner.Caption := ("&1 - &2").Substitute( #VariantValue.ValueType #VariantValue )
 
   Endroutine
 
End_Com

Properties

NameDescription
BooleanBoolean is the value of the variable as Boolean
ComponentComponent is the value of the variable as component reference
ComponentClassNameComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)
ComponentMembersComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)
ComponentPatternNameComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)
ComponentTagGeneric space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)
ComponentTypeComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)
ComponentTypeNameComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)
DecimalDecimal is the value of the variable as decimal
IntegerInteger is the value of the variable as integer
NameName identifies the component Inherited from Object (PRIM_OBJT)
OwnerOwner owns this component Inherited from Object (PRIM_OBJT)
ParentThe component instance to which this instance is attached. The visual container for a control or the collector of a set of child instances Inherited from Object (PRIM_OBJT)
StringString is the value of the variable as string
UnicodeStringReturns the value of the variant as a Unicode string
UsePicklistControls whether the values in the picklist are enforced Inherited from Data Class (PRIM_DC)
ValueValue of the data class
ValueTypeValueType test the type of value in the variant

Events

NameDescription
CreateInstanceCreateInstance is signalled when an instance of a component is created Inherited from Variant (PRIM_VAR)
DestroyInstanceDestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from Variant (PRIM_VAR)

Methods

NameDescription
AssignEmptyAssignEmpty assigns no value to the variable
AssignNullAssignNull assigns a null value to the variable
GetValueGet the current component value Inherited from Data Class (PRIM_DC)
Value
SetValueSet Field value Inherited from Data Class (PRIM_DC)
Result, Value

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2