Creating formatlocale objects – Echelon LNS User Manual

Page 259

Advertising
background image

LNS Programmer's Guide

245

the PC running your application. The default settings may vary, depending on

which operating system is installed on the PC. Consult the MSDN documentation
of the Win32 GetLocaleInfo() function for more information on the Windows

Regional settings.

3. LonMarkCompatibility. When you use this FormatLocale object, all

properties will be set so that formatted data will be displayed based on the
LonMark standards used prior to LNS 3.0, when localized formatting was not

available. In this case, Systeme Internationale measurement units, LonMark-

defined time and date formats, and U.S. options for everything else will be used
to display all formatted data.

4. ISO8601DateAndTime. When you use this FormatLocale object, all properties

will be set to be the same as the LonMarkCompatibility settings, except for the

localized time and date formats, which will be based on the ISO 8601 standard.
This standard helps avoid confusion that may be caused by the different national

notations used for dates and times, and increases the portability of computer user

interfaces.

Creating FormatLocale Objects

The four pre-defined FormatLocale objects are read-only, but you can create custom
FormatLocale objects to suit the specific needs of your application with the Add

()

method of the FormatLocales collection. Note that all custom FormatLocale objects

are instantiated with the same settings as the pre-defined
UserDefaultRegionalSettings FormatLocale object described above.

To create a custom

FormatLocale

object, and assign it as the

CurrentFormatLocale

,

follow these steps. Note that you can only create and configure your custom

FormatLocale

objects, and set the

CurrentFormatLocale

property, before opening

any networks and formatting any data with your application. Operations that will cause
your application to format data include acquiring a DataPoint object, and reading or

writing the value of a ConfigProperty or NetworkVariable object. If you write to the
CurrentFormatLocale property after performing any of these operations, or attempt to

modify the FormatLocale object acting as the CurrentFormatLocale, the LCA:#122
lcaErrReadOnlyInContext exception will be thrown.

1. Open the Object Server as described in Chapter 4 of this document.

2. Access

the

FormatLocales

collection.

Dim MyFormatLocales as LcaFormatLocales
Set MyFormatLocales = ObjectServer.FormatLocales

3. Invoke

the

Add()

method to create a new

FormatLocale

object.

Dim MyFormatLocale as LcaFormatLocale
Set MyFormatLocale = MyFormatLocales.Add(“myNewFL”)

4. Set the properties of the new

FormatLocale

object to match your

application’s requirements. These properties are described in Table 9.6.

5. Assign the new

FormatLocale

object to the

CurrentFormatLocale

property.

Set ObjectServer.CurrentFormatLocale = MyFormatLocale

Advertising