I was wondering, how exactly do unions work and can I use them for this? For example, if I declare
Code: Select all
structure PTime
TStr as string(7) union
Mins as string(4) union
Secs as string(3)
end structure
What I'm thinking is that I can do PTime.Mins = DecToStr(Time/60,3," ") to get minutes, then PTime.Secs = DecToStr(Time mod 60,2) which will give me seconds and terminate TStr with a null. Then I do PTime.TStr(3)=":" to replace the terminator I got from the minutes conversion.
That should give me a string MMM:SS? Or am I misunderstanding structures and unions? Is there a better or simpler way to do this?
(I understand I need to declare a variable as the structure, this is just an example)