You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
but the number of fields is unknown at compile time, so I was looking at how I could use an array and fill the columns with data
Code:
LOCAL col() AS FIELD
....
REDIM col(nField-1)
FOR Z = LBOUND(Col,1) TO UBOUND (col,1)
FIELD OutputLine$, FROM xxxx TO YYY AS Col(Z) <<< MATH NEEDED HERE
NEXT
Using the FROM..TO option you can FIELD part of the buffer each loop.
An array of dynamic strings or a filed array of the same? In that case Field variables could be of use for quickly separating the string into it's relevant parts. However, the positioning of the columns would still be an XPRINT SET POS task, since it seems apparent the length of the field variables is probably going to be less than the column widths. Is that correct?
Maybe you have already planned on that? Several ways to do the task, but the first case is that you would print a line of columns, although there are other types of data that want to be printed newspaper style. I think the example I cited earlier uses the latter. But for any who have not done this it's pretty simple to do either method.
Right at the moment, I plan on fixed font (like Courier) but the number of fields is unknown at compile time, so I was looking at how I could use an array and fill the columns with data.
Fields partition data in the circumstances listed in the help.
However, printing except with a fixed width font, will have no guarantee of columnar location just because data is fielded. Printing with a typical, proportional font using a Windows printer requires that the code set each column's horizontal position on the line. Once you set the position you could print using a FIELD variable if so desired. See XPRINT GET/SET POS functions.
Also you can see an example of columnar printing to screen and to Windows printer in PBWin90\Samples\Ddt\Graphic\boltcalc example (also with PBWin80 ... similar path).
I am trying to understand how "Fields" works. Or more specifically I would like to perhaps use it to print a file of columns 1 column may be 15 spaces wide, while the 2nd may be 30 spaces wide and yet a 3rd may only be 5 spaces wide.
Now if Fields is what I need so I can say
Field1 = "Some Command"
Field2 = "Some Comment"
Field3 = "Some Line Number"
Does anyone have a compilable example that does that? Or am I way off base how Fields are used?
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: