The MacView

Virtual Instrumentation from a Mac perspective

Thursday, August 17, 2006

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.

  1. Run AppleScript Code (vi.lib->Platform)
  2. System Exec (Connectivity->Libraries & Executables)
  3. Open System Command Pipe (vi.lib/Platform/system.llb)
  4. Call Library Function Node (Connectivity->Libraries & Executables)
  5. 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 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.


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.

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.

Tuesday, August 08, 2006

20th Anniversary LabVIEW 8.20 Released Today

Today, 8/8 at 8:20 am, National Instruments released the 20th Anniversary Edition was released, featuring native Object Oriented programming and support for Intel Macintosh machines.

Other Headlines:

National Instruments LabVIEW 8.20 page
Business Wire Post

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.