Since the current record could be at or near the top of your found set or could be near or at the bottom of your found set, you won't always be able to center the current record, but when that is not the case, the following script should succeed in centering the record vertically:
Set Variable [$RecordNumber ; get ( CurrentRecordNumber ) ]
Go to record number [no dialog ; Get ( FoundCount ) ] ---> Make last record in found set the current record, scrolls window to the bottom
Go to Record Number [ No Dialog ; Max ( $RecordNumber - (Total Rows per screen / 2 ) ; 1 ) ]
Go to Record Number [ No Dialog ; $RecordNumber ]
If your list view can show up to 25 records at a time, that would make the next to last step:
Go to Record Number [ No Dialog ; Max ( $RecordNumber - 12 ; 1 ) ]
Note that this only works perfectly for records that aren't records near the top or bottom of the found set nor with layout designs where the window resizes to different heights on different monitors. More sophisticated variations could use a get function to detect the window height and use it to calculate the value needed in step 3.
Thanks for the input. Understand the top and bottom records cannot be centered. That is not a problem.
My process which is essentially what you describe except I was not forcing the record pointer to the bottom of the stack. Adding this step stabalized the script perfomance and it now works like a charm - except - it still leaves the active record pointer setting at the last record in the visible list. I am matching a global Last_Record_Visited field to the actual Record_Number field in a Conditional Formatting statement to highlight the functional index record and the record I need to return to and place near the center of the list (when possible). The active record pointer is always the offset number of records away. Very dangerous situation since the user may damage this record thinking they are working in the highlited record.
Any suggestions on moving the active record pointer back to the Last_Record_Visited value without the list moving?
I tested my script before I posted it. It centers on the current record when possible.
The set back approach was the frist one I tested and I have tested this approach repeatedly. I do not get the results you describe.
If I leave the Record Pointer in the offset, the list centers (exact count asside). But, when I execute even one back step, the list pointer remains at the bottom of the list and the selected record moves down to meet the record pointer - (ignoring the top/bottom extremes).
I am working with 120 test records starting at 60 so the extreams are not an issue.
I have a demonstration file that I could post hear but being new to this interface, I cannot find the attach file function.
In my example file the Go to Record Number [ No Dialog ; Pervious ] walks the visible list down to where it is setting rather than walking up the visible list. My structure is a bit more complex than yours but I can't find anything in my scripts or layouts that would explain the different performance.
Can you explain how I can attach a runtime or source file to this system?
I'd look for a script trigger that your script may be tripping when it executes. That triggered script might interfere with the results of this "centering" script.
To share a file via this forum, upload the file to a sharing site such as Drop Box and then post the download link here.
Thanks for the tip philmodjink,
I am using FMPA 13 and your script works but only if I add a script pause after each goto record command.
If I have the script run without any pause, it will always move the selected record as the last line in the list.
If I follow the steps by adding a pause, the list is vertically centered on the record selected.
Is that normal?
I have it working by adding a pause of 0,01 seconds after each step.