Fun with AppleScript

Coding Questions, IDE related or anything else

Fun with AppleScript

Postby udo.killermann » Sat May 29, 2010 6:33 pm

Hello Board,

using the latest Beta Objective Basic is now capable to handle AppleScript calls via NSAppleScript and NSAppleEventDescriptor:
Code: Select all
Declare Class "NSAppleEventDescriptor"
Declare Function "NSAppleEventDescriptor" - (NSString *)stringValue
Declare Function "NSAppleEventDescriptor" - (DescType)descriptorType
Declare Function "NSAppleEventDescriptor" - (NSInteger)numberOfItems
Declare Function "NSAppleEventDescriptor" - (NSAppleEventDescriptor *)descriptorAtIndex:(NSInteger)anIndex
Declare Function "NSAppleEventDescriptor" + (NSAppleEventDescriptor *)alloc

Declare Class "NSAppleScript"
Declare Function "NSAppleScript" + (id)alloc
Declare Function "NSAppleScript" - (id)initWithSource:(NSString *)source

Declare Function "NSAppleScript" - (id) executeAndReturnError: (NSError **) errorInfo

Event AwakeFromNib()
  Dim myScriptString As String
  Dim myASScript As NSAppleScript
  Dim myAEDescriptor As NSAppleEventDescriptor = Nil
  Dim err As id = Nil
  myScriptString = "choose URL"
  myAEDescriptor = myASScript.executeAndReturnError(errinfo := err)
End Event

Code: Select all
myScript="tell application \"System Profiler\"\nset detail level of document 1 to basic\nset theProfile to profile of document 1\nend tell"
you will see the current system configuration.

Have Fun
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: Fun with AppleScript

Postby berndnoetscher » Tue Jun 01, 2010 7:04 pm

Hi Udo!

Thanks for your feedback.
Happy coding :-)

Site Admin
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 0 guests