Basic has UDT. This feature seems to be rarely used, but would be expedient in specific cases.
However, variables of such types are always treated as references (ByRef
) even by user defined subroutines where the respective prameters are qualified as ByVal
. The reference also is persistent if the routine does Redim Preserve
the parameter or a variable to which it was assigned.
Since there also is no way to get info about the fields of the type, it seems there is no way to get a deep copy breaking the inherited reference by a Function
or a Sub
. An assignment to any field of the intended copy will also afflict the respective field of the original: Only the reference was copied.
Is there remedy?
Related problem with arrays: Apache OpenOffice Community Forum - OpenOffice BASIC: Create an independent copy of an array. - (View topic)
A class module might help. I never used them with StarBasic. Think of multiple instances of the same module, each instance initialized with its own set of variable values.