row number

In a table or list is there (or could there be) a function that returns the row number in the found set, to be used in a calc. This is not the same as recordIndex, which is the currently selected row.

Seems there is a system parameter that gets passed via the RowBGColor, but I can’t see that this is available elsewhere.

I’m looking for a way to set a discount - 0% on the first listed item, 10% on the second, 20% on subsequent items in a table, without needing a method to recalc the discount if the order of records changes.

eg

Item A 0%
Item B 10%
Item C 20%

now if I add an item D which sorts into position 2,

Item A 0%
Item D 10%
Item B 20%
Item C 20%

Do I understand correct that you want to change a value in the first # of records in the table and that you want these records to sort ‘automatically’. In other words what are you trying to do, I don’t get the concept.

You can read/write into a row in a set (getRecord(index)) and you can do a sort on more than one column. Is this what you are asking for?

Hi Marcel, sorry if my explanation is not clear, but your answer is. I see now that I can write into row 1, 2, 3 etc with a set (getRecord(index)) - didn’t know that command, thought I could only work with the current record or the found set.

So for what is now only historical interest ;-)

I have a table that sorts by ItemValue

I want to set the Discount field to 0% discount on the most expensive item, 10% on the second most expensive, and 20% on subsequent items.

When a new item is added and it changes the sort order, I want the discounts to adjust. I was wondering if there was a way to determine row in a calculated field, but this is too hard and not the Servoy way.