Multiple Ways to Interact with OS
I attended the presentation by Christphe Salzmann as NI-Week about the state of LabVIEW and the Mac. He reminded me that there are many ways to interact with the OS. I have been focusing on Call Library Function Nodes to call functions in frameworks like Carbon.
Run AppleScript Code
The great thing about the AppleScript is that it is fairly english like. For operations in the Finder, you can record actions with Script Editor (/Applications/AppleScript) directly to AppleScript. You can even script the interface, for example, select a menu item.
See the wikipedia entry for more information.
System Exec
With the System Exec VI, you can execute commands like you would in Terminal (/Applications/Utilities). Because of the UNIX underpinnings of Mac OS X, this can be a powerful utility. The most difficult part will be parsing the text output. Parse Regular Expression (Programming->String) and Split String, Normalize End Of Line, Join Strings and Escape String (all in vi.lib/AdvancedString) make parsing the text output of command line utilities easier.
A great place to pick up interesting tidbits on command line utilities is Mac OS X Hints.com. As a matter of fact, Run AppleScript Code is just a System Exec to the osascript command line utility.
Open System Command Pipe
This is similar to the System Exec, except that you you get a reference to the standard output, standard input and standard error, and you can interact with those references while the command line program is running. Using pipes is an advanced feature and may not always work as you expected, but it can give you more flexibility when working with command line tools.
Call Library Function Node
This is the option I have been exploring the most in this blog. This allows you to get at just about anything you can do with Carbon and C.
AppleEvent
The AppleEvent VIs have been in LabVIEW a long time. I personally have never used them, but they can be pretty powerful and flexible. If you are familiar with AppleEvents, its a great tool. I personally prefer Run AppleScript Code, which will create all the AppleEvents for me from an English like script.
If you can think of any other ways to interact with the OS in LabVIEW, please post them in the comments.
- Run AppleScript Code (vi.lib->Platform)
- System Exec (Connectivity->Libraries & Executables)
- Open System Command Pipe (vi.lib/Platform/system.llb)
- Call Library Function Node (Connectivity->Libraries & Executables)
- AppleEvent (Data Communication->Protocols->AppleEvent)
Run AppleScript Code
The great thing about the AppleScript is that it is fairly english like. For operations in the Finder, you can record actions with Script Editor (/Applications/AppleScript) directly to AppleScript. You can even script the interface, for example, select a menu item.
See the wikipedia entry for more information.
System Exec
With the System Exec VI, you can execute commands like you would in Terminal (/Applications/Utilities). Because of the UNIX underpinnings of Mac OS X, this can be a powerful utility. The most difficult part will be parsing the text output. Parse Regular Expression (Programming->String) and Split String, Normalize End Of Line, Join Strings and Escape String (all in vi.lib/AdvancedString) make parsing the text output of command line utilities easier.
A great place to pick up interesting tidbits on command line utilities is Mac OS X Hints.com. As a matter of fact, Run AppleScript Code is just a System Exec to the osascript command line utility.
Open System Command Pipe
This is similar to the System Exec, except that you you get a reference to the standard output, standard input and standard error, and you can interact with those references while the command line program is running. Using pipes is an advanced feature and may not always work as you expected, but it can give you more flexibility when working with command line tools.
Call Library Function Node
This is the option I have been exploring the most in this blog. This allows you to get at just about anything you can do with Carbon and C.
AppleEvent
The AppleEvent VIs have been in LabVIEW a long time. I personally have never used them, but they can be pretty powerful and flexible. If you are familiar with AppleEvents, its a great tool. I personally prefer Run AppleScript Code, which will create all the AppleEvents for me from an English like script.
If you can think of any other ways to interact with the OS in LabVIEW, please post them in the comments.
1 Comments:
Never knew that in Mac, we can record our actions with script editor. This is some cool stuff
Post a Comment
<< Home