Re-order sample


What is it:  REORDER.FSL contains code which allows one to re-order records in a table without requiring the key value to be changed.  This may be useful if records need to be in some order not defined in a logical fashion (such as copied from a paper document).


Credit:  All* work done by Liz A. Woodhouse.  Feel free to send comments, suggestions, bug reports to Liz at: law@aros.net.  SEE END OF FILE FOR TERMS/DISCLAIMER/COPYRIGHT.

*Record highlight code taken from code written by Mark J. Pauker, MP Technologies.


Instructions/features:  In addition to the re-ordering code, this dialog includes samples of keeping the current record of the tableframe highlighted even when the tableframe loses focus, setting the color of certain objects to match the current Windows color scheme, and one method of incrementing a field value without the use of an autoincrement field.

Extract all files into the same directory and set :WORK: to that directory.  :WORK: is in code at least once.  Please use real aliases in implementation.

The re-order code relies on an 'Order' field in the table of type LongInt and with a unique, case-sensitive, maintained secondary index on that field.  For detail tables, you would want this secondary index to contain the master key field first and the Order field second.  The table uses this secondary index for sorting (Filter Tables dialog, Order By section) or for linking to the master.  This code has NOT been tested on a detail table, so other modifications may be required.

New lines inserted will be numbered according to where they're inserted.

When a line is deleted, numbers are resequenced to fill the gap (as necessary).

Use the arrows to move the current record up or down.

You may also type a new Order value to move a row.


Developer Notes: 

All code is commented.

1. Record highlight code is contained in the tableframe object's action, close, open, Const and Var events/methods.

2. Color setting code can be found in the page's and tableframe header's open methods.

3. The custom increment code can be found in cmIncrement - defined at the page level and implemented in the record object's action event in the DataInsertRecord trap.

4. The re-ordering code does some strange things with the display sometimes (and with departing the Order field or the record when the Order value has been changed by the user).  I haven't isolated the causes but suspect the record highlight code plays a part in the behavior.  Attempts to fix the display glitches tend to cause other less desirable glitches...  The arrows seem to work best for moving records.  [Suggestions for resolving the display glitches are encouraged...]

5. Re-ordering code is found in the following events/methods:

#Page2::cmAdjust
#Page2::Var
#Page2::open
#Record5::action
SequenceID.changeValue
#Button50::pushButton
#Button52::pushButton


Disclaimer/Terms: This information and associated files (REORDER.TXT, REORDER.FSL, REORDER(.DB, .FAM, .PX, .TV, .X02, .YO2), POAUTOINC(.DB, .FAM, .PX, .TV, .VAL)) and code are provided free of charge for any legal use or activity.  Illegal use is strictly prohibited and you are solely responsible for such actions.

All files, information, and other data provided with this text file are provided as-is with no implied or explicit warranties of any kind whatsoever.  While I make good-faith efforts to provide accurate information, you should always verify my findings before incorporating this information into your own projects and processes. You are strictly and solely responsible for your use of this information. If you damage your system, data, reputation, ability to work, mental stability, or any other material (or immaterial) asset while using the information in this file or the files included with it, it is your responsibility. Practice safe computing--make a backup!

This file and the files included with it may be redistributed freely under the following terms:  All files listed above must be included, this file (REORDER.TXT) may not be altered (include your own file if you wish to include additional information), you may not charge anyone any kind of fee (monetary or otherwise) for this file or its associated files, and credit must be given to the author of these files (leave the cmCredit() methods in place).

If you wish to make commercial use of this file or any of its associated files, please contact the author via the email address given at the start of this file.

Copyright 2000, Liz A. Woodhouse.  All rights reserved.
