Author Topic: Nested arrays?  (Read 1460 times)

0 Members and 1 Guest are viewing this topic.

Offline 40wattstudio

  • Newbie
  • Posts: 82
    • 40wattstudio
Nested arrays?
« on: March 08, 2020, 02:16:55 pm »
Hi everyone!

I've heard of nested loops in QBasic, but is there a way to implement nested arrays (which I understand to be one array inside of another)?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Nested arrays?
« Reply #1 on: March 08, 2020, 03:32:07 pm »
Hi everyone!

I've heard of nested loops in QBasic, but is there a way to implement nested arrays (which I understand to be one array inside of another)?

Yes there is a way, it will take some cleverness on your part here is a great tool for doing this:
https://www.qb64.org/forum/index.php?topic=1607.0

Use different delimiters to break string into elements (sub strings) which are in turn broken by a different delimiter. Is it JS that splits first by ";" and then by "," ? ( or vice versa)

I also have a Word tool that could be applied for this task.

I don't know what QBasic had but this method could be applied in any decent PL.

I have used this method to save (x, y) point locations in Type definition with non fixed String (but you can't save this Type element to file).
« Last Edit: March 08, 2020, 03:34:48 pm by bplus »

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
Re: Nested arrays?
« Reply #2 on: March 08, 2020, 03:37:28 pm »
There are of course multidimensional arrays. But yeah - if you're looking for abstract arrays in arrays, you probably need to dip into string space.

HOWEVER... I really wish we had a developed section on linked lists right now, those would handle this to a tee. Maybe I'll hit that soon.
You're not done when it works, you're done when it's right.

Offline 40wattstudio

  • Newbie
  • Posts: 82
    • 40wattstudio
Re: Nested arrays?
« Reply #3 on: March 08, 2020, 03:58:41 pm »
Thanks for the feedback bplus and STxAxTIC!
I'll try that tool and see if I can get it to work. In my case though I'm just dealing with integers and not strings. Hopefully that means it'll be easier since I'm dealing with just the one datatype.
Fingers crossed!