IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#20825 - 11/06/07 02:27 PM Formatting a string to display with commas and deciamal point
jehsse1 Offline
OL Toddler

Registered: 07/20/01
Posts: 35
I am trying to format a string up 20 numbers long as currency without the $ sign, I have been able to do this successfully. The issue is that the strings are preceded by a number of zeros that I do not want to display.
For example, if my data is:
00000001123456
I want it to look like this:
1,123,456.00.

Any suggestions, thanks.

Top
#20826 - 11/06/07 02:30 PM Re: Formatting a string to display with commas and deciamal point
jehsse1 Offline
OL Toddler

Registered: 07/20/01
Posts: 35
Forgot to add the code that
I am already using......

define(&cur,string,'1000000000')
define(&cur2,currency,0)
define(&n,integer,1)
set(&cur2,strtocur(&cur))
define(&nbcar,integer,length(&cur))
for(&n,1,1,&nbcar)
show(mid((&cur),&n,1))
%show(inttostr(&nbcar))
if((mod((&nbcar-&n),3))=0)
if(&n<>&nbcar)
show(',')
endif()
endif()
endfor
show('.00')

Top
#20827 - 11/07/07 10:58 AM Re: Formatting a string to display with commas and deciamal point
cosimo Offline
OL Expert

Registered: 10/31/01
Posts: 1286
Loc: montreal
Hi,

To remove the leading zero's simply use this logic.

Code:
show(inttostr(strtoint('00000001123456')))  
It will now return : 1123456

Thanks
Cosimo

Top
#20828 - 11/07/07 02:16 PM Re: Formatting a string to display with commas and deciamal point
cosimo Offline
OL Expert

Registered: 10/31/01
Posts: 1286
Loc: montreal
Hi,

In addition, if you need to format the amount string there are some amount functions that you can download here

Thanks
Cosimo

Top
#20829 - 11/08/07 02:07 PM Re: Formatting a string to display with commas and deciamal point
jehsse1 Offline
OL Toddler

Registered: 07/20/01
Posts: 35
Hi Cosimo,

Unfortunetly my Ptalk expertise is well below average, can you give me the string that I would need to use to do the following:

Data looks like.......0000000192343256

I need it to look like.....

1,923,432.56

Top
#20830 - 11/08/07 04:01 PM Re: Formatting a string to display with commas and deciamal point
cosimo Offline
OL Expert

Registered: 10/31/01
Posts: 1286
Loc: montreal
Hi,

What you need to do is use the function I provided you with.
Simply go under Tools | Document Utilities | Global Function Library Manager
Then go to File | Mage folder and brows to the folder containing the function.
Then under the amounts function on the left hand side, select all the faction and drag and drop on the right and side (blank area) and press OK.

Now add a PressTalk object on the page and type this code.

Code:
define(&amount,string,'')
set(&amount,(inttostr(strtoint('00000001123456'))))
show(@FormatAmountCurr(strtocur(&amount),','))  
Hope this helps you!

Cosimo

Top


Moderator:  cosimo, OL Newsgroup Support