Export Formulas


Export formulas can be used to derive values from information stored in the current field or the current record being processed.  An export formula can contain an arithmetic, logical, or string expression, a BASIC function, and external subroutine call or almost any other type of BASIC statement.  Conceptually, an export formula provides the same functionality as I-type dictionaries without the need to create permanent dictionaries and the freedom to use standard BASIC syntax.

The following table lists the most common system variables used in an export formula:

Variable Name Description - Usage - Notes
FIELD$ This variable contains the information associated with the dictionary or attribute referenced in the Field ID prompt in internal format (e.g., may include dates and/or times in internal format and embedded values and sub-values marks).

Use this field to return information to the Kourier. 

FILENAME$ This variable contains the name of the export data file.
@ID Contains the item-ID of the current record being processed.
@RECORD Contains the contents of the current record in internal format.

Cautions

You should avoid using any BASIC statements or functions that will stop the processing of a BASIC subroutine.  Examples are STOP or ABORT.  Instead, you should return an appropriate value in the FIELD$ variable.

If you use equated constants to access attributes in a dynamic array (i.e., @RECORD<CUSTOMER.NAME>), you may not be able to use this coding technique in a Kourier formula depending on the configuration of the Kourier website (see ValidateRequest key).  By default, .Net will see @RECORD<CUSTOMER.NAME> as an attempt to do "cross site scripting".  You can trick .Net into allowing this coding technique by entering a space character after the < and before equated constant (e.g., @RECORD< CUSTOMER.NAME >).

Examples

Example 1

In this example, the data passed in FIELD$ may contain either a 5-digit (92021) or 9-digit (92021-1457) US postal code or a Canadian postal code (BN9 19R).  The following export formula will return the first 5 digits of a US postal code but will return all digits in a Canadian postal code.

IF LEN(FIELD$) > 5 THEN
  CHK.VAL = FIELD$[1,5]
  IF NUM(CHK.VAL) THEN
    FIELD$ = CHK.VAL
  END
END

Example 2

In this example, the data passed in FIELD$ may contain several values(MICHAELP]STEVENH]KATHYI).  The following export formula will return the last value (KATHYI).

NUM.VNOS = DCOUNT(FIELD$,@VM)
FIELD$ = FIELD$<1,NUM.VNOS>

Example 3

This example illustrates how to use the FIELD$ and FILENAME$ functions to extract the year from the file the is currently being processed. In the example below, the files names being processed consists of GL, GL-2008 and GL-2007.  In Line 002, if the year could not be found (as is the case if the current year's file named GL), then the year will be determined by the current system date. Line 003 returns the year using the standard FIELD$ variable.

  
   001:  YEAR = FIELD(FILENAME$,'-',2)
   002:  IF YEAR = '' THEN YEAR = OCONV(DATE(),'DY')
   003:  FIELD$ = YEAR

Example 4

This example illustrates how to create a simple loop when dealing with multi-value data. The FIELD$ variable will contain all system delimiters and it is up to the formula to loop through each value taking the appropriate action while maintaining the structure in FIELD$. In this example, the desired action is to make any non-numeric data values null while leaving all numeric data values alone.  

  
   001: 
NUM.VNOS = DCOUNT(FIELD$,@VM)
   002:  FOR I = 1 TO NUM.VNOS
   003:    DATA.VALUE = FIELD$<1,I>
   004:   
IF NOT(NUM(DATA.VALUE)) THEN FIELD$<1,I>=""
   005:  NEXT I

 


User Guide - Table of Contents