Jump to content

Bug or problem? osascript error... Expected "end" but found "use"


Recommended Posts

I just upgraded to Mojave and am trying to re-enable a workflow that previously worked. I think I've narrowed down the problem to use of scripting additions. The script works fine when running outside of Alfred (ie, in ScriptEditor). When I trigger from an Alfred workflow, I get the following error:

 

[2019-03-19 15:43:27][ERROR: action.script] /Users/*****/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/3A6E9A07-7A4F-4C71-9EC7-C40B3653134C:1079:1082: script error: Expected “end” but found “use”. (-2741)

 

The portion of the script that is failing is here:

 

use scripting additions

use application "SatimageOSAX"

 

set theOrganizerEmailParsed to splittext theOrganizerEmail using "@"

 

 

I'm at a loss on further steps for troubleshooting. Other Alfred workflows that include AppleScript are working fine. Seems all of my Security settings are complete.

 

Any tips? thanks -- jay

 

Link to comment

Could you post a link to the entire workflow so we can have a look for ourselves?

 

It's almost impossible to diagnose an issue with an un-runnable code snippet unless the error is glaringly obvious (e.g. a typo) or you've already run into the exact same problem yourself.

Edited by deanishe
Link to comment

See below for the full script...  

 

If I eliminate this section, the script runs fine:

 

use scripting additions
use application "SatimageOSAX"

set theOrganizerEmailParsed to splittext theOrganizerEmail using "@"
set theOrganizerName to item 1 of theOrganizerEmailParsed
set theOrganizer to change "." in theOrganizerName into " "

 

it's also worth noting I'm able to access and use other functions from SatimageOSAX additions in other AppleScripts run straight from Script Editor.

 

on run argv

tell application "Microsoft Outlook"
	set meetingSet to selected objects
	set allAttendees to ""
	repeat with aMeeting in meetingSet
		set theSubject to subject of (item 1 of aMeeting)
		set theDate to start time of (item 1 of aMeeting)
		set theContent to content of (item 1 of aMeeting)
		set theOrganizerEmail to organizer of (item 1 of aMeeting)
		set ParticipantCount to count of every attendee in aMeeting
		if ParticipantCount > 30 then
			set allAttendees to " > 30"
		else
			repeat with aParticipant in attendees of aMeeting
				set theParticipant to item 1 of aParticipant
				set theParticipantEmail to email address of theParticipant
				try
					set theParticipantName to name of theParticipantEmail
				on error number -1728
					set theParticipantName to address of theParticipantEmail
				end try
				set allAttendees to allAttendees & theParticipantName & "; "
			end repeat
		end if
		-- set theMeetingContent to "<hr/>" & "organizer: " & theOrganizer & "<br/>" & "invitees: " & allAttendees & "<br/>" & theContent & "<hr/>"
	end repeat
end tell

use scripting additions
use application "SatimageOSAX"

set theOrganizerEmailParsed to splittext theOrganizerEmail using "@"
set theOrganizerName to item 1 of theOrganizerEmailParsed
set theOrganizer to change "." in theOrganizerName into " "
-- set theOrganizer to theOrganizerEmail

tell application "Evernote"
	
	activate
	
	set DefaultNotebook to (system attribute "theNotebookName")
	
	set theMeetingDate to "meeting date: " & theDate & "<br/><br/>"
	set theParticipantsHeader to "participants: " & "<br/><br/>"
	set theDiscussionHeader to "discussion:" & "<br/><br/>"
	set thePrepHeader to "prep:" & "<br/><br/>"
	set theOrganizerFormatted to "<hr/>" & "organizer: " & theOrganizer & "<br/>"
	set theAttendeesFormatted to "invitees: " & allAttendees & "<br/>"
	
	set theFullContent to theMeetingDate & theParticipantsHeader & theDiscussionHeader & thePrepHeader & theOrganizerFormatted & theAttendeesFormatted & theContent
	
	set NewNote to create note title "Meeting: " & theSubject with html theFullContent notebook DefaultNotebook
	open note window with NewNote
	
end tell

end run

 

Link to comment

Please don't post the script, upload the workflow.

 

It's not reasonable to expect us to try to first go off and find this SatimageOSAX (never heard of it) and then rebuild your workflow from scratch simply in order to help you.

 

 

Edited by deanishe
Link to comment

 

My apologies for misunderstanding your request. I surely didn't expect you to go find the add-in nor rebuild anything. The problem is not with the add-in. The problem is with the way Alfred is handling the script and my use of "use scripting additions" 

 

If this forum is not the right place for this type of support, I'll try to sort this on my own.

 

https://www.dropbox.com/s/rrvy9oog23bki6x/Broken workflow for Alfred Forums.alfredworkflow?dl=0

 

Link to comment
11 minutes ago, jayelevy said:

If this forum is not the right place for this type of support, I'll try to sort this on my own.

 

You're in the right place, imo, but we're not geniuses. We need to be able to poke around in the broken workflow to figure out what's wrong with it. By posting the workflow, you make it very easy for us to have a look and dramatically improve your chances of getting some useful help.

 

I'll have a look at it after work if it hasn't been figured out by then.

 

As you're using Mojave, could you double-check that you've granted Alfred all the access rights it needs? AppleScript behaving differently in Script Editor and elsewhere is nothing new, I'm afraid, but Script Editor having correct permissions while Alfred doesn't is the simplest thing to verify.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...