Posts: 64
Threads: 19
Joined: Nov 2012
Hi, I use an Autotext command to put a timestamp in the text I am working with. It works super. However when I am next to characters and not one space away it will not work. For example Taskts01 (that should of produced “Task1909031438”) will not work, but Task ts01 (it will produce Task 1909031442) does work. How could I make it where It works anywhere next to other text? Thanks
code for Autotext:
Autotext [b]Autotext[/b] [help1][/help1]
Trigger [b]$t[/b] [help2][/help2]
[code]/b/i/c
ts01 :mac "MainTS"
ts02 :mac "BasicTS"
[/code]
code for Timestamp:
Macro [b]MainTS[/b] [help1][/help1]
[code]DateTime t.FromComputerTime
str sf=t.ToStrFormat("{yyMMdd}{HHmm}")
key (sf)
[/code]
Posts: 1,337
Threads: 61
Joined: Jul 2006
09-03-2019, 10:59 PM
(This post was last modified: 09-03-2019, 11:07 PM by Kevin.)
Taskts01 will not work if autotext line is ts01
you can however do a couple things
First, all your code can be put into subfunctions of the autotext list .No external macro or function are needed.
In the example below i have given you a couple of options.
taskts01 will work when that is typed fully. Will remove ts01 and replace with the time stamp.
[32]ts01 will work when you type any text then hit spacebar followed by ts01(example: Task ts01 becomes Task1909031902).
the space and ts01 will be replaced with the timestamp.
The [32] means space.
Autotext
Autotext
Trigger
$t
/b/i/c
taskts01 :sub.MainTS2 ;;typed fully then ts01 is removed and replaced with timestamp
[32]ts01 :sub.MainTS ;;timestamp output with no space
ts02 :sub.BasicTs ;; add code to #sub BasicTs below
;ts01 sub.MainTS ;;timestamp output only works with ts01 as text
#sub MainTS
DateTime t.FromComputerTime
str sf=t.ToStrFormat("{yyMMdd}{HHmm}")
paste+ sf
#sub BasicTs
;add code here ts02
#sub MainTS2
str userText;TriggerInfoAutotext userText 0 0
DateTime t.FromComputerTime
str sf=t.ToStrFormat("{yyMMdd}{HHmm}")
userText.replacerx("ts.+" "")
sf- userText
paste+ sf
Posts: 64
Threads: 19
Joined: Nov 2012
09-03-2019, 11:46 PM
(This post was last modified: 09-03-2019, 11:57 PM by pctechtv.)
Hi thanks for the replay. I don't want Taskts01 I want ts01 to work when it is next to another character. I see what you did and I am getting something to work but it still does not work when next to another character. I was only typing Task as the other text it will not flow next to (see vid). Thanks
http://pctechtv.com/extra/forum/quickmac...Better.mp4
Posts: 1,337
Threads: 61
Joined: Jul 2006
I understand what your desire is but it wont work when there is text before the autotext trigger. That's why i showed you the alternatives
Your best bet is to used this [32]ts01
then you type whatever then spacebar then ts01 and choose option 1.
Autotext
Autotext
Trigger
$t
b/i/c
[32]ts01 :sub.MainTS ;;timestamp output removes space and ts01
ts02 :sub.BasicTs ;; add code to #sub BasicTs below
ts01 :sub.MainTS ;;timestamp output only works with ts01 as text
#sub MainTS
DateTime t.FromComputerTime
str sf=t.ToStrFormat("{yyMMdd}{HHmm}")
paste+ sf
#sub BasicTs
;add code here ts02
Posts: 64
Threads: 19
Joined: Nov 2012
Quote:... but it wont work when there is text before the autotext trigger.
OK I figured that could be the problem. I see now with [32] in front that is a good solution. Super helpful, Thank You