Download User Manual

Transcript
>def amt,11,2,int,12
repeats 12 times}
>if amt(5) > 1000
>output outfile
{"amt" is an integer that
{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
as amt(1)}
{amt is 12J2}
{amount is 1J2 and is the same
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
selecting for May}
{amt is 12J2; same length and type}
{amount is 12J2; we are
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).
Relative Example Combining Subscripts and Offsets
If we have ten part numbers combined into one field (e.g., 10X12) we can still define
a single field that corresponds to the bin number of one of the parts.
94 • Suprtool Commands
Suprtool/Open 5.7