I'm trying to take an A4 filed from my SQLServer data base that sometimes has less than 4 values and pad it with leading zeros, i.e. a School_ID value of 13 becomes 0013. I've looked at the EDIT function, but I must be missing something as this doesn't do what I want.
Thanks! Chuck Mason
April 14, 2005, 07:55 PM
Roland
Hi Chuck,
I guess the following should give you the desired result. Put it in a DEFINE or a COMPUTE:
format A2L packs with leading zeros, that's what the L indicates. although of late i've seen it work, as Roland says, even without the L. which makes A w/leading blanks a puzzle now.
April 14, 2005, 08:11 PM
Chuck Mason
Roland -
Thanks for the post! I tried that, but it doesn't add leading zeros. My 13 stayed 13. I need the field to go from '13' to '0013'
April 14, 2005, 08:14 PM
Chuck Mason
Susannah -
Let me try that one...Thanks!
April 14, 2005, 08:31 PM
<Pietro De Santis>
Try the L for leading zeros.
DEFINE FILE CAR XTEST/A6 WITH SALES = '23'; YTEST/I6L = EDIT(XTEST); ZTEST/A6 = EDIT(YTEST); END TABLE FILE CAR PRINT YTEST ZTEST
ON TABLE SET PAGE NOLEAD ON TABLE SET STYLESHEET * TYPE=REPORT, GRID=OFF, FONT='VERDANA', SIZE=8, $ ENDSTYLE END
April 15, 2005, 08:25 AM
Roland
Chuck,
I am surprised it didn't work. I tried it myself on WF526 and it worked perfectly:
DEFINE FILE CAR X/A4 WITH COUNTRY = '13'; X_I/I4 = EDIT(X); X_A/A4 = EDIT(X_I); END TABLE FILE CAR PRINT X X_I X_A BY COUNTRY END
This gives me '0013' in X_A. EDIT is always adding leading zeros while converting from numeric to alpha, as far as I can remember.This message has been edited. Last edited by: <Mabel>,