Focal Point
leading zeros: integers to string

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9651008331

October 04, 2004, 08:15 PM
<bigpgo>
leading zeros: integers to string
Hello. I'm trying to print my integers as strings (because I want to concatenate them with the word " days"). So when I do:

COMPUTE temp/A12 = EDIT(numDays)| ' days';

my result looks like:

"00015 days" instead of "15 days". I tried making a temporary field in define, such as:

myNum/P7S = numDays;

and then putting that into EDIT. Still same leading zeros. Please help.
October 04, 2004, 08:36 PM
GCohen
You need to provide the Edit mask.
So if the integer is 2 digits and 3 leading zeros to ignor..
newvalue/A12=EDIT(NUMBER,'$$$99')|' Days');

where the $ are ignored, and the 9's are selected.
October 04, 2004, 08:37 PM
jimster06
Take a look at the TRIM function and its possible use on an intermediate variable.
October 04, 2004, 09:11 PM
<bigpgo>
Unfortunately, I cannot use the Mask - my number of days can vary from 1 to 7 digits long, and can also be negative.

TRIM function? Where can I find documentation for that? Thanks.
October 04, 2004, 09:30 PM
pruittlr
TRIM is a function and is located in the Using Functions manual.

If you don't have the manual, here's the syntax:
TRIM(trim_where, string, string_length, pattern, pattern_length,outfield)

Ex:
CTR/A3=TRIM('L',CTR2,3,'0',1,'A3');

trim_where (alphanumeric) = L for leading, T for trailing, B for both

string (alphanumeric) = source character string enclosd in single quotes, or the field containing the string

string_length (integer) = length of string in characters

pattern (alphanumeric) = pattern to remove enclosed in single quotes

pattern_length (integer) = number of characters in pattern

outfield (alphanumeric) = field where the result is returned, or the format of the ouput value enclosed in single quotes

Hope this helps.

Raelene
October 04, 2004, 10:05 PM
susannah
ITEMP/I8 = 00000108; or ITEMP/I8=108; same result
FTEMP/F8=ITEMP;
BTEMP/A8=FTOA(FTEMP,'(F8)',BTEMP);
CTEMP/A15=BTEMP || ' ' | 'days';

and CTEMP is then '108 days'
This works; Icky, but works;
FTOA is 'floating point to alpha' and is on page 9-6 in the manual "Using Functions"
October 04, 2004, 11:07 PM
<bigpgo>
FTOA worked! Thanks for all your help.

(I do not have a copy of the manual, and I have not been able to find complete documentation online; that's why I did not know about FTOA or how it worked)
Thanks again.
October 05, 2004, 01:37 PM
<monte2000>
bigpo - Have you visited Tech Support or Documentation Services?