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

gINT Rules Code Samples - 016

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 rule 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 to run on save in the POINT table. If you wish to be able to manually alter the sort values, you can use GRA007 which uses the same core code but will only run when executed from a menu.

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
  lSortOrderOrg As Long
  lGintRecID 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 GR016 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:
Initial public upload
*************************************************

INCLUDED FILES:
GR016.GLB:
  Add-Ins:   GR016 - Populates the GintPointSort field on save in the POINT table.

  gINT Rules code modules:
    GR016:  Main
            HoleSave
            HoleSortOrder

    GR016 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.
*************************************************