Array in an array - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Array in an array (/showthread.php?tid=1476) |
RE: Array in an array - bplus - 03-01-2023 You folks have sure wandered far from the main subject problem of OP. Associative arrays really aren't a solution to arrays of arrays but are an interesting topic on their own. TempodBasic and I have kicked them around with a Rosetta Code Challenge on the old forum. Too bad a new thread on that subject was not started. RE: Array in an array - madscijr - 03-01-2023 (03-01-2023, 04:00 PM)bplus Wrote: You folks have sure wandered far from the main subject problem of OP. I agree that associative arrays on their own are not a solution. If you see my original reply in this thread, what I suggested wasn't an associative array, but a data structure similar to objects in JavaScript - and not OO, with methods / classes / etc., but just a data structure allowing nested arrays, dictionaries & objects, and functions for serializing/deserializing to & from JSON (which would solve the issue of persistence, since reading/writing JSON as text is trivial). RE: Array in an array - Sprezzo - 03-02-2023 Now that this thread is 6 pages long, here comes a bucket of saltwater: Linked Lists Look them up anywhere but here. RE: Array in an array - mnrvovrfc - 03-02-2023 Not much different from handling associative arrays the "traditional" way. However it's possible now with the _MEM gang. Copy that old source code from Turbo Pascal, however in QB64(PE) the pointer is always neutral. I don't know if the _MEMGET and _MEMPUT syntax works with UDT "as <type>" being the final parameter. Might be able to arrange it coding in C++, and write subprograms in QB64(PE) to make a request to add an element, to count the number of list elements, to change the reference of one of the members, and so forth. The trade-off is that the programmer might have to hard-code the UDT to make it simpler. RE: Array in an array - bplus - 03-02-2023 (03-02-2023, 08:34 AM)Sprezzo Wrote: Now that this thread is 6 pages long, here comes a bucket of saltwater: Linked Lists Easy to bitch not so easy to teach. So why not try showing us what you mean? I suggest another thread. RE: Array in an array - SpriggsySpriggs - 03-02-2023 I have no problem with MEM being used but in my opinion it should always be used with MEMGET instead of some weird algorithm for accessing the data within. To my knowledge, MEMGET does work with UDTs. You just can't have any variable-length strings in the UDT or else it won't work right. RE: Array in an array - bplus - 03-02-2023 (03-02-2023, 05:19 PM)Balderdash Wrote: I have no problem with MEM being used but in my opinion it should always be used with MEMGET instead of some weird algorithm for accessing the data within. To my knowledge, MEMGET does work with UDTs. You just can't have any variable-length strings in the UDT or else it won't work right. Variable length strings do work in UDT, you just can't file them in a records format. I am not sure if MEMGET or Memory techniques can work with variable length strings inside or outside of a UDT. RE: Array in an array - SpriggsySpriggs - 03-02-2023 @bplus Yeah, variable length strings work in UDTs. I was talking about MEMGET on a UDT that has variable length strings. RE: Array in an array - bplus - 03-02-2023 Ah! thanks for clearing that up RE: Array in an array - Dimster - 03-02-2023 In terms of an Array in an Array, if the index could work with decimal values, theoretically you could create an array of multiple layers making say the whole numbers the name of the student and decimal values could associate with that student. For example all .5 could carry attendance, all .9 carry math test score etc. The expansion could be limitless. But it doesn't work. Here is my attempt Code: (Select All) Dim Shared TestArray(1.1 To 2) The results provide only 1.4 or 1.9. Why I don't know. |