Home

Macros and Programming

 

CardboxForumsMacros and Programming > "adding today's date"

adding today's date

adding today's date to a field without deleting the existing text

Current user: [none]
Register / Log In · Help

Posted By Post

TB

20-Nov-2010 00:25

Can someone help me ? Each contact with a client, i open his file, go to the last line of the extra-text, add today's date, and jump to the end of the date, add a space and leave the macro.

So i can now add some written text, save the record and next visit i add some dated text again.

It was so simple in V2, but with the V3 commands, i do not find the equivalent of "eof" to go to the end of the file (i can work around by scolling down 500 lines or so... so that's fine), and i do not find the date as a variable. (isn't it simply assigned to a keyboard stroke or so?)

Thanks in advance.

bert

20-Nov-2010 01:41

Don't you have a macro recorder...?

This is your code:
GoToField "**"
Command cmdEnd+cmdControl
TypeText DateToCardbox(Now,"04/07/1976 ")
Command cmdEnd+cmdControl

See in Help page : Command method (Window object) + DateToCardbox function (Application object, macros)
Regards
Bert

Charles Welling

20-Nov-2010 10:32

This method is a bit sluggish because it makes the cursor jump to the Extra Text and then moves the cursor down all the lines.
By the way: adding the extra space before you save the record has no use because Cardbox removes all linefeeds and spaces at the end of the text before saving the record.

This is faster:

Fields("**") = Fields("**") & " " & DateToCardbox(Now,"04/07/1976 ")

This single line tells Cardbox that the Extra Text should be:
- the existing content of your Extra Text
- AND a space
- AND today's date

It does so without moving the cursor.

bert

20-Nov-2010 11:42

Charles,

Your suggestion misses a solution for line 3:

1 go to the last line of the extra-text
2 add today's date,
3 and jump to the end of the date,
4 add a space and leave the macro

Then: if you are used to CB2 macros it is more then logic your start with cb3 "cursor" macros directly in the client.
That's my motivation to give *this* answer.

And in this case "faster" of your suggestion is negligible.
regards
Bert

Charles Welling

20-Nov-2010 18:38

You're quite right Bert. It had been my understanding that the purpose was to add the date to the field including a space for future additions.
I've re-read the question and I see that I've missed a part.
Still, the following lines are faster :-)

Fields("**") = Fields("**") & " " & DateToCardbox(Now,"04/07/1976 ") & " "
Command cmdEnd+cmdControl

royalina

8-Jan-2011 07:05

adding the extra space before you save the record has no use because Cardbox removes all linefeeds and spaces at the end of the text before saving the record.

[url=http://www.cartier4us.com/Cartier-Necklaces-4.html]buy cartier love bracelet[/url]
[url=http://www.cartier4us.com/Cartier-Trinity-Ring-14.html]cartier love[/url]
[url=http://www.cartier4us.com/Cartier-Pen-5.html]cartier pens[/url]

bert

8-Jan-2011 10:05

You're right.
However, the space was added because TB has to add some text after it...
Read the first message in the topic.
Regards
Bert

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home