I can do it manually of course but I have a brain fart and I wonder if there is an API for this?

I have an Edit Window which can receive up to 10 digit of numbers or letters. Now if the user enters 6 chars, I have to fill the blanks with "0"'s .

If it were numbers I would use wsprintf with %010lu but as there might be letters I can't.

Any API which fills the blanks or do I really have to re-invent the wheel.

Yours lazily,

...of course by typing this I could have probably already done it :-/
Posted on 2011-04-11 07:54:20 by JimmyClif

wsprintf with %010s

I typed by accident %010ls in my code and figured wsprintf was kaputt as I do not make mistakes ;)

Posted on 2011-04-11 08:23:29 by JimmyClif
...or prepare a "000000000" string and copy the one provided by the user onto it (with proper offset: 10 - userStringLen). Should be much faster.
Posted on 2011-04-11 15:59:59 by ti_mo_n
Good point - but I outgrew the re-invention of the wheel a bit :-/

I feel that if I had started doing it manually I would have gotten suckered into writing the left justify, blank fill, zero fill, right justify procedures also and then loose some steam in finishing the job in the few hours provided for the task.

Good old proc having as argument the wsprintf format string made the whole thing very nice to edit. (Especially after I lost the overview at some point and switcherood the left with the right justified ones)

Bureau of Labor file specs aren't much fun ;-) (http://www.bls.gov/cew/cewedr07.htm)

I do have to announce that assembly was my idea of how to get this done the quickest.
Posted on 2011-04-11 18:52:13 by JimmyClif