PV-WAVE Foundation > User Guide > Creating and Querying Tables > Formatting and Printing Tables
Formatting and Printing Tables
The simplest way to print a table is with the command:
PRINT, table_name
Unfortunately, the output from such a statement is not formatted in a readable, presentable manner.
Printing the Table without Column Titles
To print the phone_data table without column headings, simply enter:
WAVE> for i=0,N_ELEMENTS(phone_data)-1 do $ 
begin PRINT, phone_data(i)
This prints a readable, neatly organized representation of the table. The PRINT statement accesses each column of the table directly, using the basic structure notation, which is:
Variable_Name.Tag_Name
For more information on the relationship between structures and tables, see "Tables and Structures".
Printing the Table with Column Titles
To achieve a presentable format with column titles requires a slightly more complicated approach. For example, the following procedure prints a formatted version of the phone_data table to the screen and places titles above each column. The Format keyword in the PRINT statement uses FORTRAN-style format specifiers to format the rows. For detailed information on format specifiers, see the PV‑WAVE Reference.You can also refer to the description of the PRINT function in th PV‑WAVE Reference.
PRO pr_table, t_name
PRINT, ' DATE   TIME    DUR    INIT   EXT '+ $
  '  COST    AREA    NUMBER '
FOR i = 0, N_ELEMENTS(t_name) - 1 do begin
PRINT, Format = '(I6, 1X, I6, 3X, F5.2, 3X, ' + $ 
'A3, 3X, I3, 2X, F5.2, 3X, I3, 3X, A10)', $
t_name(i).DATE, t_name(i).TIME, t_name(i).DUR, $
t_name(i).INIT, t_name(i).EXT, t_name(i).COST, $
t_name(i).AREA, t_name(i).NUMBER
ENDFOR
END
After the procedure is compiled with .RUN, the following command prints the formatted phone_table to the screen:
WAVE> pr_table, phone_data
 
DATE
TIME
DUR
INIT
EXT
COST
AREA
NUMBER
901002
93200
21.40
TAC
311
5.78
215
2155554242
901002
94700
 1.05
BWD
358
0.0
303
5553869
901002
94700
17.44
EBH
320
4.71
214
2145559893
901002
94800
16.23
TDW
289
0.0
303
5555836
901002
94800
 1.31
RLD
248
0.35
617
6175551999
901003
91500
 2.53
DLH
332
0.68
614
6145555553
901003
91600
 2.33
JAT
000
0.0
303
555344
901003
91600
  .35
CCW
418
0.27
303
5555190
901003
91600
 1.53
SRB
379
0.41
212
2125556618
901003
91600
  .45
MLK
370
0.12
212
2125557956
901004
94700
  .80
JAT
000
0.0
303
555320
901004
94900
 1.93
SRB
379
0.52
818
8185552880
901004
95000
 3.77
DJC
331
1.02
512
5125551228
901004
95100
  .16
GWP
370
0.0
303
5551245
901004
95300
 1.36
JAT
000
0.0
303
555320