I have two global structures, let’s call them Struct1 and Struct2.
I like to be able to convert between those two without having to explicitly invoke a function for this. Like using Operator_Convert:
dim s1 as Struct1
dim s2 as Struct2
s2 = s1 // this is what I want to be able to write
However, it seems Operator_Convert only works with Classes. Since these are Structures, I wonder if there’s another way to make the above work.
Can you use
s2.ByteValue=s1.ByteValue
Nope, values are different - I have to convert the values individually.
Copy to string and back to structure.
Unlike classes, structs have no v-table of methods so there is no way to add operator_XXX to structs. The best youll be able to do is an extends methods that extends struct1, does the conversion and returns a struct2
ie/
dim s1 as Struct1
dim s2 as Struct2
s2 = s1.ToStruct2
dim s1 as Struct1
dim s2 as Struct2
s2.stringValue = s1.StringValue
if you want to move the bytes.
Yes, Jason, thanks for clarifying - that’s actually my current work-around.
I’d hoped that there’s a global kind of Operator_Convert that would let me define both the input and output type.