-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCallBack2.cls
More file actions
507 lines (459 loc) · 12 KB
/
Copy pathCallBack2.cls
File metadata and controls
507 lines (459 loc) · 12 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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CallBack2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'class for call back
Private objref As basetask
Private mineHere$
Public Event ErrorAtt(ByRef recover As Variant)
Private mObjRef As Object, mName$
Private reghash As New FastCollection
Dim locked As Boolean
Friend Sub NoPublic(bstack As basetask, where$)
Set objref = New basetask
Set objref.Sorosref = bstack.soros
Set objref.Owner = bstack.Owner
mineHere$ = where
End Sub
Friend Property Get CopyOfMe() As Object
Dim a As New CallBack2
a.NoPublic objref, mineHere$
Set CopyOfMe = a
End Property
Property Let ShowGui(RHS As Boolean)
If Forms.Count = 0 Then Exit Property
If RHS Then
Form1.Visible = True
Form1.WindowState = 0
If Form1.top >= VirtualScreenHeight Then Form1.move ScrInfo(Console).Left, ScrInfo(Console).top
Else
If Form1.WindowState = 0 Then
If Not (QRY Or GFQRY Or Forms.Count > 5) Then Form1.Visible = False
End If
End If
End Property
Public Sub EventRef(RHS As Object, Optional Name As String)
Set mObjRef = RHS
mName$ = Name$
End Sub
Public Sub MethodType(ByVal mName$, mType$)
mName$ = myUcase(mName$)
reghash.AddKey mName$, mType$
End Sub
Public Sub CallGlobal(modulename$, ParamArray a())
If status <> 0 Then Exit Sub
Dim ohere$
ohere$ = here$
Dim I As Long, ms As New mStiva, Ar As mArray, j As Long
Dim manydim As Long, maxitems As Long, probe As Long, v() As Variant, probelow As Long
Dim oldsoros As mStiva
Set oldsoros = objref.soros
Set objref.Sorosref = ms
For I = 0 To UBound(a())
Select Case VarType(a(I))
Case Is >= vbArray
' only with error control
If Typename(a(I)) = "Variant()" Then
Set Ar = New mArray
v() = a(I)
On Error Resume Next
For j = 1 To 60
probe = UBound(v, j)
If Err Then Exit For
Next j
manydim = j - 1
On Error Resume Next
Dim items As Long
For j = 1 To manydim
probe = UBound(v, j)
If Err Then Exit For
probelow = LBound(v, j)
Ar.PushDim probe - probelow + 1
Next j
Ar.PushEnd
'ar.RevOrder = True
Ar.CopySerialize v()
ms.DataObj Ar
Set Ar = Nothing
Erase v()
Else
ms.DataValLong 0
End If
Case vbEmpty
ms.DataValLong 0
Case vbVariant, vbString
ms.DataStr CStr(a(I))
Case Else
ms.DataVal CDbl(a(I))
End Select
Next I
PushStage objref, 0
Set ms = Nothing
here$ = vbNullString
If subHash.ExistKey(myUcase(modulename$, True)) Then
probe = interpret(objref, modulename$)
Else
Dim what
what = False
If mObjRef Is Nothing Then
RaiseEvent ErrorAtt(what)
If what = True Then Reset
Else
On Error Resume Next
If mName$ <> "" Then
mObjRef.Run mName$ + "_ErrorAtt", what
If Err Then Err.Clear: mObjRef.Run mName$ + ":ErrorAtt", what
Else
mObjRef.Run "ErrorAtt", what
End If
Err.Clear
If what = True Then
Reset
Else
Err.Raise 12345, , "Not Found"
End If
End If
End If
PopStage objref
Set objref.Sorosref = oldsoros
Set oldsoros = Nothing
here$ = ohere$
End Sub
Private Function GetSubFullName2(nm$, fullname$, retnum As Long) As Boolean
Dim dummy As Long
If Len(here$) > 0 Then
If Len(here$) > Len(nm$) Then
If Mid$(here$, Len(here$) - Len(nm$)) = "." + nm$ Then
GetSubFullName2 = subHash.Find2(nm$, retnum, dummy)
fullname = nm$: Exit Function
End If
End If
End If
If here$ <> "" Then
GetSubFullName2 = subHash.Find2(here$ & "." & nm$, retnum, dummy)
If GetSubFullName2 Then fullname$ = here$ & "." & nm$: Exit Function
End If
GetSubFullName2 = subHash.Find2(nm$, retnum, dummy)
If GetSubFullName2 Then fullname$ = nm$
End Function
Public Sub CallModule(modulename$, ParamArray a())
Static once As Boolean, where As Long, what, full$
If status <> 0 Then Exit Sub
If Not GetSubFullName2(myUcase(modulename$, True), full$, where) Then
what = False
If mObjRef Is Nothing Then
RaiseEvent ErrorAtt(what)
If what = True Then Reset
Else
On Error Resume Next
If mName$ <> "" Then
mObjRef.Run mName$ + "_ErrorAtt", what
If Err Then Err.Clear: mObjRef.Run mName$ + ":ErrorAtt", what
Else
mObjRef.Run "ErrorAtt", what
End If
Err.Clear
If what = True Then
Reset
Else
MyEr "Not Found " + modulename$, "Äåí ÂñÝèçêå " + modulename$
End If
End If
Exit Sub
End If
If once Then Exit Sub
Dim ohere$
once = True
ohere$ = here$
here$ = full$
Dim I As Long, ms As New mStiva, Ar As mArray, j As Long
Dim manydim As Long, maxitems As Long, probe As Long, v() As Variant, probelow As Long
Dim IhaveSignature As Boolean, sign$, sign2$, dummy$, look As Long
If reghash.Find(myUcase(modulename$, True)) Then
sign$ = reghash.Value
sign2$ = sign$
IhaveSignature = True
End If
' no byrefernece yet
Dim oldsoros As mStiva
Set oldsoros = objref.soros
Set objref.Sorosref = ms
For I = 0 To UBound(a())
Select Case VarType(a(I))
Case Is >= vbArray
' only with error control
If Typename(a(I)) = "Variant()" Then
Set Ar = New mArray
v() = a(I)
On Error Resume Next
For j = 1 To 60
probe = UBound(v, j)
If Err Then Exit For
Next j
manydim = j - 1
On Error Resume Next
For j = manydim To 1 Step -1
probe = UBound(v, j)
If Err Then Exit For
probelow = LBound(v, j)
Ar.PushDim probe - probelow + 1
Next j
Ar.PushEnd
Ar.RevOrder = True
Ar.CopySerialize v()
''
If IhaveSignature Then
look = IsLabelOnly(sign$, dummy$)
If look = 2 Then ' byref
look = IsLabelOnly(sign$, dummy$)
look = globalvarGroup("b" & (var2used) & "." & dummy$, True) ' perhaps this is a fault, why is true??
ElseIf look > 4 Then
FastSymbol sign, ")", True
ms.DataObj Ar
Else
SyntaxError
GoTo there
End If
Else
ms.DataObj Ar
End If
Set Ar = Nothing
Erase v()
Else
ms.DataValLong 0
End If
Case vbEmpty
ms.DataValLong 0
Case vbVariant, vbString
ms.DataStr CStr(a(I))
Case Else
ms.DataVal CDbl(a(I))
End Select
Next I
PushStage objref, 0
objref.soros.MergeTop ms
probe = FastCallModule(objref, where)
If probe <> 1 Then
If mObjRef Is Nothing Then
RaiseEvent ErrorAtt(what)
If what = True Then Reset
Else
On Error Resume Next
If mName$ <> "" Then
mObjRef.Run mName$ + "_ErrorAtt", what
If Err Then Err.Clear: mObjRef.Run mName$ + ":ErrorAtt", what
Else
mObjRef.Run "ErrorAtt", what
End If
Err.Clear
If what = True Then
Reset
Else
Err.Raise 12345, , "Not Found"
End If
End If
End If
there:
PopStage objref
Set objref.Sorosref = oldsoros
Set oldsoros = Nothing
here$ = ohere$
once = False
End Sub
Public Sub ExecuteStatement(ByVal Code$)
Dim what$, Pos As Long, func As Boolean, param$, drop$
If status <> 0 Then Exit Sub
If IsLabelOnly(Code$, what$) > 4 Then
func = True
ElseIf what$ = vbNullString Then
Exit Sub
ElseIf LTrim$(Code$) = vbNullString Then
' one call
Call Run(what$)
Exit Sub
End If
Do
Pos = 1
drop$ = aheadstatus(Code$, True, Pos)
If drop$ = vbNullString And Pos > Len(Code$) Then Exit Sub
If param$ <> "" Then
param$ = param$ + ", " + Left$(Code$, Pos - 1)
Else
param$ = Left$(Code$, Pos - 1)
End If
Code$ = Mid$(Code$, Pos)
Loop Until Not FastSymbol(Code$, ",")
If func Then
Call Run(what$ + " " + param$ + ")")
Else
Call Run(what$ + " " + param$)
End If
End Sub
Public Function Eval(Code$) As Variant
Dim Pos As Long, p As Double, s As String, drop$
Pos = 1
drop$ = aheadstatus(Code$, True, Pos)
If drop$ = vbNullString And Pos > Len(Code$) Then Exit Function
If InStr(drop$, "N") Then
If IsExp(objref, Left$(Code$, Pos), p) Then
If Not objref.lastobj Is Nothing Then
Set Eval = objref.lastobj
Else
Eval = p
End If
End If
Else
If IsStrExp(objref, Left$(Code$, Pos), s$) Then
If Not objref.lastobj Is Nothing Then
Set Eval = objref.lastobj
Else
Eval = s$
End If
End If
End If
Set objref.lastobj = Nothing
End Function
Public Sub AddExecCode(Code$)
If locked Then Exit Sub
Call Run(Code$, False)
End Sub
Public Function Run(ByVal Code$, Optional clean As Boolean = True) As Boolean
Dim ohere$, stay As Variant
If status <> 0 Then Exit Function
If elevatestatus2 Then Exit Function
elevatestatus2 = 1
If clean Then PushStage objref, 0
ohere$ = here$
here$ = mineHere$
NoAction = True
NOEXECUTION = False
objref.toprinter = False
MOUT = False
ResetBreak
Run = True
LastErNum = 0: LastErNum1 = 0
LastErName = vbNullString
LastErNameGR = vbNullString
If Execute(objref, Code$, False) <> 1 Then
Run = False
If Not App.StartMode = vbSModeStandalone Then
MOUT = True
ProcTitle objref, Chr$(34) + Chr$(34) + ",0", 0
End If
ClearLoadedForms
If NERR Then
If mObjRef Is Nothing Then
RaiseEvent ErrorAtt(stay)
If stay = True Then Reset Else Err.Raise 12345, , "Not Found"
Else
On Error Resume Next
If mName$ <> "" Then
mObjRef.Run mName$ + "_ErrorAtt", stay
If Err Then Err.Clear: mObjRef.Run mName$ + ":ErrorAtt", stay
Else
mObjRef.Run "ErrorAtt", stay
End If
Err.Clear
If stay = True Then
Reset
Else
Err.Raise 12345, , "Not Found"
End If
End If
If Not stay Then GoTo finalize
End If
objref.toprinter = False
If MOUT Then
NOEXECUTION = False
ResetBreak
MOUT = interpret(objref, "new: flush: clear")
MOUT = False
Else
If NOEXECUTION Then
closeAll
End If
End If
MOUT = True
NoAction = False
If ExTarget Then Run = False
End If
finalize:
If NERR Then
' problem
PopStage objref
End If
here$ = ohere$
If clean Then PopStage objref
elevatestatus2 = 0
Dim exityes
If NERR Then NERR = False: Err.Raise 50500, , "Fatal Error"
End Function
Property Get ErrorGr() As String
ErrorGr = LastErNameGR
End Property
Property Get ErrorEn() As String
ErrorEn = LastErName
End Property
Property Get status() As Long
If elevatestatus2 Then
status = -elevatestatus2
Else
status = LastErNum
End If
End Property
Public Sub Reset()
NERR = False
LastErNum = 0: LastErNum1 = 0
LastErName = vbNullString
LastErNameGR = vbNullString
End Sub
Private Sub Class_Initialize()
Set objref = New basetask
Set objref.Owner = Form1.DIS
mineHere$ = vbNullString 'HERE$
End Sub
Public Function SpellUnicode(a$)
' use spellunicode to get numbers
' and make a ListenUnicode...with numbers for input text
Dim b$, I As Long
For I = 1 To Len(a$) - 1
b$ = b$ & CStr(AscW(Mid$(a$, I, 1))) & ","
Next I
SpellUnicode = b$ & CStr(AscW(Right$(a$, 1)))
SpellUnicode = b$ & CStr(AscW(Right$(a$, 1)))
End Function
Public Function ListenUnicode(ParamArray aa() As Variant) As String
Dim all$, I As Long
For I = 0 To UBound(aa)
all$ = all$ & ChrW(aa(I))
Next I
ListenUnicode = all$
End Function
Private Sub Class_Terminate()
Set mObjRef = Nothing
mName$ = vbNullString
Set objref.Owner = Nothing
Set objref.Sorosref = Nothing
Set objref = Nothing
End Sub
' This is a way to create a fhandler outside M2000 and pass it to
' M2000 system, creating a M2000 File Handler.
' The M2000 File Handler now can be used from Print, Write, Input, Seek, Seek(), Get, Put, Close
' The exclusive or not is upon creation of the original file handler
' By Default we use open for Input (fway=1), so adjust it accordingly
' The fstep say 1 (means one character, this can change to something else only for Field type,fway=4)
' The unic=1 means we use UTF16LE (One Word width, 2 bytes)
' Use unic=0 for ANSI (is bound to Locale number)
Public Function FileHandler(Fhandler, Optional fway = 1, Optional Fstep = 1, Optional uinc = 1) As Variant
FileHandler = BigFileHandler(CLng(Fhandler), CLng(fway), CLng(Fstep), CLng(uinc))
End Function