Public Member Functions | List of all members
IncrementalVariable Class Reference

Public Member Functions

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

Detailed Description

An incremental formatting variable. State is maintained to avoid output for zero increments.

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

Constructor & Destructor Documentation

◆ IncrementalVariable()

IncrementalVariable ( Map  specifiers,
Format  format 

Constructs a variable.

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.
  3. first: Specifies the first value to be output. The default is 0.

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. 12 April 2024
Copyright (c) 2012-2024 by Autodesk, Inc.