I got very similar.
but its all very manual. So inside the "class" you have to keep putting the prefix before it... very bloated and tedious.
I used an array for each member of the object and a count, and some have strings to help do field to text translation, think I even used a call to var to lookup fields. But seeing as most classes have the same fields such as count/type/name or whatever... I kept the class prefix in the name so kinda useless to try to generalize the field access, smilebasic likes unique named.I gave most objects their own "out" functions so they could format their own debug outs.
F=VAR(TI_$[I])'where i is the field
F[object_index]' such as F[player] or F[T] I use T as "this"
I was working with a bunch of fields, like seconds, minutes, hours that were overflowing into each other so I liked to think of things as F and F2 instead of seconds/minutes and it made debug'ing a lot easier.
I=TI_FIELDS-1
F=VAR(TI_$[I])
F2=VAR(TI_$[I-1])
TI_OFLOW T,F,F2
I=TI_FIELDS-2
F=VAR(TI_$[I])
F2=VAR(TI_$[I-1])
TI_OFLOW T,F,F2
I know its ugly but it let me manually debug things, had to unroll a for loop etc. Hope it makes sense...or shows how not to do things at the least ;)
In hindsight it would of been nice to say .sec .min .hour when writing the time handling, made it easier to read etc.
I didn't care to put any object limits in, just push things ontop of their array. do a copy for array to array, if I recall, sb wont' push arrays onto arrays, have to mem copy. which means you have to keep track of where an objects portion of the array begins and ends.
Its all indices. an index that is used by functions, generally one index will work with all the members. battling between what you can read and type in before forgetting how to read an objects value.
all that goes in a separate slot from my main program.
load "PRG1:LIBRARYNAME1",FALSE
USE 1
GOSUB "1:@DEFDT"
VAR CUR=NEWTI(2016,9,20,2,0,0):?"CUR=";CUR
TI_OUT CUR 'will output the time in the "CUR" object
The idea is that being in a separate slot it is out of my way and I can use the time fields with a few update calls or setting new time and now I got timers and a sorta minimal calender support.
Programming in SB is always a tradeoff of what inputs fast, holds some value to re-reading the code, and what keeps good namespace.. obviously I'd run out of namespace as it quickly turns into abbreviations for object names but ohwell.
No inheritance, but objects can have "references" to other objects.. its just an index afterall.
If you are dealing with AX and AY array for aliens. sure that works. and it is very easy to input. You got an "object" or "index" you just need to write the functions on what to do with it. so you get the nice function names that are backwards of the dot operator version
Apple1.set_color("red")
'turns into
AppleSet_color(Apple1,"red")
the goal of object based is to get it so you don't have to type as much, and can forget the nuances of array definition and access... so using the libraries seems the way to go when your objects differ so much from each other that they need their own unique fields that aren't useable by other functions etc.