REVO2700accountancyFormat() P{function accountancyFormat pNumber,pRounded,pCurrency,pSeparator,pDecimal --// Neatly formats a number, whether positive or negative for uk accountancy purposes. Returns a hyphen for empty or zero. --// --// pNumber the number being evaluated --// pRounded true or empty returns a rounded number, false leaves pence to two decimal places --// pCurrency inserts a string before the result --// pSeparator empty returns a comma, specify an alternative here --// pDecimal empty returns a period, specify an alternative here local tOpenBracket,tCloseBracket,tTheDecimals -- is the value empty? if so, we'll return a hyphen if pNumber is empty then return "- " -- is this negative? if so, we'll return with brackets if char 1 of pNumber = "-" then delete char 1 of pNumber put "(" into tOpenBracket put ")" into tCloseBracket else put space into tCloseBracket end if if pSeparator="" then put "," into pSeparator if pCurrency="" then put empty into pCurrency if pRounded = "false" then if pDecimal="" then put "." into pDecimal set the numberFormat to "0.00" add 0 to pNumber else put round(pNumber) into pNumber end if set the itemDel to "." put item 2 of pNumber into tTheDecimals put item 1 of pNumber into pNumber repeat with i = length(pNumber)-3 to 3 step -3 put pSeparator before char i+1 of pNumber end repeat if pNumber = 0 and pDecimal = 0 then return "- " return (pCurrency && tOpenBracket & pNumber & pDecimal & tTheDecimals & tCloseBracket) end accountancyFormat }maccountancyFormat() ULucida Grande UMonaco WLucida GrandeWLucida Grande WLucida Grande ULucida Grande UCourier ULucida Grande WMonaco WLucida GrandecREVGeometryCachestackID1023 cREVGeneralscripteditorvscroll0breakpointconditionsscripteditorselection73 breakpointsbreakpointstatesstackfileversion2.7 @cREVGeometryCacheIDs1242565789797100912425648850841004124256609810610161242564943920100512425660981071017124256633896610221242565979552101312425663389671023124256608007610141242565941000101012425660800771015124256594100110111242566300321102112425657668881007cREVGeometrycachetotal14order  Field@ \ cREVTable currentviewFunction: accountancyFormat cREVGeneral revUniqueID 1242564885084  Function: accountancyFormat Field @ $>x cREVTablecurrentvscroll0 viewablerows37currentxmouseloc112currenthscroll0currentymouseloc37scrollbarwidth20 cellyspacing13viewablecolumns8rightfieldloc616numbertabstops1 cellxspacing80 leftfieldloc12 topfieldloc36 currentviewP

accountancyFormat([number],[rounded],[currency character],[thousands character],[decimal character])

This is a function to take a number and format it in the UK accountancy style. It has the following parameters:

number the number that you want to format (mandatory)

rounded true = rounds off to a whole number

false = rounds off to two decimal places

currency character

Where is the script?

You can find the script for the function in this stack's script. Copy and paste it into your own.

bottomfieldloc506 cREVGeneral revUniqueID 1242564943920  eaccountancyFormat([number],[rounded],[currency character],[thousands character],[decimal character])  @Blue  @Blue $ @Blue% 9 @Blue: O @BlueP c d pThis is a function to take a number and format it in the UK accountancy style. It has the following parameters: 6number the number that you want to format (mandatory) ,rounded true = rounds off to a whole number * false = rounds off to two decimal places kcurrency character places an optional character in front of the formatted number (default is no character) Pthousands character changes the default comma to one character of your choosing Sdecimals character changes the default full stop character to one of your choosing  Note: All positive results will carry a trailing space character. Thus if you have a mixture of positive and negative results, they will all neatly line up in a right-aligned field.     Where is the script?   bYou can find the script for the function in this stack's script. Copy and paste it into your own. Example builder:   QEnter numbers, characters and change checkboxes to see how the function behaves. P  Label Field  _q cREVTable currentviewNumber: cREVGeneral revUniqueID 1242565766888 Number:  field_number-`^ cREVGeneral revUniqueID 1242565789797  3141652.9849  Label Field  {s cREVTable currentviewCurrency Character: cREVGeneral revUniqueID 1242565941000 Currency Character: field_currency-`z& cREVTable currentview

£

 cREVGeneral revUniqueID 1242565941001  checkbox_rounded`%  Round off to the nearest pound cREVGeneral revUniqueID 1242565979552  Label Field  s cREVTable currentviewThousands Character: cREVGeneral revUniqueID 1242566080076 Thousands Character: field_thousands-`& cREVTable currentview

£

 cREVGeneral revUniqueID 1242566080077  field_decimal-`& cREVTable currentview

£

 cREVGeneral revUniqueID 1242566098106   Label Field  s cREVTable currentviewDecimal Character: cREVGeneral revUniqueID 1242566098107 Decimal Character:Executepon mouseUp local tNumber,tRounded,tCurrency,tThousands,tDecimal put field "field_number" into tNumber put the hilite of button "checkbox_rounded" into tRounded put field "field_currency" into tCurrency put field "field_thousands" into tThousands put field "field_decimal" into tDecimal put accountancyFormat(tNumber,tRounded,tCurrency,tThousands,tDecimal) into field "field_result" end mouseUp RT cREVGeneralscripteditorvscroll0 revUniqueID 1242566300321scripteditorselection410  Label Field  s cREVTable currentviewResult: cREVGeneral revUniqueID 1242566338966 Result:  field_result-` cREVTable currentview

£

 cREVGeneral revUniqueID 1242566338967   3,141,652.98 revOnline | RunRev