In this section: |
After entering SCAN, your current position is at the top of the database. FOCUS databases are not sequential databases with one data record following another; they consist of segments. Databases can have one or more segments. The segments may have multiple instances of data (a Monthly Inventory segment holding a date and a quantity might have six instances in June and twelve in December). The collected data instances for a particular set of related segments constitute a logical record in the database.
The concept of a current line pointer (common in most system editors) is replaced in SCAN by the concept of a current position in the database, which represents a set of data instances that form a connected path within the database. Instead of processing databases line-by-line, SCAN achieves a somewhat similar effect by approaching FOCUS databases in a top-down, left-to-right scanning sequence.
As we said, on entering SCAN, you are automatically positioned at the top of the database. You may move through the entire database, or specify a subset of fields to be edited (called a Show List or a subtree). Show Lists are created with the SHOW subcommand, and they contain the fields you name (plus any intermediate segments required by FOCUS to navigate from one specified field to another). An important concept when specifying Show Lists is that the data in the selected records must meet all of the criteria specified in the SHOW subcommand.
When you display the contents of logical records in SCAN, each data field is identified on the screen by either its alias or the field name, whichever is shorter (and non-blank). Given the following Master File, the SCAN operation proceeds as shown below.
FILENAME=CAR,SUFFIX=FOC SEGNAME=ORIGIN,SEGTYPE=S1 FIELDNAME=COUNTRY,COUNTRY,A10,FIELDTYPE=I,$ SEGNAME=COMP,SEGTYPE=S1,PARENT=ORIGIN FIELDNAME=CAR,CARS,A16,$ SEGNAME=CARREC,SEGTYPE=S1,PARENT=COMP FIELDNAME=MODEL,MODEL,A24,$ SEGNAME=BODY,SEGTYPE=S1,PARENT=CARREC FIELDNAME=BODYTYPE,TYPE,A12,$ FIELDNAME=SEATS,SEAT,I3,$ FIELDNAME=DEALER_COST,DCOST,D7,$ FIELDNAME=RETAIL_COST,RCOST,D7,$ FIELDNAME=SALES,UNITS,I6,$ SEGNAME=SPECS,SEGTYPE=U,PARENT=BODY FIELDNAME=LENGTH,LEN,D5,$ FIELDNAME=WIDTH,WIDTH,D5,$ FIELDNAME=HEIGHT,HEIGHT,D5,$ FIELDNAME=WEIGHT,WEIGHT,D6,$ FIELDNAME=WHEELBASE,BASE,D6.1,$ FIELDNAME=FUEL_CAP,FUEL,D6.1,$ FIELDNAME=BHP,POWER,D6,$ FIELDNAME=RPM,RPM,I5,$ FIELDNAME=MPG,MILES,D6,$ FIELDNAME=ACCEL,SECONDS,D6,$ SEGNAME=WARENT,SEGTYPE=S1,PARENT=COMP FIELDNAME=WARRANTY,WARR,A40,$ SEGNAME=EQUIP,SEGTYPE=S1,PARENT=COMP FIELDNAME=STANDARD,EQUIP,A40,$ scan file car SCAN: next COUNTRY=ENGLAND CAR=JAGUAR MODEL=V12X15E AUTO TYPE=CONVERTIBLE SEAT= 4 DCOST= 7427 RCOST= 8878 UNITS= 0 LEN= 190 WIDTH= 66 HEIGHT= 48 WEIGHT= 3435 BASE= 105.0 FUEL= 18.0 BHP= 241 RPM= 5750 MPG= 16 ACCEL= 7
Note: SCAN uses ALIAS names instead of field names when aliases are shorter. Use DISPLAY (or CRTFORM) to display complete field names. Fields WARRANTY and STANDARD are not shown, because they do not lie on the path.
Some SCAN subcommands require that you specify particular data fields for the operation. LOCATE, for example, requires that you supply the data value for the target field. Within SCAN you can identify a data field in one of three ways:
In this section: |
In SCAN sessions you can move from one segment instance directly to the next, jump from a parent segment instance to the first descendant field, or jump directly to a specific record of interest based on selection criteria specified in your request (for a description of these techniques, see Subcommand Summary).
The examples in this section use the CAR database, mentioned in What You See in SCAN Display Lines. Enter SCAN, and then the subcommand:
SHOW COUNTRY CAR MODEL
This restricts the Show List to the first three segments of the database, as shown by this diagram:
The following schematic diagram shows how the data used in the examples is placed within the FOCUS structure:
There are six subcommands you may use to change the current position:
LOCATE moves the current position to the next record that fulfills certain conditions. Often, you use LOCATE to find a record with a certain value. For example, if your current position is near the top of the database and you enter the subcommand
LOCATE CAR=MASERATI
the following record appears:
COUNTRY = ITALY CAR= MASERATI MODEL = DORA 2 DOOR
If you enter this subcommand again, SCAN searches for the next MASERATI record. Since there is only one MASERATI record, it moves the current position to the end of the database.
TLOCATE moves the current position to the first record in the database that fulfills certain conditions. Often, you use TLOCATE to find a record with a certain value. For example, if you enter the subcommand
TLOCATE CAR=ALFA ROMEO
the following record appears regardless of where the current position was in the database:
ITALY ALFA ROMEO 2000 GT VELOCE
The NEXT subcommand advances the current position to the next record. That is, it advances the current position one segment instance in the lowest segment in the Show List.
Suppose you entered SCAN to edit the CAR database and displayed the first record belonging to Italy by entering:
TLOCATE COUNTRY=ITALY
SCAN displays the following record:
ITALY ALFA ROMEO 2000 GT VELOCE
You then enter the subcommand NEXT:
NEXT
The lowest segment in this example is the MODEL segment. The MODEL instance in the record (2000 GT VELOCE) is the first of three instances descended from the car ALFA ROMEO. The NEXT subcommand moves the current position to the next instance in this chain, displaying the record:
ITALY ALFA ROMEO 2000 SPIDER VELOCE
If you enter the NEXT subcommand again, SCAN displays:
ITALY ALFA ROMEO 2000 4 DOOR BERLINA
Now you are at the end of the MODEL under the instance ALFA ROMEO. If you enter the NEXT subcommand again, it moves the current position to the first MODEL chain under the next instance in the segment CAR. The next CAR instance is MASERATI. The record displayed is:
ITALY MASERATI DORA 2 DOOR
MASERATI has only one child instance, and it is the last car under the instance ITALY. If you enter the NEXT subcommand again, it moves the current position to the first MODEL chain under the next instance in the segment COUNTRY. The record displayed is:
JAPAN DATSUN B210 2 DOOR AUTO
The JUMP subcommand moves the current position to the next segment instance in the segment you specify. The segment must have at least one field specified in the Show List.
Move the current position to the first record in the ITALY chain by entering:
TLOCATE COUNTRY=ITALY
This displays the record:
ITALY ALFA ROMEO 2000 GT VELOCE
Move the current position to the next car in the ITALY chain by entering:
JUMP CAR
Note: CAR is a field and not a segment name.
The following record appears:
ITALY MASERATI DORA 2 DOOR
Now return to the first record in the ITALY chain:
TLOCATE COUNTRY=ITALY
Jump to the next country in the database by entering:
JUMP COUNTRY
The following record appears:
JAPAN DATSUN B210 2 DOOR AUTO
The UP subcommand moves the current position to the first instance in the lowest segment in the Show List descended from the segment that you specify.
Move the current position to the model 2000 SPIDER VELOCE:
TLOCATE MODEL=2000 SPIDER VELOCE
This displays the following record:
ITALY ALFA ROMEO SPIDER VELOCE
Move the current position to the first ALFA ROMEO model by entering:
UP CAR
The following records appears:
ITALY ALFA ROMEO 2000 GT VELOCE
Move the current position to the Maserati car:
LOCATE CAR=MASERATI
Move the current position to the first car in the ITALY chain by entering:
UP COUNTRY
The following record appears:
ITALY ALFA ROMEO 2000 GT VELOCE
In this section: |
To view up to 64 fields, specify the SHOW subcommand. The SHOW subcommand does not list records lacking instances (short-path records).
To review field contents, use either the DISPLAY or TYPE subcommand.
At any point in a SCAN session, you may use the TYPE subcommand to display field names in a segment path (or those named in the SHOW subcommand, if one is in effect) and their contents for the current logical record (and/or several consecutive records).
DISPLAY produces a vertical list showing the full field names followed by the data values for the current logical record. DISPLAY allows you to select the fields to be displayed, and may include fields residing in segments picked up for the subtree but not actually named in the SHOW subcommand. This displays only the fields named in the SHOW subcommand if one is in effect.
When moving through a database in SCAN with NEXT, JUMP, LOCATE, or TLOCATE, you automatically get a display of the contents of the next record unless you suppress the display. You do this by putting a period after the move keyword. Therefore,
NEXT.
retrieves, but does not display, the next record.
It is usually preferable to suppress the displays when performing global operations that affect many records.
If some segments lack data, it means that some logical records have missing segment instances. FOCUS discards short-path records when constructing the Show List.
Consider a subset of the CAR database. The subset has three segments with one field per segment (COUNTRY, CAR, MODEL). If you name all three fields in a SHOW subcommand, logical records that lack data in any of the specified fields are not selected for the subtree (they are short-path records).
The following example illustrates this. To run this example, enter the following commands as shown below. What you enter is in lowercase; computer responses are in uppercase.
scan file car SCAN: show country car locate country=france COUNTRY=FRANCE CAR=PEUGEOT input car=renault SCAN: type COUNTRY=FRANCE CAR=RENAULT
The example is as follows. The CAR database contains this data:
Country | Car | Model |
---|---|---|
. |
|
|
. |
|
|
. |
|
|
France | Peugeot | 504 4 DOOR |
France | Renault |
|
Italy | Alfa Romeo | 2000 4 Door Berliner |
Note that the French car Renault has no instances in the MODEL segment. A SCAN operation that names all three segments drops the logical record for Renault because Renault is missing instances in the MODEL segment, as follows.
show country car model type 6 COUNTRY=ENGLAND CAR=JAGUAR MODEL=V12XKE AUTO COUNTRY=ENGLAND CAR=JAGUAR MODEL=XJ12L AUTO COUNTRY=ENGLAND CAR=JENSEN MODEL=INTERCEPTOR III COUNTRY=ENGLAND CAR=TRIUMPH MODEL=TR7 COUNTRY=FRANCE CAR=PEUGEOT MODEL=504 4 DOOR COUNTRY=ITALY CAR=ALFA ROMEO MODEL=2000 4 DOOR BERLINER
Note: In all of the examples in this section, user input is shown in lowercase; the FOCUS response is in uppercase.
To locate short-path records that will be dropped from a Show List, make a test pass through the database at the short-path level to see what is there before issuing the Show List for the edit operation. (This is highly recommended when adding new records to a database.) Thus, for the simple previous example, if you start by making a pass through the database selecting all records containing values for COUNTRY and CAR, you will find the Renault car.
show country car type 6 COUNTRY=ENGLAND CAR=JAGUAR COUNTRY=ENGLAND CAR=JENSEN COUNTRY=ENGLAND CAR=TRIUMPH COUNTRY=FRANCE CAR=PEUGEOT COUNTRY=FRANCE CAR=RENAULT COUNTRY=ITALY CAR=ALFA ROMEO
On the next pass, you add the MODEL segment and note that Renault disappears (due to the short-path). Knowing this, you refrain from adding a potential duplicate record for France and make a mental note to make another pass to update the short-path record with data for the MODEL segment.
Information Builders |