Intermec PB51 Fingerprint Developer's Guide (old) - Page 55

Specifying Array Dimensions Using DIM, Sorting Arrays, Managing Files

Page 55 highlights

Chapter 3 - Managing Files • 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. In most cases, one- or two-dimensional arrays will be sufficient. 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)20TYPE$(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 Colour (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 60 SORT ARRAY$,0,3,-5 70 FOR I%=0 TO 3 80 PRINT ARRAY%(I%), ARRAY$(I%) 90 NEXT I% RUN The printer returns: Intermec Fingerprint Developer's Guide 39

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187

Chapter 3 — Managing Files
Intermec Fingerprint Developer’s Guide
39
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. In most cases, one- or two-dimensional arrays will be sufficient.
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)20TYPE$(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 Colour (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
60
SORT ARRAY$,0,3,-5
70
FOR I%=0 TO 3
80
PRINT ARRAY%(I%), ARRAY$(I%)
90
NEXT I%
RUN
The printer returns: