Jump to content

Symbolic path: Difference between revisions

From LabVIEW Wiki
Added the "resource" symbolic path.
Felipefoz (talk | contribs)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
When files are located beneath certain special folders, callers that link to these files will link to them using a ''symbolic path'', rather than an absolute or relative path. The ''symbolic path'' will be relative to the special folder. The following table lists these special folders and their ''symbolic path'':
A '''symbolic path''' (aka. ''pseudo path'') is a placeholder that represents one or more well-known locations in [[LabVIEW]]. When specifying a [[path]] to a file or folder inside a well-known location, rather than specifying the absolute path, the path is specified relative to the symbolic path. When accessing the path, it is resolved to the actual location, which may be different between machines, platforms, targets, and versions of LabVIEW.


{| class="wikitable"
A [[VI]] that uses "<vilib>:\a.vi" may resolve to "<labview>\vi.lib\a.vi" when loaded for a desktop target, and "<labview>\vi.lib\fpga\a.vi" when loaded for a [[FPGA]] target.
|-
! symbolic path
! description
! actual path
|-
| <userlib>
| User Libraries
| <LabVIEW>\user.lib
|-
| <vilib>
| NI Libraries and Addons
| <LabVIEW>\vi.lib
|-
| <instrlib>
| Instrument Drivers
| <LabVIEW>\instr.lib
|-
| <help>
| Help Files
| <LabVIEW>\help
|-
| <osdatadir>
| Default file directory of the operating system
| (OS Dependent)
|-
| <menu>
| Palette Menus
| <LabVIEW>\menus
|-
| <resource>
| Various VIs and resources used by LabVIEW and plugins, and generally not intended to be called by end-user applications.
''Note this first appeared in LabVIEW 2012 (based on [https://forums.ni.com/t5/Developer-Center-Discussions/Make-the-LabVIEW-quot-resource-quot-folder-a-symbolic-path/td-p/3438293?profile.language=en this idea exchange post]) and prior to that it was not a symbolic path.''
| <LabVIEW>\resource
|}


Note that some of these can have the actual path changed by changing the settings in '''Tools>>Options'''. The whole point of the symbolic path is to indicate "load from whatever location this path is currently defined to be."
A symbolic path can also refer to multiple locations that [[wikipedia:superimpose|overlay]] each other as if they were a single directory. If a file with the same name exists in multiple directories, the first file found is used. The order in which directories are scanned may vary and can be determined using the [[Build And Resolve Symbolic Path]] VI with "symbolic path id" set to "<libdir>".


For example, if you have a VI located in the following location:
==Syntax==
Symbolic paths are used similar to drive letters in Windows. For example, "<userlib>:\myfile.txt" specifies a file named ''myfile.txt'' in the [[user.lib]] directory.


<LabVIEW>\user.lib\_OpenG.lib\array\array.llb\Conditional Auto-Indexing Tunnel__ogtk.vi
==Usage==
LabVIEW uses symbolic paths internally to store paths to files and folders. For example, the [[lvproj]] file format stores paths to files using symbolic paths. Symbolic paths are also useful for [[VI Scripting]].


Callers will link to this VI using the following ''symbolic path'':
==Resolving symbolic paths==
In order to access the actual path that a symbolic path represents, it must be resolved. In [[LabVIEW 2023 Q3]] and later, the [[Build And Resolve Symbolic Path]] VI should be used. In earlier versions from [[LabVIEW 2015]] and later, the [[Resolve Symbolic Path (VI)|Resolve Symbolic Path]] VI should be used. For even earlier versions, the private [[Resolve Symbolic Path (method)|Resolve Symbolic Path]] method, which is deprecated since [[LabVIEW 8.5]], can be used.


<userlib>\_OpenG.lib\array\array.llb\Conditional Auto-Indexing Tunnel__ogtk.vi
==See also==
*[[List of symbolic paths]]


''symbolic path'' are not generally encountered. They are used mostly under the hood of LabVIEW, for example, when using the Application '''Linker:Read Info From File''' and '''Linker:Write Info To File''' methods.
==External links==
*[https://lavag.org/topic/10549-resolving-symbolic-paths/ Resolving Symbolic Paths] (LAVA)
*[https://forums.ni.com/t5/Community-Documents/Resolution-of-Pseudopaths-in-LabVIEW-Per-Target-Invocation-of/ta-p/4087124 Resolution of Pseudopaths per Target] (NI forums)


== Resolving Symbolic Paths Programmatically==
You can call the private '''Resolve Symbolic Path''' method to convert a Symbolic Path to an absolute path, as shown in the screenshot, below.
[[Image:ResolveSymbolicPath.png]]
== Auto update of symbolic paths ==
If you have a VI linked to another VI inside a symbolic path LabVIEW will automatically store the path symbolically. Here's the following use case:
Suppose you want to build a LabVIEW tool that resides under the Tools menu but is also accessible via the user.lib palette. What you can do is create a set-up upon built like this:
*[Built]
**[Tools]
***Menu VI
**[user.lib]
***Actual VI
When you copy the contents of ''Built'' to the LabVIEW folder the ''Menu VI'' will have a relative path like ''..\user.lib\Actual VI'' when you do a resave of the ''Menu VI'' the path will be changed to an absolute path ''<userlib>\Actual VI''. Now you can move the ''Menu VI'' around without breaking it.
== When Using Modules (FPGA, RT, etc) ==
A symbolic path may resolve to different actual files on disk depending upon which target the VI is loaded into. So a VI that is written to use <vilib>\a.vi may use <labview>\vi.lib\a.vi when loaded for the desktop target, but may use <labview>\vi.lib\fpga\a.vi when loaded for the FPGA target.
== External Links ==
* [http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/using_symbolic_paths/ LabVIEW Help: Using Symbolic Paths]
[[Category:File IO]]
[[Category:Development Environment]]
[[Category:Development Environment]]

Latest revision as of 10:25, 24 October 2024

A symbolic path (aka. pseudo path) is a placeholder that represents one or more well-known locations in LabVIEW. When specifying a path to a file or folder inside a well-known location, rather than specifying the absolute path, the path is specified relative to the symbolic path. When accessing the path, it is resolved to the actual location, which may be different between machines, platforms, targets, and versions of LabVIEW.

A VI that uses "<vilib>:\a.vi" may resolve to "<labview>\vi.lib\a.vi" when loaded for a desktop target, and "<labview>\vi.lib\fpga\a.vi" when loaded for a FPGA target.

A symbolic path can also refer to multiple locations that overlay each other as if they were a single directory. If a file with the same name exists in multiple directories, the first file found is used. The order in which directories are scanned may vary and can be determined using the Build And Resolve Symbolic Path VI with "symbolic path id" set to "<libdir>".

Syntax

Symbolic paths are used similar to drive letters in Windows. For example, "<userlib>:\myfile.txt" specifies a file named myfile.txt in the user.lib directory.

Usage

LabVIEW uses symbolic paths internally to store paths to files and folders. For example, the lvproj file format stores paths to files using symbolic paths. Symbolic paths are also useful for VI Scripting.

Resolving symbolic paths

In order to access the actual path that a symbolic path represents, it must be resolved. In LabVIEW 2023 Q3 and later, the Build And Resolve Symbolic Path VI should be used. In earlier versions from LabVIEW 2015 and later, the Resolve Symbolic Path VI should be used. For even earlier versions, the private Resolve Symbolic Path method, which is deprecated since LabVIEW 8.5, can be used.

See also

External links