VA FileMan V. 22 Key and Index Tutorial
[<-- Introduction]   Lesson 1 Quiz Button   [Next Lesson -->]

Part 1 - Regular Indexes


Lesson 1. Create a Compound Index

In this lesson you will learn how to create a New-style Regular index. The index you will create is a compound index, one that contains as subscripts data from two different fields.

Note that the only way you could have created a two-field compound index prior to Version 22.0 was to create two MUMPS cross-references, one on each field in the index. With Version 22.0, you can define the compound index as a single New-style Regular index.

There are only two types of New-style cross-references, Regular and MUMPS, but they are much more powerful than their Traditional cross-reference counterparts. In fact, most of the indexes you previously had to define as Traditional MUMPS cross-references can, with Version 22.0, be defined as New-style Regular indexes.


Exercise 1.1.  Create Your Test File

The exercises in this tutorial make use of a simple test file that contains some sample data. In this exercise, you will use the A6AKIT routine to install your own personal copy of the test file. (See the Environment Setup page for information on how to obtain the A6AKIT set of routines.)

Note that in this tutorial, all references to the tutorial test file will be of file name ZZINDIVIDUAL, file number #662nnn, and global root ^DIZ(662nnn,; however, you should always work with your own personal copy of the test file.


Steps to Install the Test File

Step 1. Enter the following in programmer mode:
>D ^A6AKIT

I am going to set up a test file for the FileMan V. 22.0 Key and Index Tutorial.

The tutorial assumes the name of the test file is ZZINDIVIDUAL and the number of the test file is 662nnn, but you can choose any name and number you wish.

Step 2. Select a name for the test file. The default is ZZINDIVIDUAL, but you can choose a different name, if you wish. Then choose a file number and a global root (internal global reference) for the file.

Note: If the ZZINDIVIDUAL file already exists in the account in which you are taking this tutorial, don't assume you can use it. Someone else may be using that file. You should use your own personal copy of the test file, with its own unique file name and number.
Name of test file: ZZINDIVIDUAL// MY ZZINDIVIDUAL
  Are you adding 'MY ZZINDIVIDUAL' as a new FILE? No// Y  <Enter>  (Yes)
   FILE NUMBER: nnnn// nnnn

