Hi folks,
this is one of those that looks like it should be dead easy but it's not turning out that way.
What I am trying to do:
I have a single table with an embedded browse ordered ascending by a field called 'rank'. All I am trying to do is to insert a new rec ranked immediately below the active rec with the only change to *everything* I can see being that all recs below the active rec, move down one position and the new rec is inserted. That's it.
The table is enclosed for your perusal. The embedded form is the one in question and the 'insert' button has the latest version of the script attached. Clearly performance should be as fast as possible.
Just to be absolutely clear...
Say before we press the 'insert' button, of 90 recs in the table, 20 are 'found' as they have a rank value, and of those 20, the browse is scrolled down a little so it is actually showing recs ranked 6 to 18 with rec 11 as the active rec. When the button is pressed, all recs in the entire table with rank"12 should have their rank value increased by 1 and when we're done, 21 recs should be 'found' and the browse should still be showing recs ranked 6 to 18, though clearly the new rec will be at 12, the rec that was 12 is now 13, 13 is 14, 14 is 15 etc and the rec that was 18 is now 19 and so it's off the bottom of the browse now and doesn't show unless we scroll down.
The problems:
The OnPush for 'insert (array)' does nearly everything I want but performance is unacceptably poor even with just 20 or so recs (it dumps rec nums to an array and then calls each rec in turn). An update operation is much quicker but I'm going round in circles trying to get it to work. I have tried Action Scripting it - 'Insert (AScr)' but while I can get an update to run fine if I manually enter the starting rec's rank using an ask() variable, I can't get it to pick up the rank value from the current rec without problems and I constantly get errors of "Error: Can't update field in primary index" even if I set the primary index to some field other than 'rank'.
Thanks in advance for any help.
Regards, as ever,
Trevor
PS Does anyone have an example of how to use flag variables?
PPS Do I have to use an embedded rather than named browse here to be able? If I use a named browse, how do I detect the rank of the current active rec?
this is one of those that looks like it should be dead easy but it's not turning out that way.
What I am trying to do:
I have a single table with an embedded browse ordered ascending by a field called 'rank'. All I am trying to do is to insert a new rec ranked immediately below the active rec with the only change to *everything* I can see being that all recs below the active rec, move down one position and the new rec is inserted. That's it.
The table is enclosed for your perusal. The embedded form is the one in question and the 'insert' button has the latest version of the script attached. Clearly performance should be as fast as possible.
Just to be absolutely clear...
Say before we press the 'insert' button, of 90 recs in the table, 20 are 'found' as they have a rank value, and of those 20, the browse is scrolled down a little so it is actually showing recs ranked 6 to 18 with rec 11 as the active rec. When the button is pressed, all recs in the entire table with rank"12 should have their rank value increased by 1 and when we're done, 21 recs should be 'found' and the browse should still be showing recs ranked 6 to 18, though clearly the new rec will be at 12, the rec that was 12 is now 13, 13 is 14, 14 is 15 etc and the rec that was 18 is now 19 and so it's off the bottom of the browse now and doesn't show unless we scroll down.
The problems:
The OnPush for 'insert (array)' does nearly everything I want but performance is unacceptably poor even with just 20 or so recs (it dumps rec nums to an array and then calls each rec in turn). An update operation is much quicker but I'm going round in circles trying to get it to work. I have tried Action Scripting it - 'Insert (AScr)' but while I can get an update to run fine if I manually enter the starting rec's rank using an ask() variable, I can't get it to pick up the rank value from the current rec without problems and I constantly get errors of "Error: Can't update field in primary index" even if I set the primary index to some field other than 'rank'.
Thanks in advance for any help.
Regards, as ever,
Trevor
PS Does anyone have an example of how to use flag variables?
PPS Do I have to use an embedded rather than named browse here to be able? If I use a named browse, how do I detect the rank of the current active rec?
Comment