| | | | strParseRecord(
const rec, // record to parse
const mode, // file mode (1)
const &fmts[], // field formats (2)
var &vals[], // fiels values returned
[const nullind]); // null indicators in vals (default=false)
Parses an ASCII record. Typically used by database import scripts together with the dax and file libraries. These file modes are supported: Mode | Description | A,a | ASCII fix | C,c | Comma separated | S, s | Semicolon separated | T,t | Tab separated, text in quotes | U,u | Tab separated, text unquoted | The field formats are records of 2 ... n words. The 1st word is a field type from this list: Format | Description | T,t | text | F,f | fixtext (ignored) | n | number with decimal point (leading sign) | N | number with decimal point (trailing sign) | x | number with fixed fraction digits (no decimal point, leading sign) | X | number with fixed fraction digits (no decimal point, trailing sign) | The next words are used as: - 2nd word = (maximum) width in chars
- 3rd word (numbers only) = # of fractional digits
The data extracted from the record are stored in vals. If nullind is true, the data is arranged in 2 colums (for example data[totFields][2]), where the first (index 0) holds the value and the second (index 1) is the NULL value indicator (true/1 = value is null, false/0 = value is not null). Example: ...
const dataLayout = {
't 20', // article #
't 30', // name
'n 6', // actual stock
'f 3', // currency, ignore
'n 8 2' // price
};
...
var fvals[4];
strParseRecord(
"'1122.344.102.00';'Leather football champion';112;'USD';12.95",
's', dataLayout, fvals)
);
// The result will be:
// fvals[0] = '1122.344.102.00';
// fvals[1] = 'Leather football champion';
// fvals[2] = 112;
// fvals[3] = 12.95;
...
|