Dinamic array creation

Cableguy

Expert
Licensed User
Longtime User
Hi guys...
I've never been to keen on working with multi-dimension arrays, or any kind of arrays for that matter, but..now I really have to, so I have some questions....

Imagine a I have to populate a series of arrays from a file....

1st-Is it possible to name an array after a variable? - My bet is "No"

2nd- On that file I have an "Firms" list, wich populates an array called "firms", then I have a list of "devices", wich a particular "Firm" uses....
The user will be able to add to the file, in the respective fields, as much Firms and related devices, as they wnat, but hardly more than 10 firms, and each no more that 7 to 10 devices....

Do I create the 10 arrays for the devices or is it possible to create them as I need, ie, The Firms array have 8 Firms, so I create 8 Devices arrays, one for each firm, and if in the next run, I have only 7 or 9 Firms, I would create as many Device Array...
I guess I'm a bit confusing, but that's me...

I need suggestions Please!!!
 

Byak@

Active Member
Licensed User
hm, can you use a HashtableEx?or in your program you need a Array?
 

Byak@

Active Member
Licensed User
hashtableEx can be converted to array
 

agraham

Expert
Licensed User
Longtime User
Why not use Arraylists which can be created at run time and are dynamic in length? The new syntax in v6.90 for controls created at runtime will make handling them a bit easier

B4X:
  AddArrayList ("AL" & index)
  ...
  ArrayList("AL" & index).Item = something
 

klaus

Expert
Licensed User
Longtime User
Attached a small example with two 2 dimension array variables.

Firm(FirmI,type) FirmI actual firm index
Firm(FirmI,0) = firm name
Firm(FirmI,1) = firm's number of devices
and
FirmDevices(FirmI,DeviceI) = device name
FirmI actual firm index DeviceI actual device index

You can add, insert or delete firms and devices.

Best regards.
 

Attachments

  • FirmDevices.zip
    2.1 KB · Views: 204

Cableguy

Expert
Licensed User
Longtime User
Thanks for all the input....

@Byak@, I was hoppng NOT to add more dll's just for this purpose, and I did not quite understood the idea...

@Andrew, Although I am registered as a beta tester, and because i've been a bit away from the forum, I still haven't got the beta of the new version of b4ppc, but I like the idea you set on the table....

@Klaus, as always, a nice and very elegant solution for any problem, This I may use as a starting point...
 
Top