First you need to know how many cells exist in the repeating field. There is a function that returns that value.
Next you simply set field (thefield[nbr0fcells+1])
THIS IS INCORRECT BUT I AM LEAVING IT WHILE CORRECTING IT BELOW. (I've used too many database applications...)
Does "set field (thefield[nbr0fcells+1])" take into account items already in the field?
Lets say I have 4 items in a 10 field list... Will this calculation put data into the 5th position?
Also, I guess when an item gets deleted, the lower repeating fields will move up...
It sounds like you should be using either a non repeating mult-line text field or a portal of related records for this.
Set field can append text to the end of a list of return separated values in that non repeating field if you use the list function like this:
Set Field [YourTable::TextField ; List ( YourTable::TextField ; "NewValueHere" ) ]
And if you use a portal with a related table of records, you can add a new related record in the portal's table to append data to the end.
In both cases, deleting an existing value or related record will enable existing values to "slide up"--which won't happen with a repeating field.
As penance for my error I have added a blog page elaborating on the nature of repeating fields: http://wp.me/1AmGx
Since you define the number of repeating cells in the field in the database manager that number of cells will always exist. You cannot increase the number of cells using a script so if you need to add a cell you have to add it in the database manager field definition dialog.
To put the value in the fith position you use set field thefield. The value in the bracket is used to define which cell you want to use.
Click on the field name to insert it into the calculation area and then type the [x] after the field name.
In your example you have the options:
Data does NOT move if you set a cell to empty. You do not delete the cell, you delete the data in the cell. The cell continues to exist and the other cells are not affected when you set another cell to empty. A similar action occurs in a spread sheet where you delete the data in one cell but not any any other.
Set field fieldname to ""