GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Five — General Functions (continued)
Overview
The FormatNumber converts a string, integer or float value to a formatted string with regional options and the ability to control the decimal places.
Syntax/Parameters
Syntax
string = FormatNumber ( int value, [dword options] );
string = FormatNumber ( float value, [dword options] );
string = FormatNumber ( string value, [dword options] );
Parameters
value
A string containing a flat number.
options
A dword containing option bits for the formatting of the number. The default value is:
FN_US_FORMAT | FN_ROUND_HALF_EVEN | 2
Return Value
Returns a string containing the formatted number or an empty string on failure. Use the GetLastError function to retrieve error information.
Remarks
There are a number of functions to format numbers. This function is designed to help with processing of data into numbers for representation on reports or other data sheets by allowed for a number of options including rounding.
The FormatNumber function is very forgiving for string source format data, ripping out most non-numeric data.
for string operations, if there is a ‘%’ suffix in the source value, the FN_PERCENT option is automatically be enabled. However, this disabled the math component treating the scaling of the incoming number as-is.
The options are as follows:
Definition | Bitwise | Description | |||||
Decimal Fraction | |||||||
FN_DECIMALS_MASK | 0x0000000F | Decimal Mask (count of decimals) | |||||
Options | |||||||
FN_OPTIONS_MASK | 0x0000FFF0 | Options Mask (flags) | |||||
Negative Numbers | |||||||
FN_NEGATIVE_MASK | 0x00000030 | Negative Mode Mask | |||||
FN_NEGATIVE_LEADING_DASH | 0x00000000 | Negative as Leading '-123' | |||||
FN_NEGATIVE_TRAILING_DASH | 0x00000010 | Negative as Trailing '123-' | |||||
FN_NEGATIVE_PAREN | 0x00000020 | Negative in the Hole '(123)' | |||||
Rounding | |||||||
FN_ROUNDING_MASK | 0x000000C0 | Rounding Mode Mask | |||||
FN_TRUNCATE_NUMBER | 0x00000000 | Truncate Extra Digits Number | |||||
FN_ROUND_HALF_EVEN | 0x00000080 | Round Number Up/Down | |||||
Source Options | |||||||
FN_EU_SOURCE | 0x00008000 | Source Decimal is a Comma | |||||
Resulting Format (ordinal) | |||||||
FN_FORMAT_MASK | 0x000F0000 | Format Mask | |||||
FN_STRIP_FORMAT | 0x00000000 | No formatting | |||||
FN_US_FORMAT | 0x00010000 | Format in US, UK, Canada Style | |||||
FN_EU_FORMAT | 0x00020000 | Format in Euro Style | |||||
FN_PERCENT | 0x000A0000 | Format as Percent (100th) |
Aside from truncation, the only current rounding option is even/half. This method take 5 and above and rounds up, without regard to sign. So for a whole number, if the incoming is 23.5 the result will be 24 and if -23.5 the result will be -24. Rounding occurs on last significant digit.
The FN_EU_SOURCE option should only be used with string input and if the number is in Euro format, i.e., “123.345,67”. This is important to the parse to process since the decimal character is pivotal to the parsing process.
Unless a ‘%’ is in the source string, using the FN_PERCENT option will treat the incoming value as a fraction of 100%. As such, “.20” will become 20%.
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Page revised 2024-12-13
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.