Hi again,
I typed a long reply only to have the forum log me out before submitting and it lost my message - I think I remember much of what I said before.
Can you give a sample of dummy student data in the array you have? A lot will depend on the way you have set up your keys.
For example if you have:
Code: Select all
repeat for each line tStudentKey in the keys of tStudents
put tStudentKey & tab after tStudentInfo
repeat for each line tKey in the keys of tStudents[tStudentKey]
put tStudents[tStudentKey][tKey] & tab after tStudentInfo
end repeat
put cr after tStudentInfo
end repeat
put tStudentInfo into field "tblStudents"
That should populate the table - but you will probably need to sort the keys for the elements, and sort the id keys before you build up the data, otherwise you will not have the right information in the right places. This isn't a real world example.
The data can be placed more directly in the table field if you know where it is to go.
Code: Select all
set the itemDelimiter to tab
-- the "table" is simply a field with items separated by tabs
put "some data" into item 4 of line 7 of field "tblStudents"
So some combination of looping by number and identifying the keys in order may be appropriate. It depends on how you have your array keyed.
To make a table you can drag it from the tools palette. To set the column widths, you use tabstops. In the table dropdown in the property inspector, you can specify the column widths in "tabstops" - so for example if you wanted column 1 to be the id and 40 px wide, column 2 to be the name and 160 px wide, column 3 to be the date of birth and 80 px wide, and column 4 to be the course and 200 px wide you would set the tabstops to: 40,200,280,480. Any column beyond the last will have the same tabstop width ad infinitum. Therefore for this example, you can set the maximum editable column to be 4. (Although that is so difficult to use cleanly, and is completely ignored if you use tab inside the field that it is safest to take out the cell editing option, and lock the text on the basic properties pane of the property inspector, only editing by script). If you adjust the width of the table field to match the right columns on screen then that is easiest, if you need to scroll horizontally you will need to set the end position of the scrollbar to the right value so that it scrolls only the amount you want visible.
If you have the horizontal grid lines shown, then they will be displayed to fill up the size of the table field regardless of whether rows are empty at the end of the table. Therefore you cannot set a table field to be "9 columns wide x 20 rows high".
In other words,
please everyone go and vote for the table control enhancement in the QCC linked above - Rev is really let down by its native table handling capabilities.