Functions and Directives

Function SetCollationTable() Foundation

Query current and/or set user defined collation table for current thread

SetCollationTable( [<nCollation>], ;
                   [<aCollationTable>] ) --> aOldCollationTable
<nCollation> is the numeric identifier for the collation table to be selected. #define constants from the file COLLAT.CH must be used for this parameter.
<aCollationTable> is a one dimensional array with 256 elements. It must contain numeric values representing the weighing factors for single characters. The ASCII value of a character plus 1 defines the array element that contains the weighing factor for that character.

If SetCollationTable() is called without the argument <aCollationTable>, the function returns a one dimensional array holding the weighing factors of characters for the current thread's active collation. If <nCollation> is passed, a weighing table for the specified collation is returned.


The function SetCollationTable() retrieves a collation table that defines sorting and comparison rules for characters. When using COLLAT_USER for <nCollation>, the functions allows the configuration of a user defined collation table.

The collation table setting is thread local. When a new thread is created, it inherits the collation table setting of the thread in which it is created.

Note that only the COLLAT_USER collation table can be configured. All other collation tables are read-only.

// The example demonstrates how to activate 
// a user-defined collation table 

#include "" 

   LOCAL aCollation, n 

   aCollation := SetCollationTable( COLLAT_AMERICAN ) 

   ? "A" = "Z"                      // Result: .F. 

   n := aCollation[ Asc("Z") + 1 ] 

   aCollation[ Asc("A") + 1 ] := n 

   SetCollationTable( COLLAT_USER, aCollation ) 

   SetCollation( COLLAT_USER ) 

   ? "A" = "Z"                      // Result: .T. 

   SetCollation( COLLAT_AMERICAN ) 

   ? "A" = "Z"                      // Result: .F. 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.