Page Blocks

Hosting sponsored by:

Point In Space

 

API: Num

Filename:
fwpNum_dec4.ctag

Released With:
5.0.0

Current Version:
1.0.1

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpNum_dec4 (Tag)

Description

Formats a specified number into a decimal format with four digit precision.

Uses the character specified by $fw_numGroupChar to separate thousands, etc. Uses the character specified by $fw_numDecimalChar to separate whole and fractional values. Therefore, it can create numbers in 123,345,678.9999 and 123.345.678,9999 formats.

Syntax

[fwpNum_dec4: integer|decimal]

Examples

[fwpNum_dec4: 3.1415169] results in 3.1415

[fwpNum_dec4: 3] results in 3.0000

[fwpNum_dec4: (field:'specificGravity')]

Source Code

View in separate window

<?lassoscript
//............................................................................
//
//    pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*

    {fileName=        fwpNum_dec4.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpNum_dec4 }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpNum_dec4 }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

    {author=        Greg Willits }
    {authorEmail=    subscribe to pbTalk at www.pageblocks.org/talk/ }
    {authorHTTP=    www.pageblocks.org }

    {desc=            formats a number with four decimal places and thousands separators }

    {maintvsrn=        1.1 }
    {maintrelease=    5.2.5 }
    {maintdate=        2006-07-23 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added comma stripping so strings like 1,000 would
                     convert properly }

    {maintvsrn=        1.0.1 }
    {maintrelease=    5.1.0 }
    {maintdate=        2006-08-07 }
    {maintauthor=    Greg Willits }
    {maintnotes=    updated to use $fw_client }

    {maintvsrn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release }

*/
//............................................................................

define_tag:'fwpNum_dec4', -priority='replace';

    local:'fw_num' = string:(params->get:1);
    #fw_num->(replace:',','');
    #fw_num = decimal:#fw_num;

    #fw_num->(setformat: 
        -precision        = 4, 
        -groupchar        = $fw_client->thousandsChar,
        -decimalchar    = $fw_client->decimalChar);

    return: #fw_num;

/define_tag;
?>

© 2002-2012, pageblocks.org