GFX@PSUVM.BITNET (08/19/89)
My question looks awfully simple and I suppose I am overlooking the obvious here. Please accept my apologies (and suggest a fix ASAP :-) I have to write numerical values to a field and want them to be aligned. Suppose X1 is an integer between 1 and 99 and X2 is an integer between 1 and 999. I do NOT want leading 0s. What is the most efficient procedure? As far as I can see, I'd have to check the numChar of Xs to determine the length of padding I must insert before them, since numberFormat fills the space with leading 0s. I have tried to set numberFormat to " 0." but it doesn't work (the leading blank is ignored). What am I missing? Stephane
walkerl@mrsvr.UUCP (Larry Walker) (08/21/89)
From article <89230.192452GFX@PSUVM>, by GFX@PSUVM.BITNET: > My question looks awfully simple and I suppose I am overlooking the obvious > here. Please accept my apologies (and suggest a fix ASAP :-) > > I have to write numerical values to a field and want them to be aligned. > Suppose X1 is an integer between 1 and 99 and X2 is an integer between > 1 and 999. I do NOT want leading 0s. What is the most efficient procedure? > As far as I can see, I'd have to check the numChar of Xs to determine the > length of padding I must insert before them, since numberFormat fills the > space with leading 0s. I have tried to set numberFormat to " 0." but it > doesn't work (the leading blank is ignored). What am I missing? Stephane No, it's not so simple. I fought with this one a few months ago. If you think it's bad with integers, just try to solve it for reals (like dollars and cents)! I finally ended up writing a general script to return a value right/left-justified/centered, with user-specified number of decimal places and optional dollar-sign prefix. The catch was that, as far as I could discover, the numberFormat property only has effect when putting the value into a field, not when putting it into another variable. I finally had to resort to setting the loc of the message box to (someplace offscreen), putting the value into msg (with the desired numberFormat) and getting it back. Not elegant, but it did work... It was also a bit slow, so I used it as an excuse to write my first non-trivial XFCN. It ran 5x-10x faster when rewritten in Pascal (no need to use the msg box). Both are at home, so I can't post them today. If there's enough interest, I can probably find them. They're very handy for doing reports by writing to a text file (and later printing it with <your favorite editor>). Things like: 1/2/89 Jane Doe 233-8745 $123.45 12/31/89 John Jones 271-4567 $19.95 Larry Walker GE Medical Systems "Not responsible, Waukesha, WI Not insane."