LabVIEW File Path Type is Cross-Platform

If you’re a regular LabVIEW user you’ve probably programmatically (sorry, I hate that word too) referenced another file at some point. Most likely you’ve done this 212 to save some data or dynamically open another VI. Both tasks require the path to the file you need to work Gaziantep with. The challenge, however, is that path formats are OS dependent. For example, Windows uses the backslash (\) for denoting directory levels while Mac OS X uses the forward slash (/). If you plan on accessing a file using the Strip and Build Path functions, you need to use the correct slash to get to the new location. Using a string data type will require you to do a bit of extra work to properly identify the operating system and then the properly formatted string. Good news: there is a better way.

So many slashes, so little time...

So many slashes, Non so little time…

One of the strengths of LabVIEW the is that it ships with a number of functions and primitives that assist with solving common programming Олег problems. Building proper file paths definitely falls into that wholesale nba jerseys category. The LabVIEW File Path data type will automatically adjust the path to contain the proper slashes required by wholesale MLB jerseys the OS. Granted, it may not look like it. In Windows, the File Path constant/control only accepts inputs with backslashes. But really, it works!

Another challenge is handling the target directory properly for RT systems. The root directory for a Phar Lap target (most likely LabVIEW RT on a PXI target) is C:/ but for a VxWorks target (probably LabVIEW RT on a cRIO) it’s /c/. Using the File Path Comparisons data type will automatically adjust the root directory for the target that is currently executing.

Default directory constants are also cross-platform. To save to the OS’s default data directory, just use the appropriate constant.

LabVIEW File Constants are Cross-Platform.

LabVIEW File Constants are Cross-Platform.

Why is this important? Mostly for code reuse. It’s not unusual to rethink a design decision in the middle of development and need to move code wholesale MLB jerseys from the Windows host to an RT Target, or from the RT to Windows. If you need to access files external to your VI, using the File Path data type will save you the headache of having to edit a bunch of strings. Another instance for cross-platform forward thinking: toolkit or library distribution. Remember, LabVIEW VIs are inherently cross-platform. A VI developed in Windows can be run and edited on a Mac or Linux machine (and vice versa). Making your toolkit cross-platform ensures Mac and Linux users can benefit from your work (or conversely, wholesale NFL jerseys you can develop and test on a Mac, then distribute to Windows).

Tags: , ,

Leave a Reply