Public Member Functions | List of all members
Variable Class Reference

Public Member Functions

 Variable (Map specifiers, Format format)
 
String format (Number value)
 
Value getPrefix ()
 
 setPrefix (Value prefix)
 
 disable ()
 
 reset ()
 
Value getCurrent ()
 

Detailed Description

A formatting variable. Instances of this class are used to format incoming values. State is maintained to avoid output for unchanged values.

var xFormat = createFormat({decimals:3, trim:false});
var xVariable = createVariable({prefix: "X"}, xFormat);
var str = xVariable.format(4.4); // returns "X4.400"
str = xVariable.format(4.4); // returns ""
str = xVariable.format(7); // returns "X7.000"

Constructor & Destructor Documentation

◆ Variable()

Variable ( Map  specifiers,
Format  format 
)

Constructs a variable.

Parameters
specifiersThe specifiers.
formatThe desired format.

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)

Returns the formatted string of the specified value. The empty string is returned if the value is identical to the last formatted value.

◆ getCurrent()

Value getCurrent ( )

Returns the last formatted value.

◆ getPrefix()

Value getPrefix ( )

Returns the prefix.

◆ reset()

reset ( )

Invoke to force output of value on the next invocation of format(). reset() has no effect if force has been set to true for the given format.

◆ setPrefix()

setPrefix ( Value  prefix)

Sets the prefix.



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