I’m a newbie in programming (not just in Servoy) and I’m pretty sure this is a stupid question but I can’t seem be sure about this. So i’m asking for some help.
I’m using a code sample found in the docs for getFoundSetUpdater:
//safely loops through the foundset, starting with the selected row
controller.setSelectedIndex(1);
var count = 0;
var fsUpdater = databaseManager.getFoundSetUpdater(foundset);
while(fsUpdater.next())
{
fsUpdater.setColumn('my_flag',count++);
}
Playing with this snippet I found out that:
1 - If I don’t setSelectedIndex(x) to 1 but to some other index say 20, the returned fsUpdater will only include records from index 20 to the end.
2 - Because I’m updating ‘myflag’ field to numbers starting from 1, then fsUpdater.next() method moves a “foundset kind of record pointer” so that the next turn int the while loop sets ‘myflag’ of the next record.
3) - The snippet works as advertised and I get all of my records numbered from 1 to 830!
But this is is strange because if according to 1) the fsUpdater includes the first record and according to 2) when the first line of the while loop when fsUpdater.next() is evaluated the “foundset kind of record pointer” should be refering the 2 record of the found set (not the first)!
The only way I can explain this behaviour is considering that although the evaluation of fsUpdater.next() returns true. This method does not iterate over the fsUpdater object. The iteration happens when and only when the setColumn() method is run positioning the object on the next row!
This would mean that 2) is incorrect! And would be correct if stated:
"2) - Because I’m updating ‘myflag’ field to numbers starting from 1, then fsUpdater.setColumn() method moves a “foundset kind of record pointer” so that the next turn in the while loop sets ‘myflag’ of the next record.
I’ve tried find this in the docs, but was unsuccessful. Is this conclusion correct?
Txs for taking the time,
mjekl