Public Member Functions | List of all members
ReferenceVariable Class Reference

Public Member Functions

 ReferenceVariable (Map specifiers, Format format)
 
String format (Number value, Number reference)
 
Value getPrefix ()
 
 setPrefix (Value prefix)
 
 disable ()
 

Detailed Description

A referenced formatting variable. This object is used to avoid output of values if not required when values are identical to a specific reference value.

var xyzFormat = createFormat({decimals:3, trim:false});
var iVariable = createReferenceVariable({prefix: " I"}, xyzFormat); // note space in front of 'I'
var str = iVariable.format(4.4, 5); // returns " I4.400"
str = iVariable.format(5, 5); // returns ""

Constructor & Destructor Documentation

◆ ReferenceVariable()

ReferenceVariable ( Map  specifiers,
Format  format 
)

Constructs a variable.

Parameters
specifiersThe behavior specifiers.
formatThe instance of type Format used to format the output values.

The supported specifiers are:

  1. prefix: Specifies a prefix to be prepended the formatted value.
  2. force: Specifies that the value always must be output.

Member Function Documentation

◆ disable()

disable ( )

Disable variable. When invoked format() always returns the empty string.

◆ format()

String format ( Number  value,
Number  reference 
)

Returns the formatted string of the specified value. The empty string is returned if the value is identical to the specified reference value. The reference value is optional. If not specified the value will be output.

Parameters
valueThe value.
referenceThe reference value.

◆ getPrefix()

Value getPrefix ( )

Returns the prefix.

◆ setPrefix()

setPrefix ( Value  prefix)

Sets the prefix.

Parameters
prefixThe prefix string.


Generated by Autodesk, Inc. 19 April 2024
Copyright (c) 2012-2024 by Autodesk, Inc.