Relation operators recognized are
EQ, NE, LT, LE,
GT, GE,
FROM ....TO
SELECTS IF WITHIN A RANGE
NOT-FROM ..... TO
SELECTS IF OUTSIDE THE GIVEN RANGE.
CONTAINS
LOOKS FOR A SPECIFIC VALUE.
OMITS
EXCLUDES A SPECIFIC VALUE.
NOTE
1. CONTAINS AND OMITS CAN ONLY BE USED WITH
ALPHA FIELDS.
2. FOR CONTAINS , IF THE VALUE IS FOUND THE RECORD
IS SELECTED.
3. FOR OMITS IF THE VALUE IS FOUND, IT IS BYPASSED.
TABLE FILE MAST
PRINT FIRST_NAME LAST_NAME
IF FIRST_NAME IS A$*
END
THIS SELECTS ONLY THOSE RECORDS WHOSE FIRST NAME
BEGIN WITH A .
THE $ IS USED TO MASK OUT THE OTHER CONTENTS
OF THE RECORD.
IT CAN BE USED ANY WHERE.
LIKE AB$$CD
ONLY THOSE THAT HAVE THEIR FIRST TWO CHARACTERS
AS AB AND LAST TWO AS CD WILL BE SELECTED.
EDITING OPTIONS ARE USED TO CHANGE THE MANNER IN WHICH A FIELD
IS DISPLAYED.
EG. SSN NUMBER STORED AS AN 9 DIGIT INTEGER.
IF HOWEVER, IT IS TO BE DISPLAYED IN THE REPORT WITH HYPHENS,
THEN
EID/A11 = EDIT(EMP_ID,999-999-999)
This creates a field (temporary) called EID, and EID is displayed
in the report as
123-456-789. The 9 in this case passes any value.
USED AS :
IF RECORDLIMIT EQ n ( N > 0).
Only the first n records will be read.
Used primarily for testing.
Selects only those records that meet all other screening conditions.
DEFINE FILE <filename> [ADD]
FIELDNAME1[/format] = expression;
FIELDNAME256[/format]=expression;
END
Where fieldname = 1 - 12 characters.
format =
Any Focus allowed format.
Expression = Any value compatible with the format.
Any logical expression.
Any arthetimic expression.
; ends the expression.
The temporary fields defined in the TABLE request are local only
for that request.
If it desired to carry it over to another TABLE request, then
ADD is used in the
TABLE request where the previous fields are needed.
They can also be explicitly cleared by the CLEAR verb (instead
of the ADD) ,
however CLEAR is the default.
Any number of temporary fields can be derived based
on an actual field in the MFD.
The only limitation is that the total DEFINEd fields in an TABLE
should not exceed 256.
The temporary fields are treated as real fields residing in the
database. Also they are treated
as appended to the bottom of the segment in which the real field
resides.
Ex.
DEFINE FILE EMPLOYEE
BIRTH_DATE/A6=EDIT(DOB,$$99$$) | EDIT(DOB,$$$$99)
| EDIT(DOB,99$$$$);
END
This defines a temporary field BIRTH_DATE.
The | symbol is for concatenation.
A single | is for weak concatenation, whereas ||
is for strong concatenation.
In case of strong concatenation, the trailing spaces are removed.
This above example can be used for changing the format
from YMD to MDY.
Temporary fields can also be DEFINEd in the MFD.
Rules
for defining temporary fields in the MFD.
· A DEFINE statement in the MFD can only refer
to a field in it's own segment. Hence it is best to place a DEFINEd
field next to the actual field from which
it is derived.
· A DEFINEd field in the MFD are
available whenever the data file is used, and it is treated
as just another stored field ,
so it cannot be CLEARed in the report request.
· A temporary field cannot be
used for cross referencing ( in JOINs ).
EDIT
EDIT changes the format from Alpha to Numeric and vice versa.
NEW_EID/A9=EDIT(EID);
If EID is defined in the MFD as
an I9 field NEW_EID is A9, and vice versa.
COMPUTE
TABLE FILE EMPLOYEE
SUM CSAL
COMPUTE BUDGET/A10=IF CSAL GE 110000 THEN
HIGH
ELSE IF CSAL GE
75000 THEN AVERAGE
ELSE LOW;
BY DEPT
END
DEPT
CURR_SAL BUDGET
-------
----------- ----------
SOFTWARE 5000
LOW
HARDWARE 80000
HIGH
TRG
120000
AVERAGE
Difference between COMPUTE and DEFINE
COMPUTE <exp> . The expression is executed only at the control
break,
if sortfield exists, else after all the records are retrieved.
TABLE FILE <filename>
...... report request......
ON TABLE HOLD [ AS NEW FILE NAME]
END
HOLD saves the data selected in the report request in a
sequential file.
Creates a MFD for the file.
? HOLD in the Focus prompt shows the HOLD FILE' s MFD.
The contents of the HOLD file can subsequently be used
in another report request.
Click here
to learn on date formats in FOCUS and their usage.