APPLICATION NOTE #122 SORT KEY IN XYWRITE III PLUS Rev. 01 The SK (Sort Key) setting has some capabilities that are not documented in the XyWrite III Plus Reference Guide. They are undocumented because we plan to revise the function significantly in a future release; you should therefore be conservative in your application of the SK settings described here. FORMAT OF THE SK SETTING The SORT command allows you to rearrange the entries in a file or in a defined block into alphabetical order. By default, the first 80 characters of each entry are used in the sort; numbers are sorted in decimal order; and duplicate entries are preserved. You can change one or all of these defaults by using the DEFAULT command to change the SK (Sort Key). The SK setting has the following form: default sk=n1,n2,n3 where n1 is a combination of one or more of the following numbers: 0 Sorts numerical entries in ASCII order (01, 10, 2, 3). 1 Sorts numerical entries in decimal order (01, 2, 3, 10). 2 Sorts entries in reverse order (Z to A and 9 to 0). 4 Deletes duplicate entries. 8 When set, means that n3 defines the number of tabs to skip rather than the number of characters. The default value for n1 is 1. To change n1, use one of the numbers listed above or add two or more of the numbers to create the sorting effect you want. For example, to sort numerical entries in decimal order and delete duplicate entries, set n1 to 5 (1+4); to sort numerical entries in decimal order, delete duplicate entries, and reverse the order of all entries, set n1 to 7 (1+4+2); to sort numerical entries in decimal order and skip tabs rather than characters, set n1 to 9 (1+8). The second value of the Sort Key (n2) defines the number of characters that XyWrite uses when sorting a list. The default size is 80, which means that the first 80 characters of each entry are sorted. If you have a very large file, you can reduce the amount of memory required to sort it by defining a smaller number of characters. Similarly, if you are creating a very large index, it is a good idea to define a smaller number of characters to be used for sorting. There is a limit to the size of the index file that XyWrite allows you to create. If you specify a smaller sort size, then you can include more entries in your index. The third value of the Sort Key (n3) defines the number of characters or tab columns that should be skipped before the sort starts. (The default is 0.) Suppose you have a list of entries that start with a 5-digit part number followed by a description. For example: 41233 Tennis racquet 41234 Baseball bat 41235 Football helmet If you want to sort this list by description rather than number, specify the number 6 as the third value of the Sort Key. The Sort program will skip over the 5-digit number and the tab, and start its evaluation with the 7th character. Alternatively, you could tell XyWrite to skip over the first tab column and sort the list using the first character of column 2. To do this, add 8 to the current value of n1, and then set n3 equal to the number of tab columns you want to skip (1 in this example). MORE INFORMATION For information on how to use the SORT command and how to set up a Sort Table, refer to the XyWrite III Plus Reference Guide.