INTERNAL GLOBAL REFERENCE: ^DIZ(nnnn,// <Enter>

...HMMM, THIS MAY TAKE A FEW MOMENTS...
     A FreeText NAME Field (#.01) has been created.

File created: MY ZZINDIVIDUAL (#nnnn)
 Global root: ^DIZ(nnnn,

DONE!!
Note: If at the "Name of test file:" prompt you choose an existing file that looks like a Key and Index Tutorial test file, A6AKIT gives you the opportunity of deleting that file, and replacing it with the original version of the test file.

End of Exercise 1.1.



Exercise 1.2.  Create Your First Compound Index

In this exercise, you will create a New-style compound index based on the DOB and SSN fields in your ZZINDIVIDUAL test file.


Step 1. First, follow the menu path to the VA FileMan option Cross Reference a Field or File:
VA FileMan
   Utility Functions
      Cross Reference a Field or File

Step 2. Enter N for New at the prompt:
What type of cross-reference (Traditional or New)? Traditional//N

Step 3. Next, you are asked for the name of the file on which to create your cross-reference. Select the ZZINDIVIDUAL test file. Press Enter when prompted to select a subfile. Answer YES when asked if you want to create a new index on this file.
MODIFY WHAT FILE: ZZINDIVIDUAL// <Enter>
Select Subfile: <Enter>


There are no INDEX file cross-references defined on file #662nnn. Want to create a new Index for this file? No// YES

Step 4. Next, you are asked for the type of index you want to create. Press Enter to select the default index type REGULAR:
Type of index: REGULAR// <Enter>

Note: You can create two types of New-style cross-references: Regular and MUMPS. MUMPS cross-references are discussed in Part 2 of this tutorial.

Step 5. You are now asked if you want your index to be used for Lookup and Sorting, or Sorting Only. Press Enter to select Lookup and Sorting:
Want index to be used for Lookup & Sorting
or Sorting Only: LOOKUP & SORTING// <Enter>

Step 6. Press Enter at the prompt to accept "C" as the index name:
Index Name: C// <Enter>

Note: VA FileMan determines a default name for your index from your response to the question in Step 5 (the type of index).

Step 7. On the two-page ScreenMan form you can edit the properties of the index you are creating. The first page shows you the responses to the questions you have already answered (i.e., the results of Steps 1 through 6).

The only field you must fill in here is the Short Description. Tab to the Short Description field and enter the following:

   This is a regular index on the DOB and SSN fields.
Number: nnn EDIT AN INDEX Page 1 of 2

File:
Index Name:
662nnn
C
Root File: 662nnn
    Root Type: INDEX FILE
Short Description: This is a regular index on the DOB and SSN fields.
Description (wp): (empty)
Type: REGULAR
Activity:
Execution:
IR
FIELD
Use: LOOKUP & SORTING

Save     Exit     Next Page     Refresh
Enter a command or '^' followed by a caption to jump to a specific field.
COMMAND:                    Press <>PF1>H for help    Insert


Tips: <CTRL-U> is a toggle between the values: null, last edited, and the default of the ScreenMan field you are editing.

Press <PF1>Z ("zoom") at any field to open up an editing window at the bottom of the screen. This editing window is often easier to use than the usual scrolling window, especially when the value of the field is very long, as is the case with the Set Logic.

Step 8. Page 2 of the ScreenMan form is used to enter field data. Press <PF1><Down> or <PageDown> to go to page 2. Here you will specify the fields in your compound index.

In the "Order..." column, type in the number 1 and press Enter:
Number: nn EDIT AN INDEX Page 2 of 2

CROSS-REFERENCE VALUES:
Order... Subscr Type Length Field or Computed Expression
---------- ------- ----- -------- -------------------------------------
1 <Enter>
 Set Logic: Q
Kill Logic: Q
Whole Kill:
 Set Condition:
Kill Condition:

COMMAND:                    Press <>PF1>H for help    Insert

Step 9. Tab or arrow to the "CROSS-REFERENCE VALUES TYPE OF VALUE:" prompt, enter "F" for FIELD:

    CROSS-REFERENCE VALUES TYPE OF VALUE: F <Enter>

This will bring up the pop-up window "Field-Type Cross Reference Value", shown in the next step.
Note: Each cross-reference value can be a field or a computed value.

Step 10. At the "Field:" prompt in the pop-up window, enter DOB and press Enter:
Number: nn            EDIT AN INDEX              Page 2 of 2

CROSS-REFERENCE VALUES: Order... Subscr Type Length Field or Computed Expression -------- ------ ---- ------ ----------------------------

Field-Type Cross Reference Value
  Order Number: 1               Subscript Number:
         Field: DOB <Enter>                 File: 662nnn
    Field Name:

Maximum Length:                        Collation: forwards
 Lookup Prompt:
Transform for Storage:
Transform for Lookup:
Transform for Display:

COMMAND:                    Press <>PF1>H for help    Insert
At this point we have entered to first field (DOB) of our two field compound index.

Step 11. Press <PF1>E to close the pop-up window.
Note: VA FileMan has automatically built the Set and Kill logic for your new cross-reference based on the DOB cross-reference value you added to the index.

Step 12. Tab to the second row of the table, type the number 2 in the "Order…" column and press Enter.


Step 13. At the "CROSS-REFERENCE VALUES TYPE OF VALUE:" prompt, enter "F" for FIELD.


Step 14. At the "Field:" prompt on the pop-up window, enter SSN and press <PF1>E or <PF1>C to close the "Field-Type Cross Reference Value" pop-up window.

At this point we have entered the second and last field (SSN) of our two field compound index.

After you've added these two cross-reference values, page 2 should look like this:
Number: nnn EDIT AN INDEX Page 2 of 2

CROSS-REFERENCE VALUES:
Order... Subscr Type Length Field or Computed Expression
---------- ------- ----- -------- -------------------------------------
1
2
1
2
FIELD
FIELD

30
DOB (#.03)
SSN (#.02)
 Set Logic: S ^DIZ(662nnn,"C",X(1),$E(X(2),1,30),DA)=""
Kill Logic: K ^DIZ(662nnn,"C",X(1),$E(X(2),1,30),DA)
Whole Kill: K ^DIZ(662nnn,"C")
 Set Condition:
Kill Condition:

COMMAND:                    Press <>PF1>H for help    Insert
Your index contains two fields, DOB and SSN, each of which is used as a subscript in your index. Notice above that the Set and Kill Logic is automatically generated for you. X(1) refers to your DOB field, and X(2) refers to your SSN field. The subscripts 1 and 2 in the X array correspond to the Order numbers of the cross-reference values.


Step 15. Press <PF1>E to exit the ScreenMan form.


Step 16. Press Enter at the prompt "Do you want to build the index now? YES//". This will build the new "C" index on your file.
Note: If you haven't installed Patch DI*22.0*58, you will not see this prompt and the index will be built automatically. This patch was released October 18, 2000.

End of Exercise 1.2.


Congratulations! You have just created your first New-Style cross-reference!



Lesson 1 Quiz Button Select this link to test yourself on what you've learned in this lesson.

[<-- Previous Lesson]   [Intro] 1 [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]   [Next Lesson -->]

 


Reviewed/Updated: March 20, 2007