vbdpss.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Article Q79149
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 How to Remember Current ISAM Record for Different Indexes - Q79149
 
 Using the SETINDEX statement in ISAM sets the current index for the
 specified table. It also sets the current record to the first record
 according to the ordering of that index. The version of ISAM included
 with the Professional Edition of Visual Basic for MS-DOS does not
 directly support maintaining the current record position for an index
 between uses of that index.
 
 This article describes three methods for remembering the current
 record for each index and restoring to that position after changing
 indexes to work around this limitation. A sample code fragment is
 also provided to illustrate each method.
 
 More Information:
 
 One way to remember the position of the current record according to an
 index is to count the record's relative position (from the beginning or
 end of the table) before changing to another index. This could be
 accomplished by using either MOVEPREVIOUS, with the beginning of the
 table as a reference point, or MOVENEXT, with the end of the table as
 a reference point. However, because this method is sequential, it is
 slow on larger data bases. Listed below is an example, using "One" and
 "Two" as arbitrary index names:
 
    See Method 1
 
 A temporary variable can be used to maintain the key value(s) for the
 current record for the desired index. These key values could be used
 in a SEEKEQ statement when the original index is returned to, making
 the record with those key values the current record. Assume the
 following type and index are used in the example below:
 
    See Method 2
 
 In some situations, you may want to know the physical position of a
 record within an index. This position could be used to display the
 relative position of the current record to the user of the database
 application, giving them an indication of "where they are" in their
 database file. Knowing the record's position also allows you to easily
 return to that record when indexes are changed. To do this, keep a
 position element in the type used to create the table as in the
 example below:
 
    See Method 3