Page 1 of 1
Inserting date in text
Posted: Thu Apr 16, 2009 5:26 am
by urbaud
I have a multiline text field called “text1â€
Re: Inserting date in text
Posted: Thu Apr 16, 2009 5:42 am
by sturgis
Probably the easiest way to do this would be to have a placeholder string in your field where you want to insert the date, and use replace.
So if your field has
I would like the _date_ text to have several dates _date_ dispersed throughout _date_ the text like this
then you can use code like this to do what you want.
Code: Select all
on mouseUp
put the long date into theDate
replace "_date_" with theDate in field "field"
end mouseUp
The keyword "into" always behaves the way you described. Whatever is there now goes away and is replaced what you're putting "into" the container. YOu can use alternate keywords for different affects like after will append your new string at the end, before inserts it at the start..
[quote="urbaud"]I have a multiline text field called “text1â€
Posted: Thu Apr 16, 2009 1:21 pm
by Tim
The best way is to use the "merge" command and have the rev date command in double square brackets - [[ ]]
Here is an example:
put "The day today is [[the long date]]" into tVar
put merge(tVar)
Will output :
"The day today is Thursday, April 16, 2009"
You can use any Rev command inside the [[ ]] and can have as many instances of [[ ]] as you like in the string ... see the dictionary entry for the "merge" command for more information.
Best,
Tim.
Posted: Thu Apr 16, 2009 3:46 pm
by sturgis
Oh cool, thanks from me too!
Tim wrote:The best way is to use the "merge" command and have the rev date command in double square brackets - [[ ]]
Here is an example:
put "The day today is [[the long date]]" into tVar
put merge(tVar)
Will output :
"The day today is Thursday, April 16, 2009"
You can use any Rev command inside the [[ ]] and can have as many instances of [[ ]] as you like in the string ... see the dictionary entry for the "merge" command for more information.
Best,
Tim.
Posted: Fri Apr 17, 2009 12:09 am
by urbaud
Sturgis and Tim, thanks so much for your suggestions. Now that I see the code, is there a way to insert the date where the cursor is? I'd like to try to get away without using a placeholder, just the cursor. Any more help is much appreciated.
Thanks,
urbaud
Posted: Fri Apr 17, 2009 12:49 am
by sturgis
Try this
Code: Select all
put the long date into the selection
urbaud wrote:Sturgis and Tim, thanks so much for your suggestions. Now that I see the code, is there a way to insert the date where the cursor is? I'd like to try to get away without using a placeholder, just the cursor. Any more help is much appreciated.
Thanks,
urbaud
Posted: Fri Apr 17, 2009 9:43 pm
by urbaud
Hi sturgis,
Thanks so much for the one liner. It works exactly as I wanted. thanks again.
urbaue