Padding a Sting from the Left?

I know that I can use PADSTR() to padd a sting with a filler character to the end of a string, is there any function that will allow me to pad to the beginning? The reason I ask is that I need to populate a fixed length field with a decimal field with leading zeros to fill the field. Darren Bezzant, NCPS, NCSD Central Software Ludlow, New Brunswick, Canada dbz@nb.aibn.com

Never Mind. I created a function to do it myself, basically I looped until the desired length appending a zero on the front. Cheers Darren Bezzant, NCPS, NCSD Central Software Ludlow, New Brunswick, Canada dbz@nb.aibn.com

Darren, not standard function. But you probably know the length of the string to export, you can find the length of the string you want to have the leading zeros. So by doing a little programming :-): MESSAGE(PADSTR(’’, 10 - STRLEN(‘TEST’), ‘0’) + ‘TEST’); VOILA! Hope it works, haven’t tried it for you! But sometimes things are done faster just by “trial and error” :-). /Soren

Hi Darren. I think this should do the trick. If Strlen(test) < WantedLenght then __while strlen(test) < WantedLenght do ____test := ‘0’ + test; Regards Gudmundur Petursson

Sometimes i needed doing something similar (usually on dataports) i used a simillar to Gudmundur’s way. But as the while statements won’t run if the while conditional isn’t true… the if shouldn’t be needed. You can do the same with the code while (strlen(test) < WantedLenght) do test := ‘0’ + test; Regards Alfonso Pertierra – Alfonso Pertierra apertierra@teleline.es Spain

A.Pertierra, thank you for correcting me, indeed it is enought and it was in slightly different code I had to make this IF statement. Regards Gudmundur Petursson Edited by - G.Petursson on 11/28/00 5:07:30 PM Edited by - G.Petursson on 11/28/00 5:11:25 PM