Due to a lot of help from the great team on these Forums, I have generally got to grips with searching array$ using the various cmd available.
However, formatting each file within the array$ to neatly line up with the file above and below when printed to screen is another matter. I am trying to format the arrays and then concatenate then into 1 single array to be displayed in a listbox
Array - a$ and b$ are a fixed length so that isn't a problem, but info$ and type$ aren't. It's only really info$ that is the problem, type$ is displayed last so that's fine.. eg. array$(1) = a$ + b$ + info$ + type$ I have been using the code: sp = (60 - len(info$) to get the no. of spaces needed to evenly separate info$ from type$so I get............... array$(1) = a$ + b$ + info$ + space$(sp)+type$,
As characters are larger than spaces, as info$ varies in size constantly, then although the number of spaces added may be correct, but because they are shorter than ASCII characters nothing lines up with the next line. Although a 'space' seems to be approx 1/2 the size of an ASCII character just doubling the amount of spaces doesn't work either!
How can I format this correctly? I am trying to get
There is another way, not easy, not perfect but you can use any font. Now that I look at your OP again, my method will also be a 1/2 space off but you cna still iuuuse different fonts.
graphicbox #main.gb1 1,1,1,1 First you have to have a tiny graphic box in your main window or a window that is open. I happen to have my main window open at all times.
This code will format text with the spacing after it based on the font you are using. You format the text Something$ with the font size you are using and the space you want after the the text.
a$=FormatStr$(Something$,FontSize$, space) b$=FormatStr$(Somethingelse$,FontSize$,space) c$=FormatStr$(Somethingelse$,FontSize$,space) ListBox$(yourname)=a$+b$+c$ The text is now formatted and you concatenate the strings and display it in your list box.
Function FormatStr$(a$,listfont$,width) 'Formatting width for list boxes and displays. #main.gb1,listfont$ 'sets the graphic box with the font you are using. onePad$=" " 'This sets one space #main.gb1,"stringwidth? onePad$ PadWidth" #main.gb1, "stringwidth? a$ FieldWidth" padNum=(width-FieldWidth)/PadWidth if padNum-int(padNum)>=.5 then padNum=padNum+1 padNum=int(padNum) if padNum>0 then a$=a$+space$(padNum) FormatStr$=a$ end function
There are 2 other ways, one of which I doubt if LB allows.
Change the stylebit to accept tabs then via API set the tabs in the control(doubt if LB accepts this)
Use API to query the length of the longest string (you have to know the font to do this). Divide the longest string by the size of the character returned to give you a character cell size, then pad your strings accordingly.