Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array in an array
#6
(02-15-2023, 03:17 AM)NasaCow Wrote:
(02-15-2023, 02:43 AM)OldMoses Wrote: An array in an array... could a multi-dimensional array work here? Say, make a two dimensional array of the SlaveAssignmentType, with the first dimension being indexed to the MasterAssignmentType and the second dimension to the NameListType. The order depending upon which is most likely to need REDIMing during use, should that be necessary. REDIMing the second dimension is trivially easy using REDIM _PRESERVE, but REDIMing the first dimension would require a bit more effort; copying, REDIMing then restoring the copy to the original array.

That was how I approached doing an RPG character generator that juggled multiple characters at one time, each of which had multiple data points that each had to be unique to them.

In a nutshell, this is what I am trying to do but I am not seeing how to index the array to two different UDT. Could provide a code snippet on how to create and change elements? I understand what you are say but having a hard time to see how to code it.


On further reflection what you said and it got me thinking. I could index INSIDE the slave file, it just needs to be a standard array and could get large (number of students times number of assignments). I just needed to hear different ideas from different people to think how to make it work. I think this would work.

Code: (Select All)
TYPE MasterAssignmentType 'Needed to populate the top (assignment list)
    ARName AS STRING * 20 'Assignment report name
    ADName AS STRING * 10 'Assignment display name (short name)
    AType AS UNSIGNED BYTE 'Assignment Type (Completeion, formative, summative, etc.)
    ACat AS STRING * 20 'Assignment Category (subject, unit, etc)
    AColor AS UNSIGNED BYTE 'Color coding assignment headers and for grouping for reports
    ACode AS UNSIGNED BYTE 'Reserved
    APts AS UNSIGNED INTEGER 'Total points allowed
    AID AS INTEGER 'Unique assignment ID
END TYPE

TYPE SlaveAssignmentType 'Needed to fill in the gradebook
    UID AS INTEGER 'UID will match the stuedent name list to match results, negative UID means deleted and we will ignore it on display and reports
    AID AS INTEGER 'Know which student points are going with each assignmnet
    MPts AS UNSIGNED INTEGER 'Points earned for each particular students
    Flags AS UNSIGNED BYTE 'See below for codes
    Flags2 AS UNSIGNED BYTE ' Reserved
    Notes AS STRING * 512 'Comments for a student's work
END TYPE

Adding an assignment ID, I can use the UID and AID like an (X,Y) and print the proper numbers and flags into each box. Thanks for pointing me in the proper direction! Big Grin Big Grin Big Grin

You're welcome.

I was envisioning something like the following

Code: (Select All)
TYPE NameListType 'Used for the student name database
    PinYinName AS STRING * 20
    FirstName AS STRING * 20
    MiddleName AS STRING * 20
    LastName AS STRING * 20
    Year AS INTEGER
    Month AS INTEGER
    Day AS INTEGER
    HouseColor AS STRING * 8
    MomName AS STRING * 30
    MomPhone AS STRING * 20 'Saved as string to support symbols and international prefixes
    MomEmail AS STRING * 38
    DadName AS STRING * 30
    DadPhone AS STRING * 20
    DadEmail AS STRING * 38
    UID AS INTEGER
END TYPE

TYPE MasterAssignmentType 'Needed to populate the top (assignment list)
    ARName AS STRING * 20 'Assignment report name
    ADName AS STRING * 10 'Assignment display name (short name)
    AType AS _UNSIGNED _BYTE 'Assignment Type (Completeion, formative, summative, etc.)
    ACat AS STRING * 20 'Assignment Category (subject, unit, etc)
    AColor AS _UNSIGNED _BYTE 'Color coding assignment headers and for grouping for reports
    ACode AS _UNSIGNED _BYTE 'Reserved
    APts AS _UNSIGNED INTEGER 'Total points allowed
    AID AS INTEGER 'Unique assignment ID
END TYPE

TYPE SlaveAssignmentType 'Needed to fill in the gradebook
    UID AS INTEGER 'UID will match the stuedent name list to match results, negative UID means deleted and we will ignore it on display and reports
    AID AS INTEGER 'Know which student points are going with each assignmnet
    MPts AS _UNSIGNED INTEGER 'Points earned for each particular students
    Flags AS _UNSIGNED _BYTE 'See below for codes
    Flags2 AS _UNSIGNED _BYTE ' Reserved
    Notes AS STRING * 512 'Comments for a student's work
END TYPE

'Say you have 50 students
DIM NL(50) AS NameListType

'Each student is required to complete 30 assignments
DIM MA(30) AS MasterAssignmentType

'Create a slave assignment indexed to each student and assignment
DIM SA(30, 50) AS SlaveAssignmentType

'The AID & UID would be referenced by the first and second elements of SA respectively
'each student then has a SlaveAssignmentType record for each MasterAssignmentType
'reports can be generated by a nested loop that can check for SGN(NL(x).UID) < 0

FOR student% = 1 TO UBOUND(NL)
    IF NL(student%).UID < 0 THEN _CONTINUE 'student record deleted, skip to next record
    FOR assign% = 1 TO UBOUND(MA)
        'do stuff with all data referenced by SA(assign%, student%) or NL(student%) or MA(assign%)
    NEXT assign%
NEXT student%

placing AID and UID in the SlaveAssignmentType UDT may even be superfluous since it's already carried by the dimensional elements.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply


Messages In This Thread
Array in an array - by NasaCow - 02-15-2023, 12:44 AM
RE: Array in an array - by bplus - 02-15-2023, 01:55 AM
RE: Array in an array - by OldMoses - 02-15-2023, 02:43 AM
RE: Array in an array - by NasaCow - 02-15-2023, 03:17 AM
RE: Array in an array - by OldMoses - 02-15-2023, 11:02 AM
RE: Array in an array - by mnrvovrfc - 02-15-2023, 03:53 AM
RE: Array in an array - by SMcNeill - 02-15-2023, 12:59 PM
RE: Array in an array - by bplus - 02-15-2023, 05:31 PM
RE: Array in an array - by bplus - 02-16-2023, 04:25 PM
RE: Array in an array - by NasaCow - 02-17-2023, 12:03 AM
RE: Array in an array - by SpriggsySpriggs - 02-17-2023, 05:43 PM
RE: Array in an array - by Kernelpanic - 02-18-2023, 03:49 PM
RE: Array in an array - by TempodiBasic - 03-11-2023, 02:59 AM
RE: Array in an array - by bplus - 02-17-2023, 06:32 PM
RE: Array in an array - by TerryRitchie - 02-17-2023, 09:12 PM
RE: Array in an array - by SMcNeill - 02-17-2023, 11:42 PM
RE: Array in an array - by madscijr - 02-28-2023, 07:14 AM
RE: Array in an array - by mnrvovrfc - 02-17-2023, 10:57 PM
RE: Array in an array - by TerryRitchie - 02-18-2023, 02:24 AM
RE: Array in an array - by AtomicSlaughter - 02-18-2023, 09:39 AM
RE: Array in an array - by bplus - 02-18-2023, 12:47 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 09:25 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 09:41 PM
RE: Array in an array - by TempodiBasic - 02-18-2023, 10:01 PM
RE: Array in an array - by Kernelpanic - 02-18-2023, 11:07 PM
RE: Array in an array - by TempodiBasic - 02-19-2023, 01:46 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 12:19 AM
RE: Array in an array - by bplus - 02-21-2023, 01:07 AM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 05:13 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 02:26 PM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 02:54 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 01:18 AM
RE: Array in an array - by TempodiBasic - 02-21-2023, 02:37 PM
RE: Array in an array - by bplus - 02-21-2023, 02:16 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 06:04 PM
RE: Array in an array - by bplus - 02-21-2023, 06:26 PM
RE: Array in an array - by mnrvovrfc - 02-21-2023, 10:24 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 05:59 PM
RE: Array in an array - by bplus - 02-21-2023, 06:33 PM
RE: Array in an array - by bplus - 02-21-2023, 06:42 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 06:45 PM
RE: Array in an array - by bplus - 02-21-2023, 06:51 PM
RE: Array in an array - by Kernelpanic - 02-21-2023, 09:19 PM
RE: Array in an array - by bplus - 02-21-2023, 11:13 PM
RE: Array in an array - by TempodiBasic - 02-22-2023, 09:32 AM
RE: Array in an array - by Kernelpanic - 02-27-2023, 07:05 PM
RE: Array in an array - by Kernelpanic - 02-28-2023, 03:33 PM
RE: Array in an array - by madscijr - 02-28-2023, 06:24 PM
RE: Array in an array - by TempodiBasic - 03-11-2023, 02:23 PM
RE: Array in an array - by Kernelpanic - 02-28-2023, 11:14 PM
RE: Array in an array - by madscijr - 03-01-2023, 02:13 AM
RE: Array in an array - by mnrvovrfc - 03-01-2023, 03:29 AM
RE: Array in an array - by bplus - 03-01-2023, 04:00 PM
RE: Array in an array - by madscijr - 03-01-2023, 05:24 PM
RE: Array in an array - by Sprezzo - 03-02-2023, 08:34 AM
RE: Array in an array - by bplus - 03-02-2023, 05:18 PM
RE: Array in an array - by mnrvovrfc - 03-02-2023, 04:26 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 05:19 PM
RE: Array in an array - by bplus - 03-02-2023, 05:25 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 05:26 PM
RE: Array in an array - by bplus - 03-02-2023, 05:28 PM
RE: Array in an array - by Dimster - 03-02-2023, 06:05 PM
RE: Array in an array - by bplus - 03-02-2023, 06:20 PM
RE: Array in an array - by SpriggsySpriggs - 03-02-2023, 07:12 PM
RE: Array in an array - by mnrvovrfc - 03-02-2023, 10:46 PM
RE: Array in an array - by madscijr - 03-03-2023, 12:47 AM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 02:59 AM
RE: Array in an array - by madscijr - 03-03-2023, 04:24 AM
RE: Array in an array - by mnrvovrfc - 03-03-2023, 07:22 AM
RE: Array in an array - by mnrvovrfc - 03-03-2023, 07:11 AM
RE: Array in an array - by vince - 03-03-2023, 10:07 AM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 01:02 PM
RE: Array in an array - by madscijr - 03-03-2023, 03:06 PM
RE: Array in an array - by vince - 03-03-2023, 03:17 PM
RE: Array in an array - by SpriggsySpriggs - 03-03-2023, 03:25 PM
RE: Array in an array - by mnrvovrfc - 03-11-2023, 06:22 PM
RE: Array in an array - by NasaCow - 03-13-2023, 03:29 AM
RE: Array in an array - by TempodiBasic - 04-02-2023, 10:14 PM
RE: Array in an array - by NasaCow - 04-06-2023, 02:37 AM
RE: Array in an array - by TempodiBasic - 04-12-2023, 10:53 AM



Users browsing this thread: 1 Guest(s)