FOM Reference > Application > Datatypes > fLength interface
  
fLength interface
This object is a simple datatype that represents a length value.
LengthType enumeration
The type of length this object represents.
The LengthType enumeration has the following constants of type int.
TYPE_ABSOLUTE = 0
This length is an absolute value in decimicrons.
TYPE_HEIGHT_PLUS = 5
This length is relative to the current text height, e.g. h, 5+h, etc.
TYPE_WIDTH_PLUS = 6
This length is relative to the current text width, e.g. w, 5+w, etc.
TYPE_HEIGHT = 7
This length is a multiple of the current text height, e.g. 5h, 25%h, etc.
TYPE_WIDTH = 8
This length is a multiple of the current text width, e.g. 5w, 25%w, etc.
TYPE_PARA_PLUS = 9
This length is relative to the current paragraph height, e.g. s, 5+s, etc.
TYPE_LEADING_PLUS = 10
This length is relative to the current text leading, e.g. l, 5+l, etc.
TYPE_PARA = 11
This length is a multiple of the current paragraph height, e.g. 5s, 25%s, etc.
TYPE_LEADING = 12
This length is a multiple of the current text leading, e.g. 5l, 25%l, etc.
TYPE_EM_PLUS = 13
This length is relative to the current em size, e.g. em, 5+em, etc.
TYPE_EM = 14
This length is a multiple of the current em size, e.g. 5em, 25%em, etc.
text attribute
If this property contains text, the length is relative to the size of that text.
text
Access
read-write
Returns
String
type attribute
The type of length, e.g. if value represents an absolute or relative length. This value is one of fLength.LengthType.
Note that by changing this type, the interpretation of value will change and therefore, in general, this object will represent a different physical distance (much as if you changed value directly)!
type
Access
read-write
Returns
int
value attribute
The numeric part of the length. What this value represents is determined by the type property.
value
Access
read-write
Returns
float
fLength method
Creates a new length object.
fLengthlength
Parameters
Stringlength
The expression used to create the length.
If this value is a length object, a copy of the length object is returned.
If this value is a number, the new fLength object's valueOf() method will return that number. That is, passing the number returned by valueOf() to this constructor produces an object whose valueOf() method returns the same number. This is used for arithmetic, for example when adding or subtracting length objects.
Otherwise, this value is converted into a string and parsed as per the usual rules by APP. In particular, if the string does not specify a unit, the default unit of length is used (usually millimeters).
Returns
fLength. The newly created fLength object.
makeAbsolute method
Returns a length object after resolving any relative sizes if appropriate. Note that calling this method does not change this object but instead returns a new object with the desired property.
makeAbsolute
Parameters
None
Returns
fLength. An fLength object that is guaranteed to be absolute.
readResolve method
Return the object corresponding to the given serialized representation.
readResolveobj
Parameters
Objectobj
The serialized representation.
Returns
fLength. The object corresponding to the serialized representation.
toString method
Returns a string representation of this length. Users should not rely on the details of what is returned, but instead use valueOf() to obtain an integral value which represents the absolute length of this object for computations and can be converted back to an identical length object, or toUnit() if a representation in a particular unit of measurement is required.
The result of this method can be converted back to an fLength object by passing it to the constructor.
toString
Parameters
None
Returns
String. A string representation of this fLength object.
toUnit method
Returns the length as a string, represented in the specified unit of measurement. The exact result of this method depends on whether APP is working in strict mode, as defined by tdpref.
The result can be converted back into an fLength object by passing it to the constructor, but rounding errors may occur.
toUnitunit
Parameters
fUnitunit
The unit to convert the length into.
Returns
String. A string representation of this fLength object.
valueOf method
Returns a number representing this length, resolving any relative sizes if appropriate. If no argument is specified, the number that is returned can be converted back into an absolute fLength object by passing it to the constructor.
Note that this method automatically performs the equivalent of a call to makeAbsolute().
valueOfunit
Parameters
fUnitunit
The unit to convert the length into. If this argument is invalid or unspecified, the value will be returned in a unit that is compatible with the fLength() constructor.
Returns
float. The numeric value of this fLength object for use in arithmetic operations in the desired unit, if specified.