It is so much easier to have two fields - date and comment, as a related table related on the parent table's primary key. It accomplishes several things:
1) Protects if a User accidently selects all and deletes and all text.
2) Dates are date fields so no various funky enteries of Jun '11 etc. requiring true dates
3) Because it is true dates, you can search, sort and report by date
4) If you include a 'CreatedBy' then you can also easily search sort and report by User
5) You don't have to waste time scripting jumping around in a text field.
6) It displays in column and makes visual scanning of comments easier.
Seems like a complicated way to structure this information. Putting each note in it's own portal record with a time stamp field would be a much simpler way to go.
What you currently do could be done like this:
Set Field [Companies::Comments ; Get ( UserName ) & "-" & get ( CurrentDate ) & ¶ & Companies::Comments]
Set Selection [ Companies::Comments ; Length ( Leftwords ( Companies::Comments ; 1 ) ) ]
But why not use separate records for each company note?
The portal can sort them in descending order to put the most recent note at the top and a button can be used to start a new note so that a new blank record appears at the top each time you click it.
Thanks for both responses. I'm obviously a neophite at this. A 40 year old CS degree with 25 years in IC marketing has me at a disadvantage but I'm slowly coming up to speed.
Phil's response is the easiest to implement for the time being. However, I would still like to know how to imbed control characters within a script. Is it possible? If so, how? :)
What do you want to embed and why? (Not sure I understand what you want to accomplish here.)
Please note that LaRetta and I are recommending the same thing for your long term fix.
I have extensive use of portals where they seem appropriate i.e. customer employees, work orders, tests, etc. I have small comments fields in various sections. My customer (my boss) just wants to be able to scroll down through this comments section and see the last comment first. Rather than have the user type in his/her name and date, I wanted to do that automatically. He doesn't want to make multiple clicks through a portal to see each individual comment. A running log is fine for what he want's to accomplish. There are certain aspects of a portal that are very attractive . . . searching . . . protecting older comments from deletion etc.
For the time being, it will be as a simple text document with the latest entry at the top.
What I was originally looking for was a simple way to position the cursor after the name & datestamp. In a normal text document I can position the cursor after the first line by doing a CtrHome (cursor at the top left) followed by a "End" (End of the first line). I was originally thinking I could put those keystrokes into the script to accomplish what I wanted to do for now but we will probably use portals in the future.
Just for grins, is this possible?
Now as far as portals are concerned. My customer would like to be able to scroll through the comments without having to click on the individual comments and at the same time with each comment having enough verticle space. In otherwords, if it only takes up one line, then it should only be one line high. If it takes five, it should take five. IS THIS POSSIBLE? If not, I would need to waste verticle realestate (sp) on my portal view.
All of the features you say you want and state as reasions for not using a portal are very easy to include as part of your portal:
My customer (my boss) just wants to be able to scroll down through this comments section and see the last comment first.
Your portal can sort note records so that the last note is first. and portals, of course, can have scroll bars. A simple Add note button can create a new blank note with a single click and this new note will automatically appear at the top of the portal.
Rather than have the user type in his/her name and date,
The Username and Date fields can auto-enter the current user name and date automatically. There is no need for the user to have to type this in.
He doesn't want to make multiple clicks through a portal to see each individual comment.
Since the most recent comment is listed first and you can include a scroll bar, this should not require any different user actions than using a note field with a scroll bar. Just scroll the portal backward to see older notes. But now you have much greater flexibility when it comes to working with this data and there is no need for a script other than a simple new record script for the add note button.
Just for grins, is this possible?
My earlier post positions the cursor just to the right of the date text. This can be tweaked to put it at the start of the next line. That's the purpose of the Set Selection step.
Thanks to both of you for putting up with me.
ALLRIGHT - I'M DOING IT IN A PORTAL!!!!
Phil gave you the same responses I would have made. In addition, if Boss wants to scan all notes, you can provide a button (SEE ALL) which opens a new window to report view of notes which show them sorted by date.
If you made the note field itself the largest you ever need it and select Inspector > Position and Sliding & Visibility and set 'slide up based on' and also set 'reduce enclosing part' then the notes will only take up as much space as they need and will provide Boss with full visual of all notes back through time. It will look exactly as he/you requested originally except that the dates and who created them will align properly and be formatted and spelled properly; no multiple clicks through a portal. So your actual notes portal might just be one row (showing the most current) and then open window to see them all. This will keep your notes portal compact.