8
« on: August 09, 2020, 01:31:01 pm »
There's definitely some internal bugs when it comes to those. Before I found out this feature was added, I had several Types for various objects, but any strings were put in separate arrays like this:
'All the following code is just for examples
REDIM SHARED Obj(0 TO n) AS ObjType
REDIM SHARED ObjText(0 TO n) AS STRING
Both arrays always had the same numbers of elements so it was easy to reference the strings for whatever objects I needed. This worked great and was better than trying to use fixed-length strings in Types.
But when I found out about variable-length strings added to Types, I added the strings to my Types like this in order to clean up my code:
Type ObjType
a as integer
b as integer
Text as string
End Type
REDIM SHARED Obj(0 to n) AS ObjType
After I did this, my program became possessed, weird bugs would happen, some that were even different if I ran the program at another time, even though no code changed.
They appear to be related to the internal memory of how QB handles the strings in the Types.
The bugs seems to always happen in places when I would get the Len of the string -> LEN(Obj(id).Text). I checked and the function is returning the correct length in all my tests, so there's something more internal going on. There seems to be memory overlaps, causing random elements and objects to change their behavior because memory locations are being corrupted.
Another thing that might be affecting it is I have several dozens of objects, each being REDIMed _PRESERVEd when they were created/added to the array, maybe that has something to do with it.
So after scratching my head all day looking if it was my own code, I came to the conclusion that it wasn't my code and put my code back to what it was, putting the strings back in separate arrays. After I did that, my program became normal again working perfectly.
Sorry I can't be more specific, the bugs were really random and weird, but I can tell it's some internal memory problem.