Announcement

Collapse
No announcement yet.

Field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Field

    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?
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    You mean the FIELD datatype? The fields collection/field object provided by ADO? The FIELD statement?

    Based in "printing columns" I think you may mean the FIELD statement, as in

    Code:
    FIELD OutputLine$,  15 AS ColumnOne$, 15 as ColumnTwo$ ....
    
       ColumnOne$ = "value1"
       ColumnTwo$ = "value 2"
      ...
       PRINT #hOut, OutputLine$
    Something like that?

    FILED difference from UDT? Column sizes are dynamic, not fixed at compile time.

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Cliff,

      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).
      Rick Angell

      Comment


      • #4
        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.
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          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.
          Rick Angell

          Comment


          • #6
            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.
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X