-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathModule10.bas
More file actions
10473 lines (10175 loc) · 442 KB
/
Module10.bas
File metadata and controls
10473 lines (10175 loc) · 442 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
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "Module10"
Option Explicit
' some utilities for String$( string as converter)
' some code from dilettante - vbforums
' http://www.vbforums.com/showthread.php?342995-VB6-URL-Path-String-Manipulation-Functions
' removed all InStrB. strings expexted to be as UTF16LE (as strings in VB6)
' if we have an ascii string then we have to convert it before use it
' also if we have a UTF8 string we have to convert it before use it here
Private Type PeekArrayType
Ptr As Long
Reserved As Currency
End Type
Private Declare Function PeekArray Lib "kernel32" Alias "RtlMoveMemory" (arr() As Any, Optional ByVal Length As Long = 4) As PeekArrayType
Private Declare Function SafeArrayGetDim Lib "OleAut32.dll" (ByVal Ptr As Long) As Long
Private Declare Function vbaVarLateMemSt Lib "msvbvm60" _
Alias "__vbaVarLateMemSt" ( _
ByRef vDst As Variant, _
ByRef sName As Any, _
ByVal vValue As Variant) As Long
Private Declare Function vbaVarLateMemCallLdRf CDecl Lib "msvbvm60" _
Alias "__vbaVarLateMemCallLdRf" ( _
ByVal vDst As Long, _
ByVal vSrc As Long, _
ByVal sName As Long, _
ByVal cArgs As Long, _
ByVal vArgs As Long) As Long
Private Declare Sub PutMem4 Lib "msvbvm60" (ByVal Addr As Long, ByVal NewVal As Long)
Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Addr As Long, retval As Long)
Private Const E_POINTER As Long = &H80004003
Private Const S_OK As Long = 0
Private Const INTERNET_MAX_URL_LENGTH As Long = 2083
Private Const URL_ESCAPE_PERCENT As Long = &H1000&
Private Const URL_PART_SCHEME As Long = 1
Private Const URL_PART_HOSTNAME As Long = 2
Private Const URL_PART_USERNAME As Long = 3
Private Const URL_PART_PASSWORD As Long = 4
Private Const URL_PART_PORT As Long = 5
Private Const URL_PART_QUERY As Long = 6
Private Declare Function UrlEscape Lib "shlwapi" Alias "UrlEscapeW" ( _
ByVal pszURL As Long, _
ByVal pszEscaped As Long, _
ByRef pcchEscaped As Long, _
ByVal dwFlags As Long) As Long
Private Declare Function UrlUnescape Lib "shlwapi" Alias "UrlUnescapeW" ( _
ByVal pszURL As Long, _
ByVal pszUnescaped As Long, _
ByRef pcchUnescaped As Long, _
ByVal dwFlags As Long) As Long
Private Const CONST_HOSTNAME = 2
Private Declare Function UrlGetPart Lib "shlwapi" Alias "UrlGetPartW" ( _
ByVal pszIn As Long, _
ByVal pszOut As Long, _
pcchOut As Long, _
ByVal dwPart As Long, _
ByVal dwFlags As Long) As Long
Private Declare Function UrlCanonicalizeApi Lib "shlwapi" Alias "UrlCanonicalizeW" ( _
ByVal pszURL As Long, _
ByVal pszCanonicalized As Long, _
pcchCanonicalized As Long, _
ByVal dwFlags As Long) As Long
Const NO_ERROR = 0&
Const MOVEFILE_REPLACE_EXISTING = &H1
Const FILE_ATTRIBUTE_TEMPORARY = &H100
Const FILE_BEGIN = 0
Const FILE_CURRENT = 1
Const FILE_END = 2
Const FILE_SHARE_READ = &H1
Const FILE_SHARE_WRITE = &H2
Const FILE_APPEND_DATA = &H4
Const FILE_READ_ATTRIBUTES As Long = &H80&
Const CREATE_NEW = 1
Const CREATE_ALWAYS = 2
Const OPEN_EXISTING = 3
Const OPEN_ALLWAYS = 4
Const GENERIC_READ = &H80000000
Const GENERIC_WRITE = &H40000000
Const ERROR_SHARING_VIOLATION = 32&
Const INVALID_HANDLE_VALUE = (-1&)
Const INVALID_SET_FILE_POINTER = (-1&)
Const FILE_ATTRIBUTE_NORMAL = &H80
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function FlushFileBuffers Lib "kernel32" (ByVal hFile As Long) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileW" (ByVal lpFileName As Long, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function SetEndOfFile Lib "kernel32" (ByVal hFile As Long) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private InUseHandlers As New FastCollection
Private FreeUseHandlers As New FastCollection
Enum MyOpenFileType
ForInput = 1 ' Read - Begin
ForOutput = 2 ' write - End
ForAppend = 3 ' Read+Write - End
ForField = 4 ' Read+Write - Begin
End Enum
Enum MyOpenFileExclusive
ExclusiveON = 0 ' Lock at open from 0 to
ExclusiveOff = 1 ' not Lock
End Enum
Public FileError As Long
Public Enum Ftypes
FnoUse = 0
Finput = 1
Foutput = 2
Fappend = 3
Frandom = 4
End Enum
Sub AssignVal2Array(bstack As basetask, ppppAny As iBoxArray, v As Long)
Dim useHandler As mHandler, mAr As mArray, mtu As tuple
Dim usehandler1 As mHandler
Set useHandler = bstack.lastobj
If useHandler.t1 = 4 Then
Select Case ppppAny.MyTypeToBe
Case vbVariant, vbObject
Set ppppAny.item(v) = bstack.lastobj
Case vbString, vbByte
ppppAny.item(v) = useHandler.index_cursor
Case 201, 36
'nothing change
Case Else
ppppAny.item(v) = useHandler.index_cursor * useHandler.sign
End Select
Else
If useHandler.ReadOnly And useHandler.t1 = 3 Then
Set usehandler1 = New mHandler
usehandler1.t1 = 3
With useHandler
If .UseIterator Then
usehandler1.UseIterator = True
usehandler1.index_start = .index_start
usehandler1.index_End = .index_End
usehandler1.index_cursor = .index_cursor
End If
End With
If TypeOf useHandler.objref Is mArray Then
Set mAr = New mArray
useHandler.objref.CopyArray mAr
Set usehandler1.objref = mAr
ElseIf TypeOf useHandler.objref Is tuple Then
Set mtu = New tuple
useHandler.objref.CopyArray mtu
Set usehandler1.objref = mtu
Else
Set usehandler1 = useHandler
End If
Set ppppAny.item(v) = usehandler1
Else
Set ppppAny.item(v) = useHandler
End If
End If
Set bstack.lastobj = Nothing
End Sub
Sub FileReadString(FileH As Long, r$, bytes As Long)
Dim Buf1() As Byte
If bytes <= 0 Then r$ = vbNullString: Exit Sub
If FileH = 0 Then Exit Sub
ReDim Buf1(0 To bytes - 1)
r$ = Buf1()
API_ReadFile FileH, bytes, Buf1()
CopyMemory ByVal StrPtr(r$), Buf1(0), bytes
End Sub
Sub FileReadBytes(FileH As Long, Buf1() As Byte, bytes As Long)
If bytes <= 0 Then Exit Sub
If FileH = 0 Then Exit Sub
API_ReadFile FileH, bytes, Buf1
End Sub
Sub FileWriteString(FileH As Long, r$)
Dim Buf1() As Byte, bytes As Long
If LenB(r$) = 0 Then Exit Sub
If FileH = 0 Then Exit Sub
bytes = LenB(r$)
ReDim Buf1(bytes - 1)
CopyMemory Buf1(0), ByVal StrPtr(r$), bytes
API_WriteFile FileH, bytes, Buf1()
End Sub
Sub FileWriteBytes(FileH As Long, ByRef Buf1() As Byte)
Dim bytes As Long
If PeekArray(Buf1()).Ptr = 0 Then Exit Sub
If FileH = 0 Then Exit Sub
bytes = UBound(Buf1()) - LBound(Buf1()) + 1
API_WriteFile FileH, bytes, Buf1()
End Sub
Private Function GetType(bstack As basetask, b$, p, v As Long, W$, Lang As Long, VarStat As Boolean, temphere$, noVarStat As Boolean) As Integer
Dim ss$, skip As Boolean, checktype As Boolean
If noVarStat Then
If GetVar(bstack, W$, v, , , True, , checktype) Then
skip = True
On Error Resume Next
End If
End If
If IsLabelSymbolNew(b$, "ÁÑÉÈÌÏÓ", "DECIMAL", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CDec(p)
If Err.Number Then p = CDec(0)
ElseIf IsLabelSymbolNew(b$, "ÄÉÐËÏÓ", "DOUBLE", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CDbl(p)
If Err.Number Then p = CDbl(0)
ElseIf IsLabelSymbolNew(b$, "ÁÐËÏÓ", "SINGLE", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CSng(p)
If Err.Number Then p = CSng(0)
ElseIf IsLabelSymbolNew(b$, "ËÏÃÉÊÏÓ", "BOOLEAN", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CBool(p)
If Err.Number Then p = False
ElseIf IsLabelSymbolNew(b$, "ÌÁÊÑÕÓ", "LONG", Lang) Then
If IsLabelSymbolNew(b$, "ÌÁÊÑÕÓ", "LONG", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = cInt64(p)
If Err.Number Then p = cInt64(CDec(0))
Else
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CLng(p)
If Err.Number Then p = CLng(0)
End If
ElseIf IsLabelSymbolNew(b$, "ÁÊÅÑÁÉÏÓ", "INTEGER", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CInt(p)
If Err.Number Then p = CInt(0)
ElseIf IsLabelSymbolNew(b$, "ËÏÃÉÓÔÉÊÏÓ", "CURRENCY", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CCur(p)
ElseIf IsLabelSymbolNew(b$, "ÃÑÁÌÌÁ", "STRING", Lang) Then
If FastSymbol(b$, "=") Then
If Not ISSTRINGA(b$, ss$) Then MissString: Exit Function
ElseIf skip Then
If MemInt(VarType(v)) = vbString Then
ss$ = var(v)
Else
ss$ = ""
End If
End If
p = vbNullString
SwapString2Variant ss$, p
ElseIf IsLabelSymbolNew(b$, "ÁÔÕÐÏÓ", "VARIANT", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then
If ISSTRINGA(b$, ss$) Then
p = vbNullString
SwapString2Variant ss$, p
Else
missNumber
Exit Function
End If
End If
End If
v = globalvar(W$, p, , VarStat, temphere$, useType:=False)
If extreme Then GetType = 2 Else GetType = 1
Exit Function
ElseIf IsLabelSymbolNew(b$, "ØÇÖÉÏ", "BYTE", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then missNumber: Exit Function
ElseIf skip Then
p = var(v)
End If
p = CByte(p)
If Err.Number Then p = CByte(0)
ElseIf IsLabelSymbolNew(b$, "ÇÌÅÑÏÌÇÍÉÁ", "DATE", Lang) Then
If FastSymbol(b$, "=") Then
If Not IsNumberD2(b$, p) Then
If ISSTRINGA(b$, ss$) Then
p = vbNullString
SwapString2Variant ss$, p
Else
missNumber
Exit Function
End If
Else
End If
ElseIf skip Then
p = var(v)
End If
p = CDate(p)
If Err.Number Then p = CDate(0)
ElseIf IsLabelSymbolNew(b$, "ÌÉÃÁÄÉÊÏÓ", "COMPLEX", Lang) Then
If FastSymbol(b$, "=") Then
p = nMath2.cxZero
If FastSymbol(b$, "(") Then
Dim p1
If Not IsNumberD2(b$, p1) Then
GoTo ER0001
End If
p.r = CDbl(p1)
If Not FastSymbol(b$, ",") Then GoTo ER0001
If Not IsNumberD2(b$, p1) Then
GoTo ER0001
End If
p.i = CDbl(p1)
b$ = NLtrim(b$)
If Not UCase$(Left$(b$, 2)) = "I)" Then GoTo ER0001
Mid$(b$, 1, 2) = " "
Else
GoTo ER0001
End If
Else
p = nMath2.cxZero
End If
ElseIf IsLabelSymbolNew(b$, "ÌÅÃÁËÏÓÁÊÅÑÁÉÏÓ", "BIGINTEGER", Lang) Then
Set p = New BigInteger
If FastSymbol(b$, "=") Then
If ISSTRINGA(b$, ss$) Then
Set p = Module13.CreateBigInteger(ss$)
ElseIf Not IsNumberD2(b$, p, True, True) Then
missNumber
Exit Function
Else
If MemInt(VarPtr(p)) = vbString Then
Set p = Module13.CreateBigInteger(CStr(p))
Else
Set p = Module13.CreateBigInteger(Format(Int(p), "0"))
End If
End If
End If
ElseIf Not IsEnumAs(bstack, b$, p) Then
ExpectedEnumType
Exit Function
End If
If noVarStat Then
If skip Then GoTo there1
If Not GetVar(bstack, W$, v, , , True, , checktype) Then
v = globalvar(W$, p, , VarStat, temphere$)
Else
there1:
If Not checktype Then
ER0001:
WrongType
Exit Function
End If
If MyIsObject(p) Then
If Not p Is Nothing Then
If TypeOf p Is BigInteger Then
Set var(v) = p
GoTo abcd
End If
End If
bstack.soros.PushObj p
If Not MyRead(5, bstack, W$, Lang, "") Then
Exit Function
End If
Else
var(v) = p
End If
End If
Else
v = globalvar(W$, p, , VarStat, temphere$)
End If
abcd:
Err.Clear
If extreme Then GetType = 2 Else GetType = 1
End Function
' We have to provide a new file created before
' in any case
' 0 is error.
' non 0 is the filehandler from M2000 (not the real handler)
Function MyOpenFile(ByVal f$, ftype As MyOpenFileType, fexc As MyOpenFileExclusive, fstp As Long, unif As Long) As Long
If Left$(f$, 2) <> "\\" Then
f$ = "\\?\" + f$
End If
Dim FileH As Long
FileError = 511
On Error GoTo there:
Select Case ftype
Case ForInput
FileH = CreateFile(StrPtr(f$), GENERIC_READ, (FILE_SHARE_READ Or FILE_SHARE_WRITE) * fexc, ByVal 0&, OPEN_EXISTING, 0&, 0&)
Case ForOutput
FileH = CreateFile(StrPtr(f$), GENERIC_WRITE, (FILE_SHARE_READ Or FILE_SHARE_WRITE) * fexc, ByVal 0&, CREATE_ALWAYS, 0&, 0&)
Case Else
FileH = CreateFile(StrPtr(f$), GENERIC_READ Or GENERIC_WRITE, (FILE_SHARE_READ Or FILE_SHARE_WRITE) * fexc, ByVal 0&, OPEN_EXISTING, 0&, 0&)
End Select
If FileH = INVALID_HANDLE_VALUE Then
FileError = GetLastError()
If FileError = ERROR_SHARING_VIOLATION Then
MyEr "Can't open file, Not Sharing allowed" & FileError, "Äåí ìðïñþ íá áíïßîù ôï áñ÷åßï, äåí åðéôñÝðåôáé ìïßñáóìá"
Exit Function
End If
there:
MyEr "Can't open file, error :" & FileError, "Äåí ìðïñþ íá áíïßîù ôï áñ÷åßï :" & FileError
Exit Function
End If
' So now we get the filehandler as 1
MyOpenFile = BigFileHandler(CVar(FileH), ftype, fstp, unif)
Select Case ftype
Case ForOutput, ForAppend
SetFilePointer FileH, 0&, 0&, FILE_END
Case Else
SetFilePointer FileH, 0&, 0&, FILE_BEGIN
End Select
End Function
Private Function proc101(b$) As String
proc101 = vbNullString
If FastSymbol(b$, "+=", , 2) Then
proc101 = "+"
ElseIf FastSymbol(b$, "/=", , 2) Then
proc101 = "/"
ElseIf FastSymbol(b$, "-=", , 2) Then
proc101 = "-"
ElseIf FastSymbol(b$, "*=", , 2) Then
proc101 = "*"
ElseIf IsOperator0(b$, "++", 2) Then
proc101 = "++"
ElseIf IsOperator0(b$, "--", 2) Then
proc101 = "--"
ElseIf IsOperator0(b$, "-!", 2) Then
proc101 = "-!"
ElseIf IsOperator0(b$, "~") Then
proc101 = "!!"
ElseIf FastSymbol(b$, "<=", , 2) Then
proc101 = "g"
End If
End Function
Private Function proc102(b$) As String
proc102 = vbNullString
If FastSymbol(b$, "+=", , 2) Then
proc102 = "+="
ElseIf FastSymbol(b$, "/=", , 2) Then
proc102 = "/="
ElseIf FastSymbol(b$, "-=", , 2) Then
proc102 = "-="
ElseIf FastSymbol(b$, "*=", , 2) Then
proc102 = "*="
ElseIf IsOperator0(b$, "++", 2) Then
proc102 = "++"
ElseIf IsOperator0(b$, "--", 2) Then
proc102 = "--"
ElseIf IsOperator0(b$, "-!", 2) Then
proc102 = "-!"
End If
End Function
Function bigintOperations(bstack As basetask, rest$, ByRef BI As BigInteger, ss$) As Boolean
Dim p As Variant, BI2 As BigInteger
If ss$ = "@@" Then
FastPureLabel rest$, ss$, , True
End If
If ss$ = "++" Then
Set BI = BI.Add(Module13.CreateBigInteger("1"))
ElseIf ss$ = "--" Then
Set BI = BI.Add(Module13.CreateBigInteger("-1"))
ElseIf ss$ = "-!" Then
BI.negate
ElseIf ss$ = "*=" Then
If IsExp(bstack, rest$, p) Then
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.multiply(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.multiply(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
End If
ElseIf ss$ = "/=" Then
contdiv:
If IsExp(bstack, rest$, p) Then
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.divide(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.divide(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
End If
ElseIf ss$ = "+=" Then
If IsExp(bstack, rest$, p) Then
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.Add(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.Add(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
End If
ElseIf ss$ = "-=" Then
If IsExp(bstack, rest$, p) Then
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI = BI.subtract(bstack.lastobj)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.subtract(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
End If
Else
Select Case ss$
Case "MOD", "ÕÐÏË", "ÕÐÏËÏÉÐÏ"
If IsExp(bstack, rest$, p) Then
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI = BI.Modulus(bstack.lastobj)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.Modulus(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
End If
Case "DIV", "ÄÉÁ"
GoTo contdiv
Case Else
WrongOperator
Exit Function
End Select
End If
bigintOperations = True
Exit Function
WrongObj:
WrongObject
End Function
Function bigintOperationsRef(bstack As basetask, b$, p, ByRef BI As BigInteger, ByVal ww As Integer) As Boolean
Dim BI2 As BigInteger
Select Case ww
Case 1
Set BI = BI.Add(Module13.CreateBigInteger("1"))
Case 2
Set BI = BI.Add(Module13.CreateBigInteger("-1"))
Case 3
BI.negate
Case 4
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.Add(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.Add(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
Case 5
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI = BI.subtract(bstack.lastobj)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.subtract(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
Case 6
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.multiply(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.multiply(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
Case 7
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI2 = bstack.lastobj
Set BI = BI.divide(BI2)
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = BI.divide(Module13.CreateBigInteger(Format$(Int(p), "0")))
End If
Case 8
If Not bstack.lastobj Is Nothing Then
If TypeOf bstack.lastobj Is BigInteger Then
Set BI = bstack.lastobj
Set bstack.lastobj = Nothing
Else
GoTo WrongObj
End If
Else
Set BI = Module13.CreateBigInteger(Format$(Int(p), "0"))
End If
Case Else
WrongOperator
Exit Function
End Select
bigintOperationsRef = True
Exit Function
WrongObj:
WrongObject
End Function
Function procObject(bstack As basetask, W$, p, v As Long, useType As Boolean, VarStat As Boolean, isglobal As Boolean, NewStat As Boolean) As Boolean
Dim myobject As Object, useHandler As mHandler, usehandler1 As mHandler, oo As Object, cv As Constant
Set myobject = bstack.lastobj
Set oo = myobject
If TypeOf bstack.lastobj Is Group Then ' oh is a group
Set bstack.lastobj = Nothing
If myobject.IamApointer Then
Set var(v) = myobject
Else
If useType Then
myobject.ToDelete = True
UnFloatGroup bstack, W$, v, myobject, VarStat Or isglobal, , myVarType(var(v), vbEmpty) ' global??
If Len(bstack.UseGroupname) <> 0 Then
var(v).IamRef = True
If Not (VarStat Or isglobal) Then
globalvar W$, CVar(v), True, True
End If
End If
Else
'Set p = myobject
MakeGroupPointer bstack, CVar(myobject) ' p
Set var(v) = bstack.lastobj
Set bstack.lastobj = Nothing
Set bstack.lastpointer = Nothing
End If
End If
Set myobject = Nothing
ElseIf CheckAnyArray(myobject) Then
If TypeOf oo Is mHandler Then
Set useHandler = oo
If useHandler.ReadOnly Then
Set usehandler1 = New mHandler
useHandler.CopyTo usehandler1
Set var(v) = usehandler1
Else
Set useHandler = New mHandler
useHandler.t1 = 3
Set var(v) = useHandler
Set useHandler.objref = myobject
Set usehandler1 = oo
With usehandler1
If .UseIterator Then
useHandler.UseIterator = True
useHandler.index_start = .index_start
useHandler.index_End = .index_End
useHandler.index_cursor = .index_cursor
End If
End With
End If
Else
Set useHandler = New mHandler
Set var(v) = useHandler
useHandler.t1 = 3
Set useHandler.objref = myobject
End If
Set useHandler = Nothing
Set usehandler1 = Nothing
ElseIf TypeOf myobject Is mHandler Then
Set useHandler = myobject
If useHandler.indirect > -1 Then
If MyIsObject(var(useHandler.indirect)) Then
' we pass an indirect handler (Static in module)
' as a non static in var(v), so we can return it, but why???
Set var(v) = var(useHandler.indirect)
Else
BadObjectDecl
Exit Function
End If
Else
Set var(v) = useHandler
If useHandler.t1 = 4 Then
If MemInt(VarPtr(useHandler.index_cursor)) = vbString Then
Else
If useHandler.sign * useHandler.index_cursor <> p Then useHandler.sign = -useHandler.sign
End If
End If
End If
If TypeOf bstack.lastobj Is mHandler Then
Set usehandler1 = bstack.lastobj
If VarTypeName(var(v)) = "mHandler" Then
Set useHandler = var(v)
With usehandler1
If .UseIterator Then
useHandler.UseIterator = True
useHandler.index_start = .index_start
useHandler.index_End = .index_End
useHandler.index_cursor = .index_cursor
End If
End With
Set useHandler = Nothing
End If
Set usehandler1 = Nothing
End If
Set bstack.lastobj = Nothing
ElseIf TypeOf myobject Is lambda Then
If funid.Find(W$ + "(", (0)) Then
funid.ItemCreator W$ + "(", -2
End If
If here$ = vbNullString Or VarStat Or NewStat Then
GlobalSub W$ + "()", "", , , v
Else
GlobalSub here$ + "." + bstack.GroupName + W$ + "()", "", , , v
End If
Set var(v) = myobject
Set bstack.lastobj = Nothing
ElseIf TypeOf myobject Is mEvent Then
Set var(v) = myobject
CopyEvent var(v), bstack
Set var(v) = bstack.lastobj
ElseIf TypeOf myobject Is BigInteger Then
Set bstack.lastobj = Nothing
Set var(v) = CopyBigInteger(myobject)
ElseIf VarType(var(v)) = vbEmpty Then
Set var(v) = myobject
Else
Set myobject = Nothing
Set bstack.lastobj = Nothing
If VarType(var(v)) = vbLong Then
NoObjectpAssignTolong
ElseIf VarType(var(v)) = vbInteger Then
NoObjectpAssignToInteger
Else
NoObjectAssign
If MyIsNumeric(var(v)) Then
If var(v) = vbEmpty Then var(v) = 0#
End If
End If
Exit Function 'GoTo err000
End If
Set bstack.lastpointer = Nothing
Set bstack.lastobj = Nothing
Set myobject = Nothing
procObject = True
End Function
Private Function readvarv(v, ss$, p) As Boolean
Dim sp
readvarv = True
Select Case ss$
Case "DIV", "ÄÉÁ"
v = Fix(v / p)
Case "DIV#", "ÄÉÁ#"
If p < 0 Then
v = Int((v - Abs(v - Abs(p) * Int(v / Abs(p)))) / p)
Else
v = Int(v / p)
End If
Case "MOD", "ÕÐÏË", "ÕÐÏËÏÉÐÏ"
sp = v - Fix(v / p) * p
If Abs(sp) >= Abs(p) Then sp = sp - sp
v = sp
Case "MOD#", "ÕÐÏË#", "ÕÐÏËÏÉÐÏ#"
sp = Abs(v - Abs(p) * Int(v / Abs(p)))
If Abs(sp) >= Abs(p) Then sp = sp - sp
v = sp
Case Else
readvarv = False
End Select
End Function
Private Function readvarvLong(v, ss$, p) As Boolean
Dim sp
readvarvLong = True
Select Case ss$
Case "DIV", "ÄÉÁ"
var(v) = CLng(Fix(var(v) / p))
Case "DIV#", "ÄÉÁ#"
If p < 0 Then
var(v) = CLng((var(v) - Abs(var(v) - Abs(p) * Int(var(v) / Abs(p)))) / p)
Else
var(v) = CLng(var(v) / p)
End If
Case "MOD", "ÕÐÏË", "ÕÐÏËÏÉÐÏ"
sp = var(v) - Fix(var(v) / p) * p
If Abs(sp) >= Abs(p) Then sp = sp - sp
var(v) = CLng(sp)
Case "MOD#", "ÕÐÏË#", "ÕÐÏËÏÉÐÏ#"
sp = Abs(var(v) - Abs(p) * Int(var(v) / Abs(p)))
If Abs(sp) >= Abs(p) Then sp = sp - sp
var(v) = CLng(sp)
Case Else
readvarvLong = False
End Select
End Function
Public Property Get uni(RHS) As Long
Dim H
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
uni = H(3)
End If
End Property
Public Property Get Fstep(RHS) As Long
Dim H
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
Fstep = H(2)
End If
End Property
Public Property Get Fkind(RHS) As Ftypes
Dim H
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
Fkind = H(1)
End If
End Property
Public Property Let FileSeek(RHS, vvv)
Dim H, where, ret As Currency, LowLong As Long, HighLong As Long
Dim FileError As Long
ret = CCur(Int(vvv)) - 1
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
where = H(0)
Size2Long ret, LowLong, HighLong
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_BEGIN)
FileError = GetLastError()
If LowLong = INVALID_SET_FILE_POINTER And FileError <> 0 Then
MyEr "Can't write the seek value", "Äåí ìðïñþ íá ãñÜøù ôç ôéìÞ ìåôÜèåóçò"
End If
Else
MyEr "No such file handler", "Äåí õðÜñ÷åé ôÝôïéï ÷åéñéóôÞò áñ÷åßïõ"
End If
End Property
Public Property Get FileSeek(RHS) As Variant
Dim H, where, ret As Currency, LowLong As Long, HighLong As Long
FileSeek = ret
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
where = H(0)
LowLong = 0
HighLong = 0
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_CURRENT)
If LowLong = INVALID_SET_FILE_POINTER Then
MyEr "Can't read the seek value", "Äåí ìðïñþ íá äéáâÜóù ôç ôéìÞ ìåôÜèåóçò"
Else
Long2Size LowLong, HighLong, ret
FileSeek = ret + 1
End If
Else
MyEr "No such file handler", "Äåí õðÜñ÷åé ôÝôïéï ÷åéñéóôÞò áñ÷åßïõ"
End If
End Property
Public Property Let FileSeekFH(where As Long, ByVal ret As Currency)
Dim LowLong As Long, HighLong As Long
Dim FileError As Long
Size2Long ret - 1@, LowLong, HighLong
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_BEGIN)
FileError = GetLastError()
If LowLong = INVALID_SET_FILE_POINTER And FileError <> 0 Then
MyEr "Can't write the seek value", "Äåí ìðïñþ íá ãñÜøù ôç ôéìÞ ìåôÜèåóçò"
End If
End Property
Public Property Get FileSeekFH(where As Long) As Currency
Dim LowLong As Long, HighLong As Long
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_CURRENT)
If LowLong = INVALID_SET_FILE_POINTER Then
MyEr "Can't read the seek value", "Äåí ìðïñþ íá äéáâÜóù ôç ôéìÞ ìåôÜèåóçò"
Else
Long2Size LowLong, HighLong, FileSeekFH
FileSeekFH = FileSeekFH + 1
End If
End Property
Public Property Get FileEOFFH(where As Long) As Boolean
Dim ret As Currency, LowLong As Long, HighLong As Long
Dim fsize As Currency
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_CURRENT)
If LowLong = INVALID_SET_FILE_POINTER Then
MyEr "Can't read the seek value on Eof() function", "Äåí ìðïñþ íá äéáâÜóù ôç ôéìÞ ìåôÜèåóçò óôç óõíÜñôçóç ÌåôÜèåóç()"
Else
Long2Size LowLong, HighLong, ret
LowLong = GetFileSize(where, HighLong)
Long2Size LowLong, HighLong, fsize
FileEOFFH = ret >= fsize
End If
End Property
Public Property Get FileEOF(RHS) As Boolean
Dim H, where, ret As Currency, LowLong As Long, HighLong As Long
Dim fsize As Currency
If InUseHandlers.ExistKey(RHS) Then
H = InUseHandlers.Value
where = H(0)
LowLong = SetFilePointer(where, LowLong, HighLong, FILE_BEGIN)
If LowLong = INVALID_SET_FILE_POINTER Then
MyEr "Can't read the seek value on Eof() function", "Äåí ìðïñþ íá äéáâÜóù ôç ôéìÞ ìåôÜèåóçò óôç óõíÜñôçóç ÌåôÜèåóç()"
Else
Long2Size LowLong, HighLong, ret
LowLong = GetFileSize(where, HighLong)
Long2Size LowLong, HighLong, fsize
FileEOF = ret >= fsize
End If
Else
MyEr "No such file handler", "Äåí õðÜñ÷åé ôÝôïéï ÷åéñéóôÞò áñ÷åßïõ"
End If
End Property
Public Function BigFileHandler(FH As Long, ftype As Long, fst As Long, unif As Long) As Long
Static MaxNum As Long
Dim where As Long
If FreeUseHandlers.Count = 0 Then
MaxNum = MaxNum + 1
InUseHandlers.AddKey CVar(MaxNum), Array(FH, ftype, fst, unif)
InUseHandlers.sValue = FH
BigFileHandler = MaxNum
Else
FreeUseHandlers.ToEnd
where = CLng(FreeUseHandlers.KeyToNumber)
FreeUseHandlers.RemoveWithNoFind
FreeUseHandlers.Done = False
InUseHandlers.AddKey CVar(where), Array(FH, ftype, fst, unif)
InUseHandlers.sValue = FH
BigFileHandler = where
End If
End Function
'internal use
Public Function ReadFileHandler(H&) As Variant
If InUseHandlers.Find(CVar(H&)) Then
ReadFileHandler = InUseHandlers.sValue
Else
MyEr "No such file handler", "Äåí õðÜñ÷åé ôÝôïéï ÷åéñéóôÞò áñ÷åßïõ"
End If
End Function
' internal use You have to close file first
Public Sub CloseHandler(RHS)
Dim H&, ar() As Variant
On Error Resume Next
If InUseHandlers.ExistKey(RHS) Then
H& = CLng(InUseHandlers.sValue)
API_CloseFile H&
H& = InUseHandlers.KeyToNumber
InUseHandlers.RemoveWithNoFind
FreeUseHandlers.AddKey CVar(H&)
Else
' no error... (I am thinking about it)
End If
End Sub
Public Sub CloseAllHandlers()
Dim H&