Array in an array - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Array in an array (/showthread.php?tid=1476) |
RE: Array in an array - TempodiBasic - 02-18-2023 @QB64 community, @QB64 developers, @NasaCow about this QB64 code Code: (Select All) OPTION _EXPLICIT after copying and pasting this code into QB64 I have got an "OK" while I was expecting an Error Alert! Why does QB64 compiler accept the declaration of array with variable as index delimiter? On running it is clear why line 10 and line 20 give the same result as output. Waiting your opinions... RE: Array in an array - TempodiBasic - 02-18-2023 another snippet for studying how QB64 manages the declaration of an array Code: (Select All) Option _Explicit RE: Array in an array - Kernelpanic - 02-18-2023 Quote:after copying and pasting this code into QB64 I have got an "OK" while I was expecting an Error Alert! The reason probably lies in this: A redimensioning takes place because the declaration of the array is not static. QBasic Manual Page 181: "Dynamic arrays are always created if no constant value is given in the DIM statement - arrays declared as COMMON are also declared dynamically." Static Arrays: Const xyz = 100 Dim x(elements) Dim p(10) a! (2) = 3.1315 -> Array is implicitly declared static RE: Array in an array - TempodiBasic - 02-19-2023 @nasacow I have loosen the structure of data that you have planned.... I see a StudentType, a MasterAssignment and a SlaveAssignment. In the first and in the last structure you use an ID to identify and correlate the data. In MasterAssignment there is no ID. You like to have all the data into one file. I think that to keep in one file all the data you need to use an ID also for the third structure of data. In this manner you can access to the searched data using the ID as index: here an example this is the file ________________________________________________________________________________________________ |long digit| records of StudentType|long digit|records of MasterAssignment|long digit|records of SlaveAssignment|CRC| |_______ |___________________________ |_______________________ |______________________________|___ | ^ ^ ^ ^ ^ ^ ^ | | | | | | | number of |_________DATA number of |_________DATA number of |_________DATA |__Security data Student records Master Assignment Slave Assignment records records while in RAM you load the data into 3 array with which you can work. RE: Array in an array - TempodiBasic - 02-21-2023 Hi @KernelPanic I do not know how and why I missed my 2 different answers to your post! I said thank you to show me why is possible to use a variable in declaration of an array, doing this array Dynamic so resuming: Code: (Select All) Dim Min As Integer RE: Array in an array - bplus - 02-21-2023 Nope! It is not about using variables for lbound or ubound. REDIM MyDynamicArray(... ) ' this is dynamic DIM MyStaticArray(... ) ' this is static Quiz: How do you reset all values to 0 (or "") in Static Array, how do you do it with Dynamic Array? RE: Array in an array - Kernelpanic - 02-21-2023 Quote:@KernelPanic Forget it! What do you think I have all missed in my life. . . Take it easy! RE: Array in an array - mnrvovrfc - 02-21-2023 (02-21-2023, 01:07 AM)bplus Wrote: Nope! It is not about using variables for lbound or ubound. If it's static "ERASE" is enough to reset all members. Cannot do it to a dynamic array unless the programmer is ready to re-allocate it. Otherwise for an array could use a _MEM variable, compute the size of the array extent and use _MEMFILL to set all elements to zero. Need a variable of the same basic type as the array only to set to zero because _MEMFILL requires a reference, cannot be a constant. Might be able to do the same thing with an array of fixed-length strings. Cannot use _MEM toward VLS's so it's harder. There's always the slow way of using a "FOR... NEXT" loop to set to zero or to the empty string. Cannot use "CLEAR" because it blanks out all other variables whether or not they are static. RE: Array in an array - bplus - 02-21-2023 @mnrvovrfc ERASE is correct for Static array. The easy answer for Dynamic array is to just REDIM it again. RE: Array in an array - TempodiBasic - 02-21-2023 (02-21-2023, 01:07 AM)bplus Wrote: Nope! It is not about using variables for lbound or ubound.Hi dear Please read #23 Or at this link Dim & Redim DIM myArray (1 to 4) AS INTEGER ' this is static DIM my2ndArray (1 to M) AS INTEGER' This is dynamic and M =0 IMHO Dynamic Array When you change dimensions of array it is restored to default value (0 or "") |