     [NOTE:  If you plan on printing this file with a laser printer, I
suggest you do so by loading the file in your word processor and printing
it from there.  Otherwise the extensive use of line drawing, as well as
some of the other ASCII charcters, may not be all that easy to follow.  I
doubt you need to worry about that with a dot matrix printer.]



                TWO NEW LOOKUP FEATURES IN DATAPERFECT 2.3

                                   by

                      Sysop Ralph Alvy (71333,2075)
                         WordPerfect Users Forum

     This text file is my attempt to explain two features of DataPerfect,
new with version 2.3.  Both features involve how DataPerfect sorts and
displays records during lookups.  Part I covers the Data Link Subgroup
Lookup, which involves lookups performed on data-linked fields during
Create or Edit.  Part II covers Smart Lookups, which involves lookups
performed anywhere during Browse.  Neither topic is covered in the manual
shipped with the initial release of DataPerfect 2.3.

     I want to thank Ray Babbitt of WordPerfect Corporation for his help in
getting this file to you.  The information in Part I was derived mainly
from Ray's participation in the DataPerfect section of WordPerfect Users
Forum.  The information in the flow charts in Part II was derived mainly
from personal conversations with Ray, who patiently guided me during
frequent telephone sessions occurring on breaks in my "real job," as well
as via CompuServe EMail transmissions of prior versions of this material.



                  Part I:  The Data Link Subgroup Lookup
                  ======================================

     As with Smart Lookups, the DataPerfect 2.3 manual fails to mention the
notion of a Data Link Subgroup Lookup.  But, unlike Smart Lookups, the
notion of a Data Link Subgroup Lookup is at least touched on in the README
file found on the shipped diskettes (though it isn't referred to as the
Data Link Subgroup Lookup).  Here's the relevant README passage:

     DATAPERFECT:  Lookup                                              
         
     Performing a lookup on a data link while you are creating or
     editing a record will display records from the linked panel based
     upon the data link Key Field List.  If the first field in the Key
     Field List is the data link field, you will be able to see all
     records in the linked panel; otherwise, you will see only the
     records that match the fields of the Key Field List.

                                                       [README 02/01/93]

     Before DataPerfect 2.3, the data link's field list would simply
determine what fields would be pulled through the link after selecting the
record from the lookup during Create or Edit.  Now, with version 2.3, the
data link's field list also acts as a record filter for the lookup display
during Create or Edit.  This allows you to define a data link in such a way
that, during Create or Edit, a lookup performed on it will display a
defined subgroup of the linked panel's records.  Thus the name, Data Link
Subgroup Lookup.

     Here's the general rule.  With DataPerfect 2.3, if you perform a
lookup on a data-linked field during Create or Edit, the lookup will
display the linked panel's records filtered by all fields preceding the
data-linked field in the data link's field list (i.e., all the fields
preceding the data-linked field in the field list must match the
corresponding fields in the displayed record).

     So, if the data-linked field is the FIRST field in data link's field
list, no fields precede it in the data link's field list; so performing a
lookup on it during Create or Edit will effectively display an UNFILTERED
display of the linked panel's records (ALL the linked panel's records will
be displayed).  This effectively keeps things the way they were with
DataPerfect 2.2, because it fails to create a Data Link SUBGROUP Lookup.

     To create a Data Link Subgroup Lookup, the data-linked field must come
somewhere after the first field in the data link's field list.  If the
data-linked field is the SECOND field in the data link's field list, the
lookup will display the linked panel's records filtered by the FIRST field
in the field list.  If the data-linked field is the THIRD field in the
field list, the display will be filtered by the FIRST and SECOND fields in
the field list.  And so on.  Note, though, that if the data-linked field is
ABSENT from the field list, the lookup display will be EMPTY, displaying
the "No Data" message.

     Let's clarify this with some examples.  Suppose you run a local
software retail store, like Egghead.  And like Egghead, you sell more than
just software--people can also purchase books and peripherals, like printer
cables.  Let's say the categories of Software, Books, and Peripherals
exhausts everything you sell.

     Now, we'll place all those items for sale in the Item Panel, which
will have at least two fields: Item and Category, where the latter field
will be a U4 field that takes three possible values:  SOFT, BOOK, or PERI. 
We'll create two indexes in the Item Panel, one sorting by Item, the other
by Category.  Okay, that's pretty straightforward.

     Now the Transaction Panel.  There, we'll have at least the Category
and Item fields again, along with the usual Date and Amount fields.  On the
Item field we'll place a data link that ties the field to the Item Panel,
and have it land on the Category field.  The data link will use the
{Category, Item} index in the Item Panel, and have a field list consisting
of Category and Item, in that order.
     Here are the two panels, showing minimum configurations:


              Ŀ
                                                
                Category:                  
                                                
                    Item:  
                                                
              
                           Item Panel

  
     Ŀ
                                                         
      Date       Cat.    Item                   Amount   
               
                                                         
     
                        Transaction Panel


     Now, when the user enters the Transaction Panel and goes into Create,
he first fills in the Date and the Category (SOFT, BOOK or PERI).  Then he
cursors to the Item field and hits F8 or Up Arrow.  What DataPerfect does
at this point is where version 2.3 differs from 2.2.  With version 2.3, the
lookup performed on the Item field during Create or Edit will now show only
records matching the Category field to its left.  So if the user filled in
SOFT in the Category field, hitting Up Arrow on the Item field during
Create or Edit will display only a list Software records.  However,
DataPerfect 2.2 would have displayed ALL the Item Panel records.

     Again, if a lookup is performed on a data-linked field during Create
