March 28, 2024, 05:32:45 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Question about USING

Started by billhsln, September 27, 2019, 01:31:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

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
When all else fails, get a bigger hammer.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

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
When all else fails, get a bigger hammer.

Andy

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.
 :)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

billhsln

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
When all else fails, get a bigger hammer.

Andy

Bill,

This one I made today works for a window.

It creates individual static controls for every individual number line by line.

Andy.
 :)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

ckoehn

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