Leveraging OSX built-in features

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lharris
Posts: 20
Joined: Fri May 22, 2009 5:27 pm

Leveraging OSX built-in features

Post by lharris » Fri Sep 11, 2009 2:49 pm

I was wondering if anyone can help me. I'm not interested in cross platform development - just osx. I am planning on developing an office scheduler/appointment manager that integrates with a contact list (information is shared between the two) that also allows tracking of other info along with appointments.
OSX has ical and contacts built in that are standards based, the server allows muiltiuser and web based calendars etc.
Is there a way to use revolution as a front end to manage the additional info I need, and let osx manage the calendaring, web, multiuser, etc. so I don't have to reinvent the wheel?

Thanks

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Fri Sep 11, 2009 4:28 pm

lharris,

did you have a look at applescript? You can integrate applescript into rev. So if you can get at the data you want via applescript you can built your additional front end with relative ease with Rev.
have a look at this thread: http://forums.runrev.com/phpBB2/viewtop ... pplescript depending on what you want this can get quite involved.
regards
Bernd

lharris
Posts: 20
Joined: Fri May 22, 2009 5:27 pm

Post by lharris » Fri Sep 11, 2009 6:58 pm

AppleScript seems very kludgy and kind of defeats using revolution.
Are ther no built in functions to access this?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Fri Sep 11, 2009 7:28 pm

lharris,
Is there a way to use revolution as a front end to manage the additional info I need
What is the additional info you need, if you could give an example it would be easier to understand what you are trying to do and what part of that Rev can do for you.
AppleScript seems very kludgy and kind of defeats using revolution
It depends. Applescript is a language on its own and has its quirks and a learning curve. But considering what level of interapplication integration you can achieve it is amazing. Rev can provide the user interface and all that which Applescript has a hard time to do. And Rev can do things Applescript can not.
Mind you a lot of workflows in the publishing industry are leveraging Applescript. And they do amazing things this way. But you are right, it is a well kept secret weapon, or call it kludgy.
I would not give up on the idea to soon.
Some people try to access the raw data of iCal or Addressbook(xml), but that is over my head. I dont know if they succeed and I would not want to tinker with the original files, sounds a little risky. By the way parsing xml is no fun either.

Maybe you just give an outline of your project and people here have a better idea then applescript.
regards
Bernd

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Fri Sep 11, 2009 7:36 pm

There may be lower-level API available to Cocoa apps using Core Data, but Rev doesn't currently use Core Data and given how specific Core Data is to not just OS X but specific versions of OS X I wouldn't hold my breath for that.

Besides, as a multi-platform tool the range of platform-specific features in Rev will always be a bit limited relative to what they could do if they could afford to blow off other OSes and just focus on one. If they were going to add hooks specifically for iCal, they'd probably want to add hooks into Outlook on Windows first, given the order-of-magnitude more users who could benefit from that. That would make sense in terms of their ROI, but doesn't solve your need.

You could submit a request for that, but while you wait to see where it winds up in the development queue you can have a useful result right now today using Rev's built-in support for AppleScript.

On OS X, AppleScript is how apps communicate with each other (well, that and sockets, but those are less commonly used for GUIS on Mac). With Rev you can run blocks of AppleScript code, and get data back from them.

Yes, AppleScript is an inherently slow mechanism, but as the established way to use inter-app communication on Macs I don't know if I'd consider it kludgy. It's not my favorite language either, but when I need it I'm glad it's there.

I just took a brief look at the AppleScript dictionary for iCal, and it seems pretty extensive. I would imagine you'd be able to get what you need from that with minimal effort.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

lharris
Posts: 20
Joined: Fri May 22, 2009 5:27 pm

Post by lharris » Sat Sep 12, 2009 8:44 pm

I'll give applescript a try. What I wanted to do was build a patient database that stores medical records, tests, forms, billing info, but also be able to schedule appointments and send emails. I could do it all in a mysql database but was hopeful I could skip the calendaring portion as I have always found them a pain to render visually. As Caldav is now a standard, I thought it would be nice to use that and since OSX has all this already built-in, it would be easy to sync with an iphone.

Thanks - if there are any other suggestions, please let me know.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Sun Sep 13, 2009 12:20 am

lharris,

try this to give you an idea:
make a new stack with 2 fields and 1 button
paste this applescript code into field 2

Code: Select all

tell application "iCal"
	set x to properties of every event in calendar "myCalendar" whose start date > (current date) --and summary contains "nameOfPatient"
	set y to ""
	-- make a return delimited listing of the result
	repeat with anItem in x
		set y to y & "----" & linefeed
		set y to y & uid of anItem & linefeed
		set y to y & summary of anItem & linefeed
		set y to y & start date of anItem & linefeed
	end repeat
	
	if y ≠ "" then
		-- takes out the last return the 4 dashes and another return	
		set y to text 1 through -2 of y
	else
		set y to "nothing found"
	end if
	return y
end tell
in above code you fill in whatever the name of your calendar is. It then searches all events that are later than today. If you want you can deblock the comment in the search where there is myPatientName and fill in search criterion.

set the code of the button to

Code: Select all

on mouseUp
   do field 2 as applescript
   put the result into myResult
   if char 1 of myResult = quote then delete char 1 of myResult
   if char - 1 of myResult = quote then delete char -1 of myResult
   put myResult into field 1
end mouseUp
it will return to you part of the property record of each event with
the ID of the event
the summary of the event
the start date of the event
(of course you could add to this or ask for something different altogether)
It is then broken up with dashes at the top of a record to parse it in Rev. Then a little clean-up and the records are returned to Rev.

Applescript is as you say a little kludgy with regards to text handling and some other things too, but the pdf "applescriptlanguageguide" from apple is not bad as a reference.
Also it is worthwile to look at http://macscripter.net/ there is a wealth of information and scripts.

this should give you something to start and feel free to ask here if you get stuck.
regards
Bernd

Post Reply