or Edit, DataPerfect first examines what field you're performing the lookup
on (in this case, the Item field of the Transactions Panel).  Then
DataPerfect looks to see if that field is on the data link's field list. 
If it isn't, you get a recordless lookup, displaying the "No Data" message. 
If it IS in the field list, the lookup display will be filtered by all
fields that precede it on the data link's field list (in this case, it was
filtered by the Category field).
                          Part II:  Smart Lookups
                          =======================

     Here I'll attempt to explain how DataPerfect chooses to sort and
display Browse mode lookups.  This algorithm is new with version 2.3, and
governs what has come to be called "Smart Lookups."  The flow charts I'll
present convey a logic that may seem terribly complicated, but I have faith
that after a few readings you'll find the beauty in it all.  Neither the
DataPerfect 2.3 manual nor any accompanying README file even mentions Smart
Lookups, so don't try to find any of this information there.

     A brief note, though, before getting into the flow charts.  In these
charts I speak of an index "activating" a field in this or that situation. 
This only applies to situations where you've entered a panel from a panel
link or from a menu using a keyword.  In such situations, DataPerfect
realizes you're really not all that interested in having the records in the
panel sorted by the beginning fields of the linking index (the fields that
correspond to the linking field list or menu keyword), because all the
records you're about to access in the panel have the same values in these
fields.  These fields are sometimes called the "common fields."

     For instance, if you just went from the Customer Panel to the
Transaction Panel, and did so with a panel link based on the Customer ID
field, you know all the records you're about to see in the Transaction
Panel are of that particular Customer.  So why bother including the
Customer ID in the sorting process of a lookup in the Transaction Panel? 
Consequently, DataPerfect takes the liberty of stripping the "common
fields" from the sorting process, sorting instead on the next field in the
index.  That's what I mean by the index "activating" that field: it
upgrades its status to primary sort field for that lookup event.

     So, using a different example, if we penetrate a panel link that has
as its field list, the Attorney ID field, then any index in the subpanel
that has Attorney ID as its first field will activate its second field.  In
this situation, the {Attorney ID, Client ID} index will activate the Client
ID field, and the {Attorney ID, Trial Date} index will activate the Trial
Date field; but the {Client ID, Attorney ID} index won't activate any field
at all in this situation.  Likewise, if we penetrate a panel link with the
{Attorney ID, Client ID} field list, then any subpanel index with Attorney
ID and Client ID as its first two fields (in that order) will activate its
third field.

     In the flow charts that follow, you'll see that DataPerfect now tries
very hard to find an index that activates the lookup field in the given
situation.  That is, it looks for an index that makes the lookup field the
primary sort, while keeping it consistent with the panel link's two
filters: the linking field list and any exception list tied to the linking
index.
            * * IF THE LOOKUP FIELD HAS A LOOKUP DEFINITION * *

ͻ       ͻ
 Did you enter the panel with a                                       
 panel link or a menu item with a NOĶ Lookup works as defined.    
 keyword?                                                             
ͼ       ͼ
                                          
                YES                        
                                          
ͻ       ͻ
 Does the lookup index share the                                      
 same exception list as the       YESĶ Lookup works as defined.    
 linking index and also activate                                      
 the lookup field?                                                    
ͼ       ͼ
                 
                NO                      
                 
ͻ       ͻ
                                          Lookup uses the first such  
 Is there an index that shares            index DP finds, starting    
 the same exception list as the           with index #1.  It will     
 linking index and also activates YESĶ display (and sort by) the    
 lookup field?                            lookup field, following it   
                                          with the rest of the lookup   
                                          field list.                 
ͼ       ͼ
                                              
                NO
                                              
ͻ       ͻ
                                          DP uses the index used by   
 Has a lookup already been                that lookup, displaying       
 performed in this panel during   YESĶ and sorting by) the field   
 this session?                            it activates.  That field   
                                          will then be followed by    
                                          the lookup field list.      
ͼ       ͼ 
                    
                NO                         
                 
ͻ
 DP uses the linking index,       
 displaying (and sorting by) the  
 field it activates.  That field  
 will then be followed by the     
 lookup field list.               
ͼ

       * * IF THE LOOKUP FIELD DOESN'T HAVE A LOOKUP DEFINITION * *

               ͻ
                Did you enter the panel with a panel    
                link or a menu item with a keyword?     
               ͼ
                                              
                        YES                   NO
                                              
ͻ ͻ
 Is there an index that shares     Does an index exist with the  
 the same exception list as the    lookup field as field one?    
 linking index, and also                                         
 activates the lookup field?                                     
ͼ ͼ
                                                                
 YES           NO                                NO              YES
                                                                
   ͻ   ͻ  
    Has a lookup already been     Has a lookup already been   
    performed in this panel       performed in this panel     
    during this session?          during this session?        
   ͼ   ͼ  
                                                              
        NO            YES                YES            NO       
                                                             
               ͻ              
                DP uses the index used by that               
                lookup, displaying its first                   
                field, followed by the lookup                  
                field.                                         
               ͼ              
                                                               
  ͻ ͻ  
   DP uses the linking index,    DP uses index #1,           
   displaying (and sorting by)   displaying (and sorting by) 
   the field it activates.       its first field.  That      
   That field will then be       field will then be followed 
   followed by the lookup        by the lookup field.        
   field.                                                    
  ͼ ͼ  
                                                                   
                 ͻ             
                  Lookup uses the first such                   
  Ķ index DP finds, starting with   
                   index #1.  It will display                
                   (and sort by) the lookup field. 
                   That field will then be         
                   followed by the fields that     
                   follow it in the index.         
                  ͼ
