Hello. Rookie AppleScripter here.
I need to grab some items from my many time entry text documents ever day.

They all start like this:
+ - - - - + - - - - + - - - - +
08:30-11:30 UWA

:: Item one
- the associated notes
+ - - - - + - - - - + - - - - +
I need to grab:
StartTime: 08:30
EndTime: 11:30
Client Code: UWA

I then need to pass these variables to Keyboard Maestro to paste into a web 
form. But my attempts at just getting "08:30" for StartTime is grabbing 
much more than just that text.

The beginning of my script is this:
+ - - - - + - - - - + - - - - +

*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*
+ - - - - + - - - - + - - - - +

Let's just focus on StartTime. Script Debugger tells me that the variable 
StartTime is getting three found properties:
found: true
found object: characters 1 thru 5 of text document id 220
found text: "08:30"
So, Excellent! StartTime properly getting the correct text "08:30" (BTW - 
I'm also getting the right text for EndTime and ClientCode.)
When it comes to sending that variable to Keyboard Maestro, I get an error:
"Can’t make characters 1 thru 5 of text document id 220 of application 
"BBEdit" into the expected type."
When I test from a script action in Keyboard Maestro, I see that the script:
+ - - - - + - - - - + - - - - +
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
+ - - - - + - - - - + - - - - +
is setting variable TicketTimeEntryBegin to:
found:true, found object:characters 1 thru 5 of text document id 220, found 
text:08:30

But I just want "08:30" !!
Where am I going wrong?

I really don't know what
"with selecting match"
in the AppleScript Find command does - I just copied that from another 
script somewhere. I do know that I don't get ANYTHING in my variable 
StartTime without it.

So how do I just get
08:30
and not
found:true, found object:characters 1 thru 5 of text document id 220, found 
text:08:30

Thank you!

-- 
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/c3ab9d00-86b6-43c8-a17c-08638285e9d4n%40googlegroups.com.

Reply via email to