Using AppleScript to find and set an AS variable collects TMI (too much 
information)

Hello!

I create many text documents in BBEdit every day, and I have to extract and 
send these 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

And Keybard Maestro action: 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

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/df434722-869f-4634-8f04-40948bacee7an%40googlegroups.com.

Reply via email to