Jump to content
jayelevy

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

 

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post

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

 

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post

 

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

 

Share this post


Link to post
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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...