Intermec PM23c Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43, PM4 - Page 49
Specifying Array Dimensions Using DIM, Sorting Arrays
View all Intermec PM23c manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 49 highlights
Chapter 3 - Managing Files The first time an array is referred to, the number of subscripts in an array variable decides its number of dimensions. The number of elements in each dimension is restricted to four (numbered 0 to 3) by default. There are four commands that are particularly relevant for working with arrays: • DIM specifies the size of an array in regard of elements and dimensions. • SORT sorts the elements in a one-dimensional array in ascending or descending order. • SPLIT splits a string into an array. • CSUM returns the checksum for a string array. Specifying Array Dimensions Using DIM If more than four elements are needed, or to limit the size of the array, use a DIM statement to specify the number of dimensions as well as the number of elements in each dimension. This example shows how three 1-dimensional, 5-element arrays can be used to return 125 possible combinations of text strings: 10 DIM TYPE$(4),COLOUR$(4),SIZE$(4)20, TYPE$(0)="SHIRT" 30 TYPE$(1)="BLOUSE" 40 TYPE$(2)="TROUSERS" 50 TYPE$(3)="SKIRT" 60 TYPE$(4)="JACKET" 70 COLOUR$(0)="RED" 80 COLOUR$(1)= "GREEN" 90 COLOUR$(2)="BLUE" 100 COLOUR$(3)="RED" 110 COLOUR$(4)="WHITE" 120 SIZE$(0)= "EXTRA SMALL" 130 SIZE$(1)="SMALL" 140 SIZE$(2)="MEDIUM" 150 SIZE$(3)="LARGE" 160 SIZE$(4)="EXTRA LARGE" 170 INPUT"Select Type (0-4): ", A% 180 INPUT"Select Color (0-4): ", B% 190 INPUT"Select Size (0-4): ", C% 200 PRINT TYPE$(A%)+ ", "+COLOUR$(B%)+", "+SIZE$(C%) RUN Sorting Arrays The SORT statement sorts a one-dimensional array in ascending or descending order according to the ASCII values for the character in the Roman 8 character set. You can also choose between sorting the complete array or a specified interval. For string arrays, you can select by which character position the sorting is performed. This example shows how one numeric array is sorted in ascending order and one string array is sorted in descending order according to the fifth character in each element: 10 FOR Q%=0 TO 3 20 A$=STR$(Q%) 30 ARRAY%(Q%)=1000+Q%:ARRAY$(Q%)="No. "+A$ 40 NEXT Q% 50 SORT ARRAY%,0,3,1 Fingerprint Developer's Guide 37