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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting number values to Ascii File 1

Status
Not open for further replies.

BnkMaggie

MIS
Mar 24, 2003
4
US
Using Crystal Reports 8.5
Need to export number fields in fixed length format to an ascii file. The formula works for text, but generates
a syntax error for number fields.
Formula is from Crystal's tech support. c2005609.
Detail of formula
numbervar requiredlength:=20;
numbervar currentlength:=length ({LACTG04.AG4_TRANS_AMOUNT});
if requiredlength < currentlength then {LACTG04.AG4_TRANS_AMOUNT}[1 to requiredlength]
else {LACTG04.AG4_TRANS_AMOUNT} + replicatestring("",requiredlength-currentlength)
 
Try something like:

numbervar requiredlength:=20;
numbervar currentlength:=
length(totext({LACTG04.AG4_TRANS_AMOUNT},0,""));
if requiredlength < currentlength then
totext({LACTG04.AG4_TRANS_AMOUNT},0,"")[1 to requiredlength]
else
totext({LACTG04.AG4_TRANS_AMOUNT},0,"") + replicatestring("",requiredlength-currentlength)

-k
 
I should have mentioned that this might be simpler:

totext(123,"00000000000000000000")

The second parameter is the mask to be applied (as in 20 places).

I didn't pay too much attention to your first formula in the first post, you might change the last part to:

replicatestring("0",requiredlength-currentlength)+totext({LACTG04.AG4_TRANS_AMOUNT},0,"")

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top