Localization Codes in LabVIEW

Updated Nov 8, 2018

Reported In

Software

  • LabVIEW

Issue Details

What are the Localization Codes in LabVIEW? Why do some LabVIEW instrument drivers use " .; " ahead of the format string?

Solution

Localization Codes are typically (though not necessarily) used with format statements in LabVIEW. You will often see them in National Instruments instrument drivers. Localization Codes are referred to in Table 6-2 of the LabVIEW Function and VI Reference Manual

Typically, you will see a format string such as "%f" or "%d" etc. Sometimes your format string can be something like "%.;%f", where %.; (period followed by a semi-colon) is the Localization Code. This is most often needed on operating systems that do not use English, or at least operating systems that have a decimal symbol other than "." (e.g., German operating systems may have commas as the decimal separator). This can be set in Start » Settings » Control Panel » Regional Settings » Number » Decimal Symbol on your operating system.

In LabVIEW there is a setting under Tools » Options » Front Panel called "Use Localized Decimal Point." If this setting is FALSE, the conversion functions (such as string conversion functions) always use a period. If the preference is TRUE, the functions use the system's setting for localized decimal point (that are set as explained above). 

Having a default decimal separator other than a period will generate problems, however, if you use the string conversion functions to generate strings for GPIB, message-based VXI, or other communications (DDE, OLE, etc.), because these devices expect decimal delimiters to be periods. You can force the string to use a period as a separator by adding the Localization Code " .;" ahead of the actual format string. This will cause a number such as 3,55 to show up as 3.55.

Alternatively, you can use the Localization Code " ,; " (comma followed by a semi-colon) to force a number such as 3.55 to be converted as 3,55. That is why, when you have a decimal number as a parameter to an instrument, the format string has a ".;" ahead of it. It is good programming practice, since the user can now use this VI on operating systems which do not have the period as the default decimal separator.
 

Additional Information

There is a LabVIEW library (from an instrument driver) attached to this KB below. This contains examples of utilizing localization codes.

WAS THIS ARTICLE HELPFUL?

Not Helpful