strBuildRecord

C Styled Script
Reference Manual

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using The CSS Executive
Language
Directives
System Library
String Library
   strAscii
   strBuildRecord
   strCenter
   strChange
   strChar
   strExport
   strFormatNumber
   strImport
   strIndexOf
   strIsInteger
   strIsNumber
   strLeftJustify
   strLength
   strLower
   strParseRecord
   strRemoveWords
   strRightJustify
   strSplitConnectString
   strSplitPath
   strSpread
   strStrip
   strStripExtension
   strStripLeading
   strStripTrailing
   strSubString
   strUpper
   strWordCount
   strWords
Regular Expression Lib.
File Library
Database Library
C API
C++ API
CSS Links
  
strBuildRecord(
  const mode,                 // file mode
  const &fmts[],              // field formats
  const &vals[],              // field values
 [const nullind]);            // null indicators in vals (default=false)

Creates an ASCII record. Typically used by database export scripts together with the dax and file libraries. These file modes are supported:

Mode Description
A,a ASCII fix
c Comma separated, text in single quotes
C Comma separated, text in double quotes
s Semicolon separated, text in single quotes
S Semicolon separated, text in double quotes
t Tab separated, text in single quotes
T Tab separated, text in double 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 text (ascii=left adjusted)
T text (ascii=right adjusted)
f fixtext (ascii=left adjusted)
F fixtext (ascii=right adjusted)
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

  • 3rd...nth word (fixtext only): text

The data to fill into 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 EUR',    // currency
    'n  8 2'       // price
  };
  ...
  var fvals = {
    '1122.344.102.00',
    'Leather football champion',
    112,
    12.95
  };
  fileWriteLine(expFile, strBuildRecord('s', dataLayout, fvals));
  fileWriteLine(expFile, strBuildRecord('a', dataLayout, fvals));
  ...

Will write this lines into the exportfile:

'1122.344.102.00';'Leather football champion';112;'EUR';12.95
1122.344.102.00     Leather football champion     000112EUR00012.95
 Copyright © IBK LandquartLast revised by Peter Koch, 24.02.00<< Back  Top  Next >>