Formats (BFormat)
A Baja Format (BFormat), is a class that returns object strings using a standardized formatting pattern language (script).
Script
A BFormat script consists of one or more calls chained together using the dot/period (.) operator. BFormat syntax requires that a percent (%) character begin and end each script. Like a wildcard or a variable, you embed BFormat script in static text strings. The system resolves the format (executes the calls contained in the embedded script) starting with the object that declares the format. Then the embedded calls (instructions) dynamically resolve to objects, and the system converts the final object into a string.
BFormats are very important for making templates (reusable portions of the data model tree that require minimal configuration), when creating Px views, and to enable localization (foreign language support).
Many properties that allow text entry support BFormat scripts. For example, a formula can refer to multiple points by using a Value Ord that contains BFormat script:
slot:/Drivers/NiagaraNetwork/%parent.name%/points/%name%The system resolves the BFormat script in this example by substituting the name of the folder that contains the point for the %parent.name%, and the name of the point for %name%.
Call resolution sequence
BFormat scripts consist of one or more calls to methods that execute against system objects.
Within a BFormat, the system resolves calls in this order:
Special calls:
time() returns the current time as a Niagara BAbsTime object
user() returns the current user’s name
lexicon(module:key) get the specified lexicon text
decodeFromString(module:type:escapedEncodedValue)
substring(to) on a string
substring(-fromEnd) on a string
substring(from,to) on a string
Java method get<call>(Context)
Java method get<call>()
Java method <call>()
Java method get(“<call>”)