August 31, 200619 yr This may be an obvious question, but I'm having difficulty setting the cursor position in a field to a point I specify. I have a script that sets a 'timestamp' at the start of a field, and I would like to position the cursor immediately after this, so that the users can then type their notes. However, I cannot seem to find a way of doing this. Any ideas? Thanks
August 31, 200619 yr Here's the script SetField (filename:userfield; Get (CurrentTimeStamp ) & " ") Go to Field (filename:userfield)
August 31, 200619 yr Author Thanks. I realise that I didn't make myself clear in the last post. As the field will be often updated, I use a 'Set Field' step to ensure that the timestamp is entered at the 'top' of the field, with the original data placed after a carriage return. However, I want to place the cursor immediately after the latest timestamp, i.e before the original data. Does this make sense? Cheers
August 31, 200619 yr So you wish: first entry: 08/30/2006 12:00:00 some notes second entry: 08/30/2006 12:30:00 08/30/2006 12:00:00 ............<-- (here the cursor ?) some notes
August 31, 200619 yr If you set up a related table for these timestamped entries (one where each entry was a separate record), you could have separate fields for timestamp and user notes, and there'd be no need for any scripting. Set the timestamp as an autoenter, put the notes field on a portal with allow creation of records, and your users have only to type in their notes. Each entry would get its own timestamp automatically. David
August 31, 200619 yr Author Hi Danielle Yes, you have the gist of it. This is what I want to do: Existing field: "1/4/06 12:34:05 Blah blah blah etc etc 29/3/06 14:52:34 Blah blah blah etc etc" I want to insert the timestamp at the beginning of the field, and place the cursor immediately afterwards: "31/8/06 20:26:02 1/4/06 12:34:05 Blah blah blah etc etc 29/3/06 14:52:34 Blah blah blah etc etc" Does this make sense?
August 31, 200619 yr Author David I had thought of that, but unfortunately this solution is one that I've inherited and upgraded to FM8 (from FM5) and I really don't want to go back through the 10,000 or so records which all have approximately 20 entries in this particular field. Thanks for your suggestion though.
August 31, 200619 yr Hi tv_kid, After you set the timestamp (in your script), your next step might be: Go To field [ field ] Set Selection [ field ; Start Position: Position ( field ; " " ; 1 ; 3 ) + 1 ] ... no End Selection need be specified. Adjust to fit your script. It just looks for the third space in the first line and places the cursor at the end of it. You could use the pilcrow to mark your place instead. UPDATE: In your case, it would be the second space? My timestamps use AM/PM so it has 2 spaces. Because of this difference, you might be wise to use the pilcrow instead and just set the selection start as: Position ( field ; ¶ ; 1 ; 1 ). LaRetta :wink2: Edited August 31, 200619 yr by Guest Added afterthought ...
September 1, 200619 yr Author LaRetta and Danielle, thank you! I hadn't noticed the 'Set Selection' script step before (duh!), but it is just what I need. Thanks again.
Create an account or sign in to comment