The problem with PB's built-in structures, such as String and Integer, is that the variable names are the same as the data type. This means that the code in the called procedure requires the data type to be attached to every variable reference. For example:
Code: Select all
Structure String
s.s
EndStructure
Structure Integer
i.i
EndStructure
*VariableName\s = *VariableName\s + ....
*VariableName\i = *VariableName\i + ....
Code: Select all
Macro ByRef (Name, Type)
*Name.ref_#Type
EndMacro
Macro Ref (Name)
; the "x" variable name allows all data types to be handled by the "Ref" macro
*Name\x
EndMacro
Structure ref_i
; the structure variable is named "x" in all data type structures
x.i
EndStructure
;-------
Procedure TestRef(ByRef(Value1, i), Value2.i)
Ref(Value1) = Ref(Value1) + Value2
EndProcedure
Define Value1.i = 55
Define Value2.i = 44
TestRef(@Value1, Value2)
Debug Value1