Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

0 fill a number field, export to text file. 1

Status
Not open for further replies.

rmiller11

MIS
Jan 20, 2003
43
0
0
US
I am trying to do a report for the back which has to be exported as a text file and sent electronically. I can not figure out how to "0" fill a number field to 10 digits ie:

$2312.00 would be 0000231200

Also, would I be able to format the export to have 80 characters with no spaces in between the fields? No lines before the detail or after the detail.
 
Here - try this;

ReplicateString ("0",8 - Len(ToText({Table.Field},0,""))) +
ToText(Truncate({Table.Field}),0,"") +
Right(ToText({Table.Field},2,""),2)

Peter Shirley
 
That worked perfectly, now I have another field that is a text field ie:

007234 and I need it to 0 fill to 10 characters. that same formmula would not work on this field cause it is a text.

 
The same concept applies - except this one's even easier (but I'm not going to give you the exact formula). You need to establish the length of the string - that's the purpose of the Len command in the original example - then you need to add the correct amount of leading zeros to fill up to the length of your field - that's where the ReplicateString command comes in. If you take the ToText option out of the first line in my original formula, and do away with the other lines - you should be close..

Peter Shirley
 
rmiller11,
this sounds like we are working on the same project, how can i contact you
 
A common need for exports, try:

whileprintingrecords;
numbervar FieldLength := 10 //change this appropriately
Replicatestring("0",fieldlength - Len(trim({Table.Field}))) +trim({Table.Field})

Note that you should add in a trim function here.

-k
 
If you are converting a number field to text, you can specify leading zeros within the ToText function like :

Totext(2312.00,"00000000.00")

This would give you 00002312.00

You can then remove the decimal point using :

Replace(Totext(2312.00,"00000000.00"),'.','')

This results in 0000231200

Reebo
UK

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
- Albert Einstein (1879-1955)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top