Experimental Physics and Industrial Control System
I've committed changes to support compilation of Objective C source
files on Mac OS X. Applications can also use code from the Foundation
framework.
To include an Objective-C source file in an application just add it to
the source list in the application Makefile:
example_SRCS += exampleObjC.m
To link the Foundation framework into an application add the following
as well:
example_LDFLAGS += -framework Foundation
Here's a short example showing how the Foundation framework can be used
to send AppleScript messages to other applications:
/*
* exampleAppleScriptRecord.m
*
* Simple Objective-C/AppleScript subroutine record
*
* To use this record in an application:
*
* 1) Make the following changes to the application Makefile:
* - Add exampleAppleScriptRecord.m to the application SRCS.
* - Add -framework Foundation to the application LDFLAGS.
* 2) Add the following line to the application database description:
* function(exampleAppleScriptProcess)
* 3) Add a record to the application database:
* record(sub,"setVolume")
* {
* field(SNAM,"exampleAppleScriptProcess")
* }
*/
#import <Foundation/Foundation.h>
#include <subRecord.h>
#include <alarm.h>
#include <errlog.h>
#include <recGbl.h>
/*
* Shim between EPICS and NSAppleScript class.
*/
long
exampleAppleScriptProcess(struct subRecord *psub)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *err;
NSAppleScript *nsa;
nsa = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:
@"tell application \"Finder\" to set volume %g\n",
psub->A]];
if ([nsa executeAndReturnError:&err] == nil) {
errlogPrintf("Failed to run AppleScript: %s\n",
[[err objectForKey:NSAppleScriptErrorMessage]
cString]);
recGblSetSevr(psub, SOFT_ALARM, INVALID_ALARM);
}
[nsa release];
[pool release];
return 0;
}
--
Eric Norum [email protected]
Advanced Photon Source Phone: (630) 252-2793
Argonne National Laboratory
- Navigate by Date:
- Prev:
Re: device support for R3.14.1 Linux IOC Andrew Johnson
- Next:
When must recGblResetAlarms be called? J. Frederick Bartlett
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
<2003>
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: device support for R3.14.1 Linux IOC Andrew Johnson
- Next:
When must recGblResetAlarms be called? J. Frederick Bartlett
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
<2003>
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024