forked from WNKLER/RefTypes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefStrings.bas
More file actions
666 lines (591 loc) · 19.2 KB
/
RefStrings.bas
File metadata and controls
666 lines (591 loc) · 19.2 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
Attribute VB_Name = "RefStrings"
Option Explicit
#Const SafeMode = True
#If Win64 Then
Public Const saSz = 32
#Else
Public Const saSz = 24
#End If
Public Type RefStr
Buf() As Integer
SA As SA1D
End Type
Private Const AChrTblSz& = 256
Private Const AChrCnt& = AChrTblSz
Private Const UChrTblSz& = 2340 '(1170 * 2)
Private Const UChrCnt& = UChrTblSz \ 2
Private UtoATbl(UChrCnt - 1) As Byte, AtoUTbl(AChrCnt - 1) As Integer
Private ULoTbl(UChrCnt - 1) As Integer, UUpTbl(UChrCnt - 1) As Integer
Private ALoTbl(AChrCnt - 1) As Byte, AUpTbl(AChrCnt - 1) As Byte
Private isCharTablesInit As Boolean
Function IntToStr(iStr() As Integer) As String
bMap1_SA.pData = VarPtr(iStr(1))
bMap1_SA.Count = UBound(iStr) * 2 '.Count * 2
IntToStr = bMap1
End Function
'ïîëó÷åíèå ìàññèâà integer (êîòîðûé áóäåò èñïîëüçîâàòü íà äåñêðèïòîð SA), çàìàïëåííîãî íà çàäàííóþ ÷àñòü ñòðîêè.
Function MidRef(SA As SA1D, sSrc As String, Optional ByVal Start& = 1, Optional ByVal Length&) As Integer()
Dim iArRes%(), lp As LongPtr, lnSrc&
If IsInitialized Then Else Initialize
lnSrc = Len(sSrc)
#If SafeMode Then
Dim maxLen&
' If lnSrc Then Else Exit Function
If Start > 0 Then Else GoTo errArgum
If Start > lnSrc Then Exit Function
If Length > 0 Then Else GoTo errArgum
maxLen = lnSrc - Start + 1
If Length > maxLen Then Length = maxLen
#End If
SA = iMap1_SA
SA.pData = StrPtr(sSrc) + (Start - 1) * 2
SA.Count = Length
PutPtr(VarPtr(lp) + ptrSz) = VarPtr(SA)
#If SafeMode Then
GoTo endFn
errArgum:
Err.Raise 5, , "invalid function argumenct"
endFn:
#End If
MidRef = iArRes
End Function
Function MidRefB(SA As SA1D, sSrc As String, ByVal Start&, Optional ByVal Length&) As Byte()
Dim bArRes() As Byte, lp As LongPtr, lnSrc&
If IsInitialized Then Else Initialize
lnSrc = LenB(sSrc)
#If SafeMode Then
Dim maxLen&
' If lnSrc Then Else Exit Function
If Start > 0 Then Else GoTo errArgum
If Start > lnSrc Then Exit Function
If Length > 0 Then Else GoTo errArgum
maxLen = lnSrc - Start + 1
If Length > maxLen Then Length = maxLen
#End If
SA = bMap1_SA
SA.pData = StrPtr(sSrc) + (Start - 1) * 2
SA.Count = Length
PutPtr(VarPtr(lp) + ptrSz) = VarPtr(SA)
#If SafeMode Then
GoTo endFn
errArgum:
Err.Raise 5, , "invalid function argumenct"
endFn:
#End If
MidRef = bArRes
End Function
Function MidRefInt(SA As SA1D, iSrc%(), ByVal Start&, Optional ByVal Length&) As Integer()
Dim iArRes%(), lp As LongPtr, lnSrc&
If IsInitialized Then Else Initialize
lnSrc = UBound(iSrc)
#If SafeMode Then
Dim maxLen&
' If lnSrc Then Else Exit Function
If Start > 0 Then
If Start > lnSrc Then Exit Function
Else: GoTo errArgum
End If
maxLen = lnSrc - Start + 1
Select Case Length
Case 0: Length = maxLen
Case Is > 0
If Length > maxLen Then Length = maxLen
Case Else: GoTo errArgum 'åñëè < 0
End Select
#End If
SA = iMap1_SA
SA.pData = VarPtr(iSrc(Start))
SA.Count = Length
PutPtr(VarPtr(lp) + ptrSz) = VarPtr(SA)
#If SafeMode Then
GoTo endFn
errArgum:
Err.Raise 5, , "invalid function argumenct"
endFn:
#End If
MidRefInt = iArRes
End Function
Function MidRefByt(SA As SA1D, bSrc%(), ByVal Start&, Optional ByVal Length&) As Byte()
Dim bArRes() As Byte, lp As LongPtr, ubSrc&
If IsInitialized Then Else Initialize
ubSrc = UBound(bSrc)
#If SafeMode Then
Dim maxLen&
' If ubSrc Then Else Exit Function
If Start > 0 Then
If Start > ubSrc Then Exit Function
Else: GoTo errArgum 'if < 0
End If
maxLen = ubSrc - Start + 1
Select Case Length
Case 0: Length = maxLen
Case Is > 0
If Length > maxLen Then Length = maxLen
Case Else: GoTo errArgum 'if < 0
End Select
#End If
SA = iMap1_SA
SA.pData = VarPtr(bSrc(Start))
SA.Count = Length
PutPtr(VarPtr(lp) + ptrSz) = VarPtr(SA)
#If SafeMode Then
GoTo endFn
errArgum:
Err.Raise 5, , "invalid function argumenct"
endFn:
#End If
MidRefByt = bArRes
End Function
Function GetStrMap(SA As SA1D, sInp$) As Integer()
Dim iMap%(), lp As LongPtr, lnInp&
If IsInitialized Then Else Initialize
lnInp = Len(sInp)
' If lnInp Then Else Exit Function
SA = iMap1_SA
SA.pData = StrPtr(sInp)
SA.Count = lnInp
lpRef_SA.pData = VarPtr(lp) + ptrSz
lpRef(0) = VarPtr(SA)
GetStrMap = iMap
End Function
Function GetStrMapB(SA As SA1D, sInp$) As Byte()
Dim bMap() As Byte, lp As LongPtr, lnInp&
If IsInitialized Then Else Initialize
lnInp = LenB(sInp)
' If lnInp Then Else Exit Function
SA = bMap1_SA
SA.pData = StrPtr(sInp)
SA.Count = lnInp
lpRef_SA.pData = VarPtr(lp) + ptrSz
lpRef(0) = VarPtr(SA)
GetStrMapB = bMap
End Function
Private Sub InitCharTables()
Dim i&, sChars$, sTmp$
If Not isCharTablesInit Then Else Exit Sub
If IsInitialized Then Else Initialize
Dim iChars%(UChrCnt - 1)
For i = 0 To UChrCnt - 1
iChars(i) = i
Next
bMap1_SA.pData = VarPtr(iChars(0))
bMap1_SA.Count = UChrTblSz
sChars = bMap1
sTmp = ToAnsi(sChars)
MemLSet VarPtr(UtoATbl(0)), StrPtr(sTmp), UChrCnt
sTmp = LCase$(sChars)
MemLSet VarPtr(ULoTbl(0)), StrPtr(sTmp), UChrTblSz
sTmp = UCase$(sChars)
MemLSet VarPtr(UUpTbl(0)), StrPtr(sTmp), UChrTblSz
Dim bAnsi(AChrCnt - 1) As Byte
For i = 0 To AChrCnt - 1
bAnsi(i) = i
Next
bMap1_SA.pData = VarPtr(bAnsi(0))
bMap1_SA.Count = AChrTblSz
sChars = bMap1
sChars = FromAnsi(sChars)
MemLSet VarPtr(AtoUTbl(0)), StrPtr(sChars), AChrCnt * 2
sTmp = ToAnsi(LCase$(sChars))
MemLSet VarPtr(ALoTbl(0)), StrPtr(sTmp), AChrTblSz
sTmp = ToAnsi(UCase$(sChars))
MemLSet VarPtr(AUpTbl(0)), StrPtr(sTmp), AChrTblSz
isCharTablesInit = True
End Sub
Function IntToAnsi(IntStrInp%()) As Byte()
Dim i&, strlen&, BytStrOut() As Byte
If isCharTablesInit Then Else InitCharTables
strlen = UBound(IntStrInp)
ReDim BytStrOut(1 To strlen)
For i = 1 To strlen
BytStrOut(i) = UtoATbl(IntStrInp(i))
Next
IntToAnsi = BytStrOut
End Function
Function IntFromAnsi(BytStrInp() As Byte) As Integer()
Dim i&, j&, Ub&, lb&, strlen&, IntStrOut() As Integer
If isCharTablesInit Then Else InitCharTables
lb = LBound(BytStrInp)
Ub = UBound(BytStrInp)
ReDim IntStrOut(1 To Ub - lb + 1)
For i = lb To Ub
j = j + 1
IntStrOut(j) = AtoUTbl(BytStrInp(i))
Next
IntFromAnsi = IntStrOut
End Function
Function StrConvInt(IntStrInp() As Integer, ByVal Conv As VbStrConv) As Integer()
Dim i&, strlen&, IntStrOut%()
If isCharTablesInit Then Else InitCharTables
strlen = UBound(IntStrInp)
ReDim IntStrOut(1 To strlen)
Select Case Conv
Case vbUpperCase
For i = 1 To strlen
IntStrOut(i) = UUpTbl(IntStrInp(i))
Next
Case vbLowerCase
For i = 1 To strlen
IntStrOut(i) = ULoTbl(IntStrInp(i))
Next
Case vbProperCase
Dim sTmp$, strSz&
strSz = strlen * 2
bMap2_SA.pData = VarPtr(IntStrInp(1))
bMap2_SA.Count = strSz
sTmp = bMap2()
sTmp = StrConv(sTmp, vbProperCase)
MemLSet VarPtr(IntStrOut(1)), StrPtr(sTmp), strSz
End Select
StrConvInt = IntStrOut
End Function
'êîíâåðòàöèÿ áàéòîâîãî ìàññèâà áåç èçìåíåíèÿ åãî ðàçìåðà (UCase, LCase)
Function StrConvByt(BytStrInp() As Byte, ByVal Conv As VbStrConv) As Byte()
Dim i&, BytStrOut() As Byte
Dim lb&, Ub&, j&
If isCharTablesInit Then Else InitCharTables
lb = LBound(BytStrInp)
Ub = UBound(BytStrInp)
ReDim BytStrOut(1 To Ub - lb + 1)
Select Case Conv
Case vbUpperCase
For i = lb To Ub
j = j + 1
BytStrOut(j) = AUpTbl(BytStrInp(i))
Next
Case vbLowerCase
For i = lb To Ub
j = j + 1
BytStrOut(j) = ALoTbl(BytStrInp(i))
Next
Case vbProperCase
'elrjeojf;lkfjas;lfkjl
End Select
StrConvByt = BytStrOut
End Function
Function UCaseInt(IntStrInp() As Integer) As Integer()
Dim i&, strlen&, arRes() As Integer
If isCharTablesInit Then Else InitCharTables
strlen = UBound(IntStrInp)
ReDim arRes(1 To strlen)
For i = 1 To strlen
arRes(j) = UUpTbl(IntStrInp(i))
Next
UCaseInt = arRes
End Function
Sub UCaseBufInt(IntStr() As Integer)
Dim i&
If isCharTablesInit Then Else InitCharTables
For i = 1 To UBound(IntStr)
IntStr(i) = UUpTbl(IntStr(i))
Next
End Sub
Function LCaseInt(IntStrInp() As Integer) As Integer()
Dim i&, strlen&, arRes() As Integer
If isCharTablesInit Then Else InitCharTables
strlen = UBound(IntStrInp)
ReDim arRes(1 To strlen)
For i = 1 To strlen
arRes(j) = ULoTbl(IntStrInp(i))
Next
LCaseInt = arRes
End Function
Sub LCaseBufInt(IntStr() As Integer)
Dim i&
If isCharTablesInit Then Else InitCharTables
For i = 1 To UBound(IntStr)
IntStr(i) = ULoTbl(IntStr(i))
Next
End Sub
'Àíàëîã UCase äëÿ áàéòîâîãî ìàññèâà
Function UCaseByt(BytStrInp() As Byte) As Byte()
Dim i&, lb&, Ub&, j&, arRes() As Byte
If isCharTablesInit Then Else InitCharTables
lb = LBound(BytStrInp): Ub = UBound(BytStrInp)
ReDim arRes(1 To Ub - lb + 1)
For i = lb To Ub
j = j + 1
arRes(j) = AUpTbl(BytStrInp(i))
Next
UCaseByt = arRes
End Function
Sub UCaseBufByt(BytStr() As Byte)
Dim i&
If isCharTablesInit Then Else InitCharTables
For i = LBound(BytStr) To UBound(BytStr)
BytStr(i) = AUpTbl(BytStr(i))
Next
End Sub
Function LCaseByt(BytStrInp() As Byte) As Byte()
Dim i&, lb&, Ub&, j&, arRes() As Byte
If isCharTablesInit Then Else InitCharTables
lb = LBound(BytStrInp): Ub = UBound(BytStrInp)
ReDim arRes(1 To Ub - lb + 1)
For i = lb To Ub
j = j + 1
arRes(j) = ALoTbl(BytStrInp(i))
Next
LCaseByt = arRes
End Function
Sub LCaseBufByt(BytStr() As Byte)
Dim i&
If isCharTablesInit Then Else InitCharTables
For i = LBound(BytStr) To UBound(BytStr)
BytStr(i) = ALoTbl(BytStr(i))
Next
End Sub
Sub UCaseBuf(sBuf As String)
Dim i&, pBuf As LongPtr, strlen&
pBuf = StrPtr(sBuf)
If pBuf Then Else Exit Sub
If isCharTablesInit Then Else InitCharTables
strlen = Len(sBuf)
iMap2_SA.pData = StrPtr(sBuf)
iMap2_SA.Count = strlen
For i = 1 To strlen
iMap2(i) = UUpTbl(iMap2(i))
Next
End Sub
Sub LCaseBuf(sBuf As String)
Dim i&, pBuf As LongPtr, strlen&
pBuf = StrPtr(sBuf)
If pBuf Then Else Exit Sub
If isCharTablesInit Then Else InitCharTables
strlen = Len(sBuf)
iMap2_SA.pData = StrPtr(sBuf)
iMap2_SA.Count = strlen
For i = 1 To strlen
iMap2(i) = ULoTbl(iMap2(i))
Next
End Sub
Private Function ToAnsi(sInp$) As String
MovePtr VarPtr(ToAnsi), VarPtr(StrConv(sInp, vbFromUnicode)) + 8
End Function
Private Function FromAnsi(sInp$) As String
MovePtr VarPtr(FromAnsi), VarPtr(StrConv(sInp, vbUnicode)) + 8
End Function
'àíàëîã InStr$() ñ äîïîëíèòåëíûì ïàðàìåòðîì endFind, ÷òîáû óêàçûâàòü ïîçèöèþ îêîí÷àíèÿ ïîèñêà.
Function InStrEndInt(isCheck%(), isMatch%(), Optional ByVal lStart As Long = 1, _
Optional ByVal Compare As VbCompareMethod, Optional ByVal endFind As Long = -1) As Long
If IsInitialized Then Else Initialize
lpRef_SA.pData = VarPtr(lStart) - ptrSz * 2
If lpRef(0) Then Else Exit Function 'check initialization isCheck
lpRef_SA.pData = lpRef_SA.pData + ptrSz
If lpRef(0) Then Else Exit Function 'check initialization isMatch
If Compare = vbBinaryCompare Then
iMap1_SA.pData = VarPtr(isCheck(1))
iMap2_SA.pData = VarPtr(isMatch(1))
Else
Dim isTmp1%(), isTmp2%()
isTmp1 = UCaseInt(isCheck)
isTmp2 = UCaseInt(isMatch)
iMap1_SA.pData = VarPtr(isTmp1(1))
iMap2_SA.pData = VarPtr(isTmp2(1))
End If
Dim i&, j&, k&, lenCheck&, lenMatch&, iMatch%
lenCheck = UBound(isCheck)
lenMatch = UBound(isMatch)
iMap1_SA.Count = lenCheck
iMap2_SA.Count = lenMatch
If endFind = -1 Then endFind = lenCheck
iMatch = iMap2(1) 'v2
For i = lStart To endFind - lenMatch + 1
If iMap1(i) <> iMatch Then
Else
k = i
For j = 2 To lenMatch
k = k + 1
If iMap1(k) = iMap2(j) Then Else GoTo skip
Next
InStrEndInt = i: Exit Function
End If
skip:
Next
End Function
'ïîèñê áàéòîâîãî ìàññèâà â áàéòîâîì ìàññèâå
Function InStrEndByt(bsCheck() As Byte, bsMatch() As Byte, Optional ByVal Start As Long = 1, _
Optional ByVal Compare As VbCompareMethod, Optional ByVal endFind As Long = -1) As Long
Dim i&, j&, k&, lenCheck&, lenMatch&, bMatch As Byte, LbCheck&, UbCheck&, LbMatch&, UbMatch&
If IsInitialized Then Else Initialize
lpRef_SA.pData = VarPtr(Start) - ptrSz * 2
If lpRef(0) Then Else Exit Function 'check initialization bsCheck
lpRef_SA.pData = lpRef_SA.pData + ptrSz
If lpRef(0) Then Else Exit Function 'check initialization bsMatch
LbCheck = LBound(bsCheck): UbCheck = UBound(bsCheck)
LbMatch = LBound(bsMatch): UbMatch = UBound(bsMatch)
If Compare = vbBinaryCompare Then
bMap1_SA.pData = VarPtr(bsCheck(LbCheck))
bMap2_SA.pData = VarPtr(bsMatch(LbMatch))
Else
Dim bsTmp1() As Byte, bsTmp2() As Byte
bsTmp1 = UCaseByt(bsCheck)
bsTmp2 = UCaseByt(bsMatch)
bMap1_SA.pData = VarPtr(bsTmp1(1))
bMap2_SA.pData = VarPtr(bsTmp2(1))
End If
lenCheck = UbCheck - LbCheck + 1
lenMatch = UbMatch - LbMatch + 1
bMap1_SA.Count = lenCheck
bMap2_SA.Count = lenMatch
If endFind = -1 Then endFind = lenCheck
bMatch = bMap2(1) 'v2
For i = Start To endFind - lenMatch + 1
If bMap1(i) <> bMatch Then
Else
k = i
For j = 2 To lenMatch
k = k + 1
If bMap1(k) = bMap2(j) Then Else GoTo skip
Next
InStrEndByt = i: Exit Function
End If
skip:
Next
End Function
'ïîèñê ñ êîíöà â ìàññèâå Integer
Function InStrEndRevInt(isCheck%(), isMatch%(), Optional ByVal Start As Long = -1, _
Optional ByVal Compare As VbCompareMethod, Optional ByVal endFind As Long = 1) As Long
Dim i&, j&, k&, lenCheck&, lenMatch&, iMatch%
If IsInitialized Then Else Initialize
If Compare = vbBinaryCompare Then
iMap1_SA.pData = VarPtr(isCheck(1))
iMap2_SA.pData = VarPtr(isMatch(1))
Else
Dim isTmp1%(), isTmp2%()
isTmp1 = UCaseInt(isCheck)
isTmp2 = UCaseInt(isMatch)
iMap1_SA.pData = VarPtr(isTmp1(1))
iMap2_SA.pData = VarPtr(isTmp2(1))
End If
lenCheck = UBound(isCheck)
lenMatch = UBound(isMatch)
iMap1_SA.Count = lenCheck
iMap2_SA.Count = lenMatch
If Start = -1 Then Start = lenCheck
iMatch = iMap2(1) 'v2
For i = Start - lenMatch + 1 To endFind Step -1
If iMap1(i) <> iMatch Then
Else
k = i
For j = 2 To lenMatch
k = k + 1
If iMap1(k) = iMap2(j) Then Else GoTo skip
Next
InStrEndRevInt = i: Exit Function
End If
skip:
Next
End Function
'ïîèñê ñ êîíöà â áàéòîâîì ìàññèâå
Function InStrEndRevByt(bsCheck() As Byte, bsMatch() As Byte, Optional ByVal Start As Long = -1, _
Optional ByVal Compare As VbCompareMethod, Optional ByVal endFind As Long = 1) As Long
Dim i&, j&, k&, lenCheck&, lenMatch&, bMatch As Byte
Dim LbCheck&, UbCheck&, LbMatch&, UbMatch&
If IsInitialized Then Else Initialize
LbCheck = LBound(bsCheck): UbCheck = UBound(bsCheck)
LbMatch = LBound(bsMatch): UbMatch = UBound(bsMatch)
If Compare = vbBinaryCompare Then
bMap1_SA.pData = VarPtr(bsCheck(LbCheck))
bMap2_SA.pData = VarPtr(bsMatch(LbMatch))
Else
Dim bsTmp1() As Byte, bsTmp2() As Byte
bsTmp1 = UCaseByt(bsCheck)
bsTmp2 = UCaseByt(bsMatch)
bMap1_SA.pData = VarPtr(bsTmp1(1))
bMap2_SA.pData = VarPtr(bsTmp2(1))
End If
lenCheck = UbCheck - LbCheck + 1
lenMatch = UbMatch - LbMatch + 1
bMap1_SA.Count = lenCheck
bMap2_SA.Count = lenMatch
If Start = -1 Then Start = lenCheck
bMatch = bMap2(1) 'v2
For i = Start - lenMatch + 1 To endFind Step -1
If bMap1(i) <> bMatch Then
Else
k = i
For j = 2 To lenMatch
k = k + 1
If bMap1(k) = bMap2(j) Then Else GoTo skip
Next
InStrEndRevByt = i: Exit Function
End If
skip:
Next
End Function
'>>>>>>>>>>>>TESTS<<<<<<<<<<<<<
Private Sub Test_StrConvByt()
Dim s$, b() As Byte, b2()
Dim s2$
s = StrConv("abcd", vbFromUnicode)
b = s
b = StrConvByt(b, vbUpperCase)
s2 = StrConv(b, vbUnicode)
End Sub
Private Sub Test_InStrEndInt()
Dim s1$, s2$
Dim rs1%(), rs2%()
Dim rs3() As Byte, rs4() As Byte
Dim rs1_ As SA1D, rs2_ As SA1D, rs3_ As SA1D, rs4_ As SA1D
Dim lres1&, lres2&, lres3&, lres4&
s1 = "gdjl;Eriuo": rs1 = GetStrMap(rs1_, s1): rs3 = GetStrMapB(rs3_, s1)
s2 = "l;er": rs2 = GetStrMap(rs2_, s2): rs4 = GetStrMapB(rs4_, s2)
' lres1 = InStrEndInt(rs1, rs2, 4, , 7)
' lres2 = InBytStr(rs3, rs4, 7, , 14)
lres3 = InStrEndRevInt(rs1, rs2, 7, vbTextCompare, 4)
lres4 = InStrEndRevByt(rs3, rs4, 14, vbTextCompare, 7)
End Sub
Private Sub Test_StrConvInt()
Dim s$, rs1%(), rs1SA As SA1D, rs2%(), rs2SA As SA1D
s = "ABCdzN"
rs1 = MidRef(rs1SA, s) ', 1, Len(s))
rs2 = StrConvInt(rs1, vbLowerCase)
Debug.Print IntToStr(rs2)
End Sub
Private Sub Test_toAnsi_formAnsi()
Dim s1$, s2$, rs1%(), iUn%(), SA1 As SA1D
Dim bAn() As Byte, b2() As Byte
s1 = "asfÀôÖri"
rs1 = MidRef(SA1, s1, 1, Len(s1))
bAn = IntToAnsi(rs1)
iUn = IntFromAnsi(bAn)
End Sub
Private Sub TestStrConvInAnsi()
Dim sU$, SA$, sAUp$, sUUp$
sU = "aBCd"
SA = StrConv(sU, vbFromUnicode)
sAUp = StrConv(SA, vbUpperCase)
sUUp = StrConv(sAUp, vbUnicode)
sUUp = StrConv(SA, vbUnicode)
End Sub
Private Sub Test_StrConvInt2()
Dim s$, rs%(), SA As SA1D, isUp%()
s = "abcd"
rs = GetStrMap(SA, s)
isUp = StrConvInt(rs, vbUpperCase)
Debug.Print IntToStr(isUp)
End Sub
Private Sub TestSALenB()
Dim SA As SA1D
Debug.Print LenB(SA)
End Sub
Private Sub Test_MidRef()
Dim s$, rStr%(), rStrSA As SA1D
s = "afpiuk44o"
rStr = MidRef(rStrSA, s, 3, 4)
Debug.Print VarPtr(rStr(1))
Debug.Print IntToStr(rStr)
End Sub
Private Sub Test_MidRefIntByt()
Dim i&, iAr%(0 To 8), iAr2%(), SA As SA1D
For i = 0 To 8: iAr(i) = i: Next
iAr2 = MidRefInt(SA, iAr, 3, 4)
End Sub
Private Sub Test_GetStrMap()
Dim sAnsi$, sUnic$, iStr%(), bstr() As Byte
Dim istrSA As SA1D, bstrSA As SA1D
sUnic = "ëäÎëÛÔ"
sAnsi = StrConv(sUnic, vbFromUnicode)
iStr = GetStrMap(istrSA, sUnic)
bstr = GetStrMapB(bstrSA, sAnsi)
End Sub