Prev Up Next Index
Go backward to 4.1 Array Descriptor Syntax
Go up to 4 Format Descriptions for Array Data
Go forward to 4.3 Examples

4.2 Handling Newlines

The convention of expecting a newline to follow each record of ASCII data becomes troublesome when dealing with array data, especially when expressed using format description notation that is intended for tabular data. It is the FreeForm ND convention that there is an implicit newline after the last variable of an ASCII format.

For example, these two format descriptions are equivalent:

ASCII_data "broken time --- BIP"  
year 1 2 uint8 0 
month 3 4 uint8 0 
day 5 6 uint8 0 
hour 7 8 uint8 0 
minute 9 10 uint8 0 
second 11 14 uint16 2 

dBASE_data "broken time --- BIP" 
year 1 2 uint8 0 
month 3 4 uint8 0 
day 5 6 uint8 0 
hour 7 8 uint8 0 
minute 9 10 uint8 0 
second 11 14 uint16 2 
EOL 15 16 constant 0  

However, the EOL variable shown here assumes that newlines are two bytes long, which is true only on a PC. FreeForm ND adjusts to this by assuming that ASCII data always has native newlines, and it updates the starting and ending position of EOL variables and subsequent variables accordingly.

The EOL variable is typically used to define a record layout that spans multiple lines. However, the EOL variable in combination with the dBASE format type can completely replace the ASCII format type.We recommend using the dBASE format type when describing ASCII arrays, to ensure that separation, if specified, takes into account the length of any newlines.

In this output format a newline separates each band of data, but it would be just as easy to omit the newlines entirely.

dBASE_input_data "broken time --- BIP" 
year 1 2 array["x" 1 to 10 sb 14] of uint8 0 
month 3 4 array["x" 1 to 10 sb 14] of uint8 0 
day 5 6 array["x" 1 to 10 sb 14] of uint8 0 
hour 7 8 array["x" 1 to 10 sb 14] of uint8 0 
minute 9 10 array["x" 1 to 10 sb 14] of uint8 0 
second 11 14 array["x" 1 to 10 sb 12] of uint16 2 
EOL 15 16 array["x" 1 to 10 sb 14] of constant 0 

dBASE_output_data "broken time - BSQ" 
year 1 2 array["x" 1 to 10] of uint8 0 
EOL 21 22 constant 0 
month 23 24 array["x" 1 to 10] of uint8 0 
EOL 43 44 constant 0 
day 45 46 array["x" 1 to 10] of uint8 0 
EOL 65 66 constant 0 
hour 67 68 array["x" 1 to 10] of uint8 0 
EOL 87 89 constant 0 
minute 90 91 array["x" 1 to 10] of uint8 0 
EOL 110 111 constant 0 
second 112 115 array["x" 1 to 10] of uint16 2 
EOL 132 133 constant 0  

NOTE: The separation size now takes into account the two-character PC

newline. To use this format description with a native ASCII file on UNIX platforms, it would be necessary to change the separation sizes of 12 and 14 to 11 and 13, respectively.


Tom Sgouros and James Gallagher, 2006-02-12

Prev Up Next