hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 8, 2023 19:04:30 GMT -5
Hi again, I really like to use the Tab function for reports. I have a text window in which I want to create a report. Sadly, the Tab function doesn't want to work in my text window. The docs suggest that it only works in the mainwin or with the LPrint command. Does anybody know of a way to get it to work in a text window?
Thanks so much!!
|
|
|
Post by Rod on Nov 9, 2023 2:58:04 GMT -5
Tab() is for mainwin use. Few of us use the text window control. Most everybody that progresses beyond mainwin text display uses a graphicbox to display the text. Here you have pixel perfect positioning as well as color and font changes.
Choose a fixed width font when displaying tabular text. You might be able to print x spaces for your tab position, you just need to keep track of how many characters have been printed in the line.
Have I said this before? Have a look at printform.bas that is in the example files shipped with Liberty. Place x,y sets the tab/drawing point, \text then draws the text, object or graphic within your report. Then you also have great printing options with print size.
With fixed width font the place x is simply a multiple of font width, have a browse and play.
|
|
|
Post by tsh73 on Nov 9, 2023 4:21:07 GMT -5
There is user-written functions to pad string with spaces Might get handy by meerkat, here libertybasiccom.proboards.com/thread/1349/column-print-straight-line' ------------------------------------- ' Align fld$ to left right or center ' of a given width ' ------------------------------------- FUNCTION align$(fld$,width,lrc$) s = width - len(fld$) fld$ = left$(fld$,width) if s < 1 then align$ = fld$ else if lrc$ = "l" then align$ = fld$;space$(s) if lrc$ = "r" then align$ = space$(s);fld$ if lrc$ = "c" then align$ = space$(s / 2);fld$;space$(int(s / 2) + (s and 1)) end if END FUNCTION also padl$() / padr$() 'demo data Jack, "and", Jill, went, up, the, hill, "To fetch a pail of water.", "**" 'Short strings to be paddeed with spaces, long string to be cut by design.
print ">Source<";tab(30);">Pad right < > Pad left<" print "----------------------------------------------------------"
while 1 read a$ if a$="**" then exit while print ">";a$;"<";tab(30);">";padr$(a$,10);"< >";padl$(a$,10);"<"
wend
end
'functions '--------------------------------------------- 'adds spaces from the left until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padl$(a$,n) padl$ = left$(space$(n-len(a$))+a$,n) end function
'adds spaces from the right until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padr$(a$,n) padr$ = left$(a$+space$(n-len(a$)),n) end function
EDIT also lots of good stuff in this thread libertybasiccom.proboards.com/thread/623/looking-tips-formatting-printable-format
|
|
|
Post by Carl Gundel on Nov 9, 2023 9:20:26 GMT -5
There is also the using() function which can be used to pad out columns of data.
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 9, 2023 9:32:55 GMT -5
Thanks, guys! I've been doing a MUCH less sophisticated version of the suggestions above. I'll keep plugging away at it. I hope that Carl will note my plea for a future update...
|
|