Download User Manual
Transcript
{"amt" is an integer that starts at the 11th byte of file}
>def amt,11,2,int
>if amt > 1000
{"amt" is now a field we can select on}
>output outfile
Absolute Example with Subcount
IMAGE and Suprtool allow fields to be repeated. In the next example, we define an
amount field that repeats twelve times (e.g., once for each month of the year). We
use a subscript when we want to refer to a specific month.
>def amt,11,2,int,12
>if amt(5) > 1000
>output outfile
{"amt" is an integer that repeats 12 times}
{we select on the 5th subfield}
Relative Examples
Use the simplest form of relative definitions to rename existing fields.
>def quantity,qty
>if quantity = "100 "
{"quantity" is a more readable name}
{selection on the new field}
The Define command copies the byteposition, sublength, and type to the new field,
but it does not copy the subcount. Define assumes that you want the first subfield:
>def amount,amt
>if amount > 1000
{amt is 12J2}
{amount is 1J2 and is the same as amt(1)}
Relative Example with Subcount
Because Suprtool defaults the subcount to one, you might want to specify an explicit
subcount when giving a new name to an existing field.
>def amount,amt,,,12
>if amount(5) > 1000
{amt is 12J2; same length and type}
{amount is 12J2; we are selecting for May}
Relative Example with Subscript
Use subscripts to define a new field that corresponds to a specific subfield.
>def may,amt(5)
>if may > 1000
{amt is 12J2}
{may is the fifth subfield}
Relative Example with Offset
Many applications define subfields within a larger character field. A common
example is a part-number where the first four digits are the warehouse location, the
second four digits are the bin number, and the last four digits are a serially assigned
number. Use the offset parameter to define new fields that are relative to the start of
the part number. The file INVOICES is a self-describing file.
>in invoices
>def warehouse,part,4
>def bin,part[5],4
>def release,part[9],4
>if bin = "100"
{part is 12 bytes}
{warehouse starts at part}
{bin is second four bytes}
{release is the last four bytes}
{use any field for selection}
Note that redefining the digits of a larger numeric field only works when the field is
a character field (type X, U, or A).
140 • Suprtool 5.7 for MPE
Suprtool Commands