tv_kid Posted August 31, 2006 Posted August 31, 2006 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
IdealData Posted August 31, 2006 Posted August 31, 2006 Here's the script SetField (filename:userfield; Get (CurrentTimeStamp ) & " ") Go to Field (filename:userfield)
tv_kid Posted August 31, 2006 Author Posted August 31, 2006 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
Raybaudi Posted August 31, 2006 Posted August 31, 2006 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
T-Square Posted August 31, 2006 Posted August 31, 2006 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
tv_kid Posted August 31, 2006 Author Posted August 31, 2006 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?
tv_kid Posted August 31, 2006 Author Posted August 31, 2006 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.
LaRetta Posted August 31, 2006 Posted August 31, 2006 (edited) 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, 2006 by Guest Added afterthought ...
tv_kid Posted September 1, 2006 Author Posted September 1, 2006 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.
Recommended Posts
This topic is 6660 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now