Hi All,
I'm slowing getting to grips with not only b4A but also general programming concepts.
Now that I seem to have a grasp on using arrays with types (like fields in a database, I'm now trying to sort this array on just one field (in the future i my need to sort on two or more fields, but lets start with something less complicated)
I read in the forum that lists can be effectively sorted & arrays can be easily converted to lists, so am looking to apply this by converting my Table (500 x 15 string fields) to a list & then sorting by the first field and converting back to an array. (I my yet consider keeping the data in a list format & using it from there, but most of my program is based around these array structures)
basically...
Dim Pad (field1 as string,field2 as string....field15 as string)
Dim Rec as Pad
Dim MyTable(500) as Pad
Dim SortedTable(500) as Pad
Dim MyList as List
Rec.initialize
MyList.initialize
All fields can be accessed by something like :
rec = MyTable(12)
text1 = rec.field3
...
to sort I need to assign each MyTable record to MyList. Can this use something like the following or do I have to do it row by row using for...next?
MyList.initialize2(MyTable)
MyList.AddAll(MyTable)
Assuming I get the Table data into a multi-columned list can I then sort it by the contents of one field like.... ?
MyList(MyTable().Field1).sort(true) << obviously doesn't work but shows what I'm trying to acheive by accessing a list field. :sign0085:
then copying back the sorted List into a new array...
for r = 0 to MyTable.Length-1
SortedTable(r) = MyList.Get(r)
next
I'm hoping that someone with more experience can point me in the right direction.
Cheers!!
I'm slowing getting to grips with not only b4A but also general programming concepts.
Now that I seem to have a grasp on using arrays with types (like fields in a database, I'm now trying to sort this array on just one field (in the future i my need to sort on two or more fields, but lets start with something less complicated)
I read in the forum that lists can be effectively sorted & arrays can be easily converted to lists, so am looking to apply this by converting my Table (500 x 15 string fields) to a list & then sorting by the first field and converting back to an array. (I my yet consider keeping the data in a list format & using it from there, but most of my program is based around these array structures)
basically...
Dim Pad (field1 as string,field2 as string....field15 as string)
Dim Rec as Pad
Dim MyTable(500) as Pad
Dim SortedTable(500) as Pad
Dim MyList as List
Rec.initialize
MyList.initialize
All fields can be accessed by something like :
rec = MyTable(12)
text1 = rec.field3
...
to sort I need to assign each MyTable record to MyList. Can this use something like the following or do I have to do it row by row using for...next?
MyList.initialize2(MyTable)
MyList.AddAll(MyTable)
Assuming I get the Table data into a multi-columned list can I then sort it by the contents of one field like.... ?
MyList(MyTable().Field1).sort(true) << obviously doesn't work but shows what I'm trying to acheive by accessing a list field. :sign0085:
then copying back the sorted List into a new array...
for r = 0 to MyTable.Length-1
SortedTable(r) = MyList.Get(r)
next
I'm hoping that someone with more experience can point me in the right direction.
Cheers!!