Hello!
I create many text documents in BBEdit every day, and I have to extract and send variables over to Keyboard Maestro to paste in a web form. These documents start like this:
08:30-11:30 UWA
:: Item one
- the associated notes
:: Item two
- etc
I need to pull out variables:
StartTime: 08:30
EndTime: 11:30
ClientCode: UWA
I’ve been working with the following script:
set StartTime to “00:00”
set EndTime to “00:00”
set ClientCode to “AAA”
tell application “BBEdit”
set StartTime to find “(\A)([0-9]{2})(\:)([0-9]{2})” searching in text document 1 options {search mode:grep, wrap around:true} with selecting match
set EndTime to find “([0-9]{2})(\:)([0-9]{2})” searching in text document 1 options {search mode:grep, wrap around:false} with selecting match
set ClientCode to find “[A-Z]{3}” searching in text document 1 options {search mode:grep, wrap around:false} with selecting match
end tell
tell application “Keyboard Maestro Engine”
setvariable TicketTimeEntryBegin to StartTime
end tell
Running it, I keep getting the error:
“Can’t make characters 1 thru 5 of text document id 220 of application “BBEdit” into the expected type.”
Script Debugger tells me that variable StartTime has these three properties:
found: true
found object: characters 1 thru 5 of text document id 220
found text: “08:30”
So I’m getting the right found text “08:30” (and I’m getting the correct EndTime and Client Code), but there is a type mismatch when trying to get 08:30 over to a variable TicketTimeEntryBegin in Keyboard Maestro.
Now, when I use the following Execute AppleScript step in Keyboard Maestro to try to see what’s going on:
tell application “BBEdit”
find “(\A)([0-9]{2})(\:)([0-9]{2})” searching in text document 1 options {search mode:grep, wrap around:true} with selecting match
end tell
With: Save to variable: TicketTimeEntryBegin
the variable TicketTimeEntryBegin in Keyboard Maestro now contains:
found:true, found object:characters 1 thru 5 of text document id 220, found text:08:30
So it is getting the three properties of the variable mashed together.
How do I just get the found text 08:30, and not the rest?
Thanks!
- eric