When I use USING("###,###",ival), when I give it an ival of 10, I expect 'bbbbb10', where b is blank. But what I get is 'bbbb10', it seems to not account for the comma. I would prefer that all comma's are accounted for, since I use a fixed format font, so that all the numbers line up in a column. Am I doing some thing wrong or is this just how USING works?
Thanks,
Bill
https://www.ionicwind.com/forums/index.php?topic=3679.msg29310#msg29310
I am getting old, I even replied to the post. Thanks for reminding me. Will add the line of code, should solve the problem.
Thanks,
Bill
Bill,
It becomes a string with leading spaces, just do what I do ltrim$ it.
int x = 0
x = 12
openconsole
print
print
print " Leading spaces ->",using("######",x)
print
print " No spaces ->",ltrim$ using("######",x)
print
print
do:until inkey$ <> ""
closeconsole
end
Andy.
:)
Except what I was wanting USING to do was to have number like 101 and 1001 to line up (fix format).
So USING("##,###",i) would give me:
bbbb101
bb1,001
where b=blank. What USING does is:
bbb101
bb1,001
Which does not line up.
Bill
Bill,
This one I made today works for a window.
It creates individual static controls for every individual number line by line.
Andy.
:)
Here is what I use to print to a window. I haven't looked at Andy's so if this is similar you can ignore this.
SUB PrintText(WINDOW w, STRING txt, INT x, INT y, OPT INT pos = 0, OPT int maxwidth = 0)
INT pw,ph,px,py,i
int xw,xh
string ntxt
GETTEXTSIZE w,txt,pw,ph
if (maxwidth <> 0) and (pw > maxwidth)
Replace(txt,".","|")
for i=1 to pw
gettextsize w, left$(txt,i) + "...", xw, xh
if xw>maxwidth
breakfor
endif
next i
if i>1
i--
endif
ntxt = left$(txt, i) + "..."
else
ntxt = txt
endif
GETTEXTSIZE w,ntxt,pw,ph
Replace(ntxt,".","~")
Replace(ntxt,"|",".")
py=y:px=x
SELECT pos
CASE 0 'left
py-=ph/2
CASE 1 'right
px-=pw
py-=ph/2
CASE 2 'center
px-=pw/2
py-=ph/2
CASE 3 'decimal
IF INSTR(txt,".",1)>0
GETTEXTSIZE w,LEFT$(ntxt,INSTR(ntxt,".",1)),pw,ph
ENDIF
px-=pw
py-=ph/2
DEFAULT 'where it is
ENDSELECT
Replace(ntxt,"~",".")
MOVE w,px,py
PRINT w,ntxt
ENDSUB
Later,
Clint