Copyright 2008 by gINT Software. All rights reserved worldwide.
GRA007.TXT

gINT Rules Code Add-In menus Samples - 007

Requires gINT version 8 or later. gINT Logs cannot run gINT Rules but can access the code or the Add-Ins manager. gINT Logs Plus and gINT Professional have full access to both.

NOTE:  Code samples are provided free of charge and as-is.  gINT Software makes no claim or warranty as to the accuracy of the samples.  It is the responsibility of the user to ensure that the code performs as it should.  Comments, suggestions, and error reports are appreciated.

Description
===========
This Add-In populates the GintPointSort field with numbers reflecting the desired sort order for PointIDs. The GintPointSort field can be inserted into the POINT table using the Tables:Point Sort Field menu item in either Input or Data Design:Project Database. The program uses the values in this field to sort PointIDs in the POINT table and all PointID drop downs in Input. This field will also automatically sort your PointIDs at output time.

The code was set up as an add-in so that you could manually alter the order numbers, if you wished. If this procedure matches your desired algorithm, you can use GR016 which uses the same core code but is set up to run every time the POINT table is saved. This avoids having to remember to run the Add-In.

This add-in assumes that PointIDs are in the format:
  <Prefix><Number><Suffix>

All of the following will sort properly:
  B-1A
  CPT3
  62
  ABC
  87b

The first example above has all three segments, the second only has the first two segments, the third only the number segment, the fourth only the prefix, and the fifth has the second and third segments.

If your PointIDs are of a different structure, you can modify the code appropriately. Notes on how to do this follow the description below on how the algorithm works.

The algorithm for the add-in is as follows:
1. Walk through each of the PointIDs and parse out the different segments. Store the segments in a structure vector of the following configuration:
Private Type PointIDSegments
  sPointID As String
  sPrefix As String
  lNumber As Long
  sSuffix As String
  lRowOrg As Long
End Type

2. Sort the vector of segments by each segment, using the prefix as the primary sort element, the number as the secondary, and the suffix as the tertiary. Therefore, PointIDs without prefixes will sort first.

3. Walk through the data array and insert the segment vector index corresponding to the original PointID.

If your PointIDs conform to a different structure, merely change the PointIDSegments type definition in the Declarations section of the GRA007 module to reflect your segmentation and change the parsing and sorting code to work with your segments. The final walk through assignment code will be the same regardless of segmentation.

Revision History
================
30Jan2008:
There was a code error that caused the suffix portion of the PointID not to sort properly. This has been fixed.
------------------------------------------------

19Dec2007:
Code optimized by using a much more efficient sorting algorithm and a much faster method of assigning the GintPointSort values to the PointIDs.
------------------------------------------------

05Feb2007:
Initial public upload
*************************************************

INCLUDED FILES:
GRA007.GLB:
  Add-Ins:   GRA007 - Populates the GintPointSort field.

  gINT Rules code modules:
    GRA007:  Main
             GintPointSort

    GRA007 COMMON PROCEDURES:  InitFieldsFnB
*************************************************

INSTALLATION PROCEDURE:
Copy the files wherever you wish.  To see the gINT Rules Add-In and code module you must either merge the GLB into your library (Utilities:Lib Merge/Copy) or change to the included library (File:Change Library).
*************************************************

SPECIAL NOTES:
See the DESCRIPTION section above for detailed usage instructions.
*************************************************