Using an array in a data type? (Difficult to word the question)

Mickster

Active Member
Licensed User
Longtime User
I've made a few data types in my app.

B4X:
Type Block (DBB As String, POB As String, DOB As String, SpringBack As String, Stacks As Int, YBIFZ As String, _
   BCIFZ As String, SplitDie As String, CNeg As String, CExtra As String, Hold As Int, YSpeed As Int, BSpeed As Int, CSpeed As Int, _
   MandExt As Int, MandTmr As Int, MandOsc As Int, PDTmr As Int, LubeTmr As Int, YOvt As Int, ClampingOrder As Int)
   
   Type datOffsets (YLoad As String, YPark As String, YMin As String, TubeDiameter As String, ColletDepth As String, HitchLength As String, _
   TubeLength As String, ClampLength As String, PDieLength As String)

I want to make a third type called 'Part' that comprises of an array of 30 block variables and one datOffsets variable. Is this possible?

B4X:
Type Part(bl(30) As Block, Off As datOffsets)

This declaration gives me a nullPointerException when I try to use a Part variable.
 

mc73

Well-Known Member
Licensed User
Longtime User
I understand. Yet why not simply adding in your second type something as
B4X:
type part(listOfBls as list,listOfDatOffsets as list)
In the list of bls and of Off, you can add the components you want. If I don't get it wrong somewhere of course, which is probable.
 
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
I suppose that could work, though it isn't a tidy as I'd like. I need to access this data in quite a few places and as you can see there are quite a few complicated sounding names. The b4a ide won't recognise the data type 'block' when it returns the variable from the list and so I won't be able to select the variable that I'm looking for from a suggestion list. It just means that accessing the data I want would be more hassle.

I realise it sounds like I'm fussing over nothing, but I'd much prefer for my app to be able to access this data 'tree'. If it can't then I'll see how the lists do.
 
Upvote 0

bartv

Member
Licensed User
Longtime User
Couldn't you create a class with just a number of subs for getting/setting the fields? You could even throw in some logic if it should become necessary.
Haven't tried it, though...
 
Upvote 0
Top