THE REFORMAT SCREEN

Up to 100 lines of Reformats may be coded for
each format level, with a maximum of 1000
Reformat lines used for the entire format.
Pressing Ctl+F2 will switch the Format Generator
to the Reformat screen.  As each line is entered
by the operator, the program will check the
Syntax.  This will ensure that all lines are
entered correctly.  The Home, End, PgUp, and PgDn
keys may be used to move around in the Reformat
section.  When the Reformats have been completed,
press Alt+F10 to switch the Format Generator back
to the Heading or Attributes screen for that
level.

Up to 9 different reformats may be defined in the
Reformat section for each level.  Reformats are
performed or executed whenever you process a data
entry file.  If you code the REFORMAT parameter
while processing files with any value from 1 to
9, that set of reformats will be executed.  If
you leave the REFORMAT parameter blank, then the
data entry records will be placed as is in the
output file.

If you do not code a reformat for a particular
format level, data entry records produced by that
level will be placed as is in the output file.
That is, unless that format level was a continued
level, or if there is any pending data in the
output buffer that has not been recorded in the
output file from a previous record's WRITE
statement.

Note: If you code any levels for reformatting,
you must define unique Format or Record Codes for
those levels, or unpredictable results may
occur.

THE REFORMAT STATEMENTS

The first line of a reformat definition must be
an "**Rn xxxx" line.  This starts the definition
of a reformat.  "n" can be any number from 1 to
9.  "xxxx" is the output file's record length.
It can be from 1 to 16000.  You must use the same
record length for all levels that use the same
reformat number.  The reformat definition will
end with the next "**Rn" line, or when no more
reformat statements are found for the current
level.

Statements are keyed on each line with the
following syntax:

     statement[; statement ...]

Please keep the following coding rules in mind:

  -  Items in square brackets [] are optional.
  -  An ellipsis (...) indicates that an item can
     be repeated.
  -  Words in capital letters are keywords and
     must be entered as shown, except that they
     can be entered in any combination of upper
     and lower case letters.  The Format
     Generator will automatically convert letters
     to uppercase where needed.

There are 7 different reformat statements that
you can use to direct the program:

     CLEAR
     EXIT
     IF   THEN  [ELSE]
     JUMP
     RECADV
     SET
     WRITE

CLEAR variable[,variable ...]

This statement is used to zero or blank out any
variable.  See "Reformat Variables" later in this
section, for a list of the valid variables.

Example:  CLEAR *WF1,*WF2,EmpNr

EXIT

This statement terminates the reformats for the
current record.  The program goes ahead and reads
the next record in the data entry file as if
there were no more reformats to be executed.  You
normally use an EXIT statement to prevent the
reformat lines that follow from being performed
under certain conditions.

In the following example, the second line will
not be executed whenever the Employee Number is
zero:

     IF EmpNr=0 THEN EXIT
     SET *WF1=EmpNr

IF logical-expression THEN clause [ELSE clause]
     -or-
IF logical-expression THEN clause
ELSE clause

An IF statement is used to make a decision
regarding program flow based on the result of a
logical expression.  If the logical expression is
true, the THEN clause is executed.  THEN is
followed by one or more statements to be
executed.  If the logical expression is false,
the optional ELSE clause is executed.  The
optional ELSE clause may be placed on the current
line or on the following line and is followed by
one or more statements to be executed.  See
"Expressions" later in this section for more
information.

Please note that once an IF statement occurs on a
line, everything else on that line is part of the
IF statement.  IF statements can be nested,
however, any ELSE clause will be executed by
either IF statement that has a false logical
expression.  Nesting is limited only by the
length of the line.  For example:

     IF A=B THEN IF B=C THEN EXIT
     ELSE WRITE A,B,C

JUMP #-of-lines

This statement branches out of the normal program
sequence to a specified reformat line.  #-of-
lines is the # of lines to jump to.  It can be
negative as well as positive or even 0.

JUMP -1 will jump to the previous line.  JUMP 0
will jump to the beginning of the current line.
JUMP 1 will jump to the next line, and so on.

Using the JUMP statement you will be able to set
up loops in the reformat code.  You may also set
up code that is performed by more than one
process.  Then use a JUMP statement to get to the
code whenever it is supposed to be executed.

In the following example, the program will jump
to the fourth edit line (SET *WF1=CODE) if the
Code field is blank or greater than 200:

     Code: IF Code=' ' THEN JUMP 3
     IF Code>200 THEN JUMP 2
     ERROR 'Code is not blank or > 200'
     SET *WF1=Code

RECADV

This statement causes the program to write the
output buffer to the output file, and clear the
output buffer for the next output record.  The
output buffer is filled using the WRITE
statement, then written to the output file using
the RECADV statement.

In the following example, several records will be
written to the output file (based on a value that
is found in Work Field #1):

     IF *WF1<=0 THEN EXIT ELSE SET *WF1=*WF1-1
     WRITE *RECORD; RECADV; JUMP -1

SET variable=arithmetic-expression

The SET statement assigns the value of an
arithmetic expression to a variable.  See
"Expressions" later in this section for more
information.

Example:  SET *WF1=Qty*Price

Note: Numeric values that are set into Work
Fields will all be 15 digits long right adjusted.
You may use a substring of the Work Field to
output the correct number of characters into the
output file.

WRITE variable[,variable ...]

The WRITE statement places data into an output
buffer that is used to create records in the
output file.  Each variable named in the WRITE
statement is written to the output buffer
immediately following any data that is already in
the buffer.  After filling the output buffer with
data, a RECADV statement is used to actually
write the buffer into the output file.  If the
amount of data written to the output buffer
exceeds the record length of the output file, the
program will truncate the output record to fit
the record length.

Example:  WRITE *RECORD(1,50), '   '
          WRITE *WF1; RECADV

In this example, the first 50 bytes of the
current data entry record is written to the
output buffer, followed by 3 blanks.  The second
statement adds whatever is found in Work Field #1
to the end of the output buffer, then writes the
buffer to the output file.

REFORMAT VARIABLES

A list of the valid reformat variable names and
their descriptions follow:

field-id  Any field described on the display
          screen may be used as a variable.

'Constant'     Surround alphabetic constants with
               single quotes.

value     Numeric values may be positive or
          negative.  Place a minus sign prior to
          the number for negative values.  (Ex: -
          25)

*RECORD   The data entry record; the entire
          record or a substring may be tested or
          written to the output file.

*WFnn     Work Field; these fields may be used to
          store values temporarily, then tested
          or written to the output file.  "nn"
          may be 0-29.

SUBSTRING FUNCTION

A substring function produces a character string
that is a subset of an existing string.  It may
be used on any variable in an IF statement, or on
any variable to the right of the equal sign in a
SET statement, and on any variable in a WRITE
statement.  The format of the substring function
is:

variable-name(starting-position, length)

The substring function produces a substring from
the contents of the variable specified.  It
begins at the specified starting position (which
can be a variable name) and continues for the
length specified (which can be a variable name).
Neither the starting position nor the length can
be 0, negative, or larger than the original
field.

Example:  WRITE *RECORD(11,30)

In this example, the 30 bytes from byte 11
through 40 of the current record are written to
the output buffer.

EXPRESSIONS

There are two different types of expressions that
you may use.  Arithmetic expressions in SET
statements are used to generate arithmetic
results that will be placed in another variable.
Logical expressions in IF statements are used to
compare one variable to another.

ARITHMETIC EXPRESSIONS:

variable[operator variable ...]

An arithmetic expression can be a constant, a
numeric value, a variable, or a single value
obtained by combining constants, values, and
variables with operators.  Operations are
executed in the order they are coded on the
reformat line, from left to right.

Arithmetic Operators:

     +    Addition.
     -    Subtraction.
     *    Multiplication.
     /    Division.
     |    Concatenation.

All arithmetic results are truncated to whole
numbers.  Any fractional portion of a result is
dropped.  (Ex: 8/3 will yield 2).

Examples:

     SET *WF1=RgHrs+OtHrs*2.45
     SET *WF2='FILE'; SET *WF3=*WF2|'NAME'

In the first example, Work Field #1 is assigned
the result after summing the fields RgHrs and
OtHrs then multiplying the result by (2.45).

In the second example, Work Field #2 is assigned
the value 'FILE', then Work Field #3 is assigned
the value 'FILENAME' which is the combination of
two variables.

LOGICAL EXPRESSIONS:

variable operator variable[,variable ...]

Logical expressions will return a true or false
value to be used in making a decision.

The expression uses logical operators to compare
one variable to one or more other variables.  One
variable may be placed on the left side of a
logical expression, but multiple variables may be
placed on the right side of the expression,
separated with commas.  Each variable will be
compared to the first variable to see if the
expression is true.  Only one of the comparisons
are needed to make the entire expression true.
When you are using the operator <> (not equal),
all variables must be not equal to make the
expression true.

Logical Operators:

     =    Equal to.
     >    Greater than.
     <    Less than.
     >=   Greater than or equal.
     <=   Less than or equal.
     <>   Not equal to.

Examples:

     IF RgHrs>0 THEN WRITE *RECORD; RECADV
     IF 0<RgHrs,OtHrs THEN WRITE *RECORD
     IF Trade<>"EDP","MCH","NWM" THEN EXIT

In the first example, if the RgHrs field is
greater than 0, the record is written to the
output buffer and then to the output file.

In the second example, if either of the fields
RgHrs or OtHrs have a value greater than zero,
the record will be written to the output buffer.

In the third example, if the Trade field is not
any of the three values "EDP", "MCH", or "NWM",
the program will exit the reformats and go on to
the next data entry record.

MAXIMUM CAPACITIES

There are 10 different Storage areas that may be
used.

There are 9 different Field Total accumulators
that may be used.

A maximum of 100 Reformat lines may be defined in
each level.

A maximum of 1000 Reformat lines may be defined
in each format.

Up to 30 different Work Fields may be used in the
Edits for each format.
**************** end of section *****************
