******************************************************************************* * Sample conversion script file (T2D) for TXT2DBF * * * * - Blank lines and lines beginning with "*" are ignored * * * * - Each line defines a field in the destination database and an * * expression that retrieves the data from the source file. The * * expression may contain almost any Clipper 5 function to convert or * * manipulate the source data. Additional user-defined functions that * * are included and may be used: * * B_VALIMPDEC() - converts a string with implied decimal to numeric * * B_CDATE2DT() - converts a string date in many formats to a date * * B_NthAT() - returns the nTh occurance of a string * * * * - 3 standard variables are available for expressions: * * cRec - entire text record * * nCnt - text record counter * * ndbCnt - dBase records counter * * * * - Users may also create their own variables by initializing them in * * an expression. A user-defined variable will only exist within the * * expression it is created and will not be visible to other expressions. * * A variable initialization is considered an expression in itself. * * Multiple expressions may be used for a single field declaration as * * long as each expressions is seperated by commas. The result of the * * last expressions is the value which is actually stored in the database * * field. * * * - Field definition format is as follows: * * field_name | type | length | decimals | expression * * * * The pipes (|) are REQUIRED item separators. All items are required * * and must abide by Clipper 5 field definition rules. Any additional * * items are ignored and may be used for inline commenting. * * * * - Sample expressions: * * For the following examples, assume the record counter nCnt = 12 * * and the record cRec contains the following: * * 081292My dog has fleas 100 1FOO * * * * SUBSTR(cRec,7,16) ==> My dog has fleas (char) * * VAL(SUBSTR(cRec,24,3)) ==> 100 (num) * * IIF(SUBSTR(cRec,28,1)=='0',.F.,.T.) ==> .T. (log) * * SUBSTR(cRec,29,3)+'BAR' ==> FOOBAR (char) * * 'X' ==> X (char) * * nCnt ==> 12 (num) * * STR(nCnt,6) ==> 12 (char) * * B_VALIMPDEC(SUBSTR(cRec,1,6),2) ==> 812.92 (num) * * B_VALIMPDEC(SUBSTR(cRec,1,6),4) ==> 8.1292 (num) * * B_CDT2DATE(SUBSTR(cRec,1,6),'M2D2Y2') ==> 08/12/92 (date) * * B_CDT2DATE(SUBSTR(cRec,1,6),'D2M2Y2') ==> 12/08/92 (date) * * B_NthAT("0",cRec,3) ==> 26 (num) * * * * - Sample expressions with user-defined variables: * * nX:=1, nY:=2, nX+nY ==> 3 (num) * * cX:=SUBSTR(cRec,13,10), "My wife"+cX ==> My wife has fleas (char) * * * ******************************************************************************* * * * - NEW!!! * * Filter expressions may be included anywhere in the script to limit * * which records are actually added to the database. Filter identifiers * * begin with an exclamation point "!" and have the following format: * * !identifier | expression * * Up to 4096 filter expressions of each type may be included. * * * * Currently, only 2 different filter identifiers are available: * * !IGNORE - records that meet the expression are ignored * * !VALID - records that meet the expression are included * * * * - Sample filter expressions: * * !IGNORE | EMPTY(cRec) * * ==> ignores blank lines * * !IGNORE | "Page No"$cRec * * ==> ignores lines containing the text "Page No" * * !VALID | SUBSTR(cRec,1,1)=="X" * * ==> includes lines with "X" in position 1 * * * * - Things to consider if using filter expressions: * * 1) If NO !VALID expressions are supplied, ALL records are * * considered valid EXCEPT those meeting ANY !IGNORE expression. * * * * 2) If ANY !VALID expressions are supplied, ONLY records that * * meet AT LEAST ONE of the !VALID expressions are considered * * valid EXCEPT those meeting ANY !IGNORE expression. * * * ******************************************************************************* !VALID | VAL(SUBSTR(cRec,68,7)) > 0 | ONLY INCLUDE RECORDS ON ORDER !IGNORE | EMPTY(cRec) | IGNORE BLANK LINES !IGNORE | "SAMPLE REPORT"$cRec | IGNORE HEADER LINES !IGNORE | "Page:"$cRec | " " " !IGNORE | "Part No"$cRec | " " " !IGNORE | "-----"$cRec | " " " !IGNORE | "Totals:"$cRec | IGNORE FOOTER LINES !IGNORE | "====="$cRec | " " " !IGNORE | CHR(12)$cRec | IGNORE FORMFEED PART_NO |C| 7| 0| SUBSTR(cRec,2,8) DESC |C| 24| 0| SUBSTR(cRec,12,24) VEND_PART |C| 15| 0| SUBSTR(cRec,37,15) PRICE |N| 7| 2| VAL(SUBSTR(cRec,52,7)) ONHAND |N| 7| 0| VAL(SUBSTR(cRec,60,7)) ONORDER |N| 7| 0| VAL(SUBSTR(cRec,68,7)) JUNK |C| 20| 0| PADC("JUNK",20) *** EOF ***