Using Applescript libraries from LC

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
trevix
Posts: 434
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Using Applescript libraries from LC

Post by trevix » Wed Aug 29, 2018 9:54 am

In the AS Script Editor, after having installed the Shane's "CalendarLib EC" in the script folder, this script works fine, deleting a specific event from the OSX Calendar.app (replace <UID> with the UID of the event):

Code: Select all

use script "CalendarLib EC" version "1.1.3" -- put this at the top of your scripts
use scripting additions

set theStore to fetch store
set theEvents to fetch events by UID "<UID>" event store theStore
try
	remove event event item 1 of theEvents event store theStore with future events
on error theErr
	return "NotFound"
end try
Saved in the LC properties and run from a LC script with the "using Applescript", does not work any more.

Please note that other conventional AS scripts, that don't use the Shane's library, work fine, like creating new events or the following (check if Calendar.app is open or not)

Code: Select all

set appName to "Calendar"
if application appName is running then
	tell application appName
		--activate
		set TheVis to the visible of front window
		if TheVis is false then
			set the visible of front window to true
			--keystroke "0" using command down
		end if
	end tell
	return true
else
	return false
end if
All permissions are fine.

Any clues?
Trevix
Trevix

trevix
Posts: 434
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Using Applescript libraries from LC

Post by trevix » Wed Aug 29, 2018 4:59 pm

One more thing.

I modified and streamlined the script to this:

Code: Select all

use scripting additions
use myLib : script "CalendarLib EC" version "1.1.3"-- Stored in my ~/Library/Script 
try
		set theStore to (fetch store)
on error terr
	return terr
end try
in the result I get:
"Unable to load the" EventKit "bundle because it does not contain any version for the current architecture."
Trevix

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3491
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Using Applescript libraries from LC

Post by richmond62 » Wed Aug 29, 2018 5:45 pm

1. I understand absolutely nothing about how one might use AppleScript inside LiveCode.

2. I don't know why one would bother when one can use LiveCode's own language.

3. BUT, I did read this:

http://runtime-revolution.278305.n4.nab ... 61727.html

Which would seem to suggest you need to have something like this:
do tScript as applescript
somewhere.

There's nothing quite like a web-crawl after supper:

"you cannot tell LC "do script xyz" from OUTSIDE of Livecode" 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3491
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Using Applescript libraries from LC

Post by richmond62 » Wed Aug 29, 2018 5:57 pm

the current architecture
PPC/INTEL . . .

32/64 bit . . .

https://macscripter.net/viewtopic.php?id=18010

trevix
Posts: 434
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Using Applescript libraries from LC

Post by trevix » Wed Aug 29, 2018 6:40 pm

Hi

2. I guess you never had the need to add/modify/delete events on the OSX Calendar. (No way with LC)
3. off course I do a "do as applescript". That's not a problem

I use the Shane's external library because is fast (based on the OSX EventKit) and does not need the Calendar.App to be open.
I also read/modify/create Calendars and Events using a mix of Applescript and SQLite reading (from the Calendar cache file).

What I am not able to do is delete an Event.
The only Applescript that seems to be able to delete an event is if using Shane's library.
Works perfectly in the "Script Debugger.App" but not on Livecode

Regards
Trevix
Trevix

trevix
Posts: 434
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Using Applescript libraries from LC

Post by trevix » Wed Aug 29, 2018 7:38 pm

News: solved
I downloaded LC 9.0.1 (I was using 8.1.10).
Everything works fine for deleting events using the Library "CalendarLib EC".

I guess is a LC8.1.10 bug.
Should I report it or LC8 is dead?
Trevix

bogs
Posts: 3716
Joined: Sat Feb 25, 2017 10:45 pm

Re: Using Applescript libraries from LC

Post by bogs » Wed Aug 29, 2018 7:43 pm

That is a good question. I wish I had a good answer :?

Myself, I would report it if it hasn't already been done.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3491
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Using Applescript libraries from LC

Post by richmond62 » Wed Aug 29, 2018 7:57 pm

Should I report it or LC8 is dead?
It is supposed to be dead: but I think it is a "bit naughty" leaving it with several bugs.

Had a "shaky" problem with it on Linux about 3 days ago.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6791
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Using Applescript libraries from LC

Post by FourthWorld » Wed Aug 29, 2018 11:02 pm

richmond62 wrote:
Wed Aug 29, 2018 7:57 pm
Should I report it or LC8 is dead?
It is supposed to be dead: but I think it is a "bit naughty" leaving it with several bugs.
In 30 years in the biz I've never seen bug-free software. As with companies and big and small, from drawing apps to operating systems, each new version is a superset of capabilities found in older version, along with new bug fixes as well.

Everything you like about 8 should be in 9. If you find something that isn't, please file a bug report.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3491
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Using Applescript libraries from LC

Post by richmond62 » Thu Aug 30, 2018 8:18 am

Everything you like about 8 should be in 9.
One thing isn't: it doesn't run on my favourite hardware. 8)

Post Reply

Return to “Mac OS”