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

Splitting String Expressions, Calculating String Array Checksums, Checking

Page 56 highlights

Chapter 3 - Managing Files 1000 No. 3 1001 No. 2 1002 No. 1 1003 No. 0 Splitting String Expressions The SPLIT function splits a string expression into elements in an array and to return the number of elements. A specified character indicates where the string will be split. In this example a string expression is divided into six parts by the separator character "/" (ASCII 47 dec.) and arranged in a six-element array: 10 A$="ONE/TWO/THREE/FOUR/FIVE/SIX" 20 X$="ARRAY$" 30 DIM ARRAY$(6) 40 B%=SPLIT(A$,X$,47) 50 FOR C%=0 TO (B%-1) 60 PRINT ARRAY$(C%) 70 NEXT RUN The printer returns: ONE TWO THREE FOUR FIVE SIX Calculating String Array Checksums The checksum for string arrays can be calculated according to one of three different algorithms and returned using the CSUM statement. Note: Do not confuse CSUM with CHECKSUM. For help, see "Checking Transferred Files With CHECKSUM" on page 38. In this example, the checksum of a string array is calculated according both to the LRC (Logitudinal Redundancy Check) and the DRC (Diagonal Redundancy Check) algorithms: 10 FOR Q%=0 TO 3 20 A$=STR$(Q%) 30 ARRAY$(Q%)="Element No. "+A$ 40 NEXT 50 CSUM 1,ARRAY$,B%:PRINT "LRC checksum: ";B% 60 CSUM 2,ARRAY$,C%:PRINT "DRC checksum: ";C% RUN The printer returns: LRC checksum: 0 DRC checksum: 197 40 Intermec Fingerprint Developer's Guide

  • 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
40
Intermec Fingerprint Developer’s Guide
1000 No. 3
1001 No. 2
1002 No. 1
1003 No. 0
Splitting String Expressions
The SPLIT function splits a string expression into elements in an array and to return
the number of elements. A specified character indicates where the string will be split.
In this example a string expression is divided into six parts by the separator
character “/” (ASCII 47 dec.) and arranged in a six-element array:
10 A$=“ONE/TWO/THREE/FOUR/FIVE/SIX”
20 X$=“ARRAY$”
30
DIM ARRAY$(6)
40 B%=SPLIT(A$,X$,47)
50
FOR C%=0 TO (B%-1)
60
PRINT ARRAY$(C%)
70 NEXT
RUN
The printer returns:
ONE
TWO
THREE
FOUR
FIVE
SIX
Calculating String Array Checksums
The checksum for string arrays can be calculated according to one of three different
algorithms and returned using the CSUM statement.
In this example, the checksum of a string array is calculated according both to the
LRC (Logitudinal Redundancy Check) and the DRC (Diagonal Redundancy Check)
algorithms:
10
FOR Q%=0 TO 3
20 A$=STR$(Q%)
30
ARRAY$(Q%)=“Element No. ”+A$
40 NEXT
50
CSUM 1,ARRAY$,B%:PRINT “LRC checksum: ”;B%
60
CSUM 2,ARRAY$,C%:PRINT “DRC checksum: ”;C%
RUN
The printer returns:
LRC checksum: 0
DRC checksum: 197
Note:
Do not confuse CSUM with CHECKSUM. For help, see
“Checking
Transferred Files With CHECKSUM” on page 38.