-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodHelper.bas
More file actions
1216 lines (1121 loc) · 40.1 KB
/
modHelper.bas
File metadata and controls
1216 lines (1121 loc) · 40.1 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 = "modHelper"
'Module modHelper. Base on clsExpressionParse.
'Sorry. I do not remember the author
'Implementation expression parser
'Grammar:
'MathExp : Expression ['=' Expression]*
'Expression : Term ['+'|'-' Term]*
'Term : Factor ['*'|'/' Fractor]*
'Fractor : Element ['^' | '_' Element]*
'Element : '(' Expression ')' | Atom
'Atom : Symbol
'Symbol : Leter[Letter]*
'Letter : A-Z|0-9|'['']'',''.'
Option Explicit
Public Const MATH_SYMBOL_FONT = "Lucida Bright Math Symbol"
Public Const MATH_CHAR_FONT = "Lucida Bright Math Italic"
Public Const MATH_EXTENSION_FONT = "Lucida Bright Math Extension"
Public Const INT_SIGN = &H97
Public Const SUM_SIGN = &HAA
Public Const PROD_SIGN = &HA9
Public Const UNI_SIGN = &H7E
Public Const PLUS_SIGN = &H21
Private Const GENERIC_SYNTAX_ERR_MSG = "Syntax Error"
Private Const MAX_SYMBOLS = 83
Private Const MAX_MATHOP = 11
Private Enum ParserErrors
PERR_FIRST = vbObjectError + 513
PERR_SYNTAX_ERROR = PERR_FIRST
PERR_DIVISION_BY_ZERO
PERR_CLOSING_PARENTHESES_EXPECTED
PERR_OVER_OPERATOR_EXPECTED
PERR_LAST = PERR_OVER_OPERATOR_EXPECTED
End Enum
Private Enum ParserTokens
TOK_UNKNOWN
TOK_FIRST
TOK_PM = TOK_FIRST
TOK_ADD
TOK_MP
TOK_SUBTRACT
TOK_EQUAL
TOK_DIFF
TOK_LEQ
TOK_LESS
TOK_GEQ
TOK_GRE
TOK_AND
TOK_or
TOK_MULTIPLY
TOK_DIVIDE
TOK_POWER
TOK_SUBSCRIPT
TOK_OPEN_PARENTHESES
TOK_CLOSE_PARENTHESES
TOK_LIST_SEPERATOR
TOK_LAST = TOK_LIST_SEPERATOR
End Enum
Public Enum OVERTYPE
OVER_NORMAL
OVER_VECTOR
OVER_ANGLE
OVER_CHORD
OVER_ABS
End Enum
Public Type MATH_SYMBOL
strEntity As String
nCode As Long
nFontIndex As Long
End Type
Public Type MATH_OP
strOP As String
nCode As Long
nFontIndex As Long
End Type
Private mMathSymbols() As MATH_SYMBOL
Private mMathOPs() As MATH_OP
'Private mMathCodes() As Long
Private mTokenSymbols() As String
Private mExpression As String
Private mPosition As Long
Private mLastTokenLength As Long
Private mProjectName As String
Public Function ParseExpression(ByVal strExpression As String) As clsBox
'On Error GoTo ParseExpression_ErrHandler
Dim Value As New clsBox
Dim OtherValue As clsBox
Dim CurrToken As ParserTokens
mExpression = strExpression
mPosition = 1
SkipSpaces
Set Value = Expression
If mPosition <= Len(mExpression) Then
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Set ParseExpression = Value
Exit Function
ParseExpression_ErrHandler:
Set ParseExpression = Nothing
SetErrSource "ParseExpression"
Err.Raise Err.Number
End Function
Private Function Expression() As clsBox
'On Error GoTo ParseExp_ErrHandler
Dim Value As clsBox
Dim OtherValue As clsBox
Dim CurrToken As ParserTokens
Set Value = Term
Do While mPosition <= Len(mExpression)
CurrToken = GetToken
If CurrToken = TOK_PM Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("+-"), OtherValue)
ElseIf CurrToken = TOK_MP Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("-+"), OtherValue)
ElseIf CurrToken = TOK_ADD Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("+"), OtherValue)
ElseIf CurrToken = TOK_SUBTRACT Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("-"), OtherValue)
ElseIf CurrToken = TOK_EQUAL Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("="), OtherValue)
ElseIf CurrToken = TOK_DIFF Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("<>"), OtherValue)
ElseIf CurrToken = TOK_LESS Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("<"), OtherValue)
ElseIf CurrToken = TOK_GRE Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text(">"), OtherValue)
ElseIf CurrToken = TOK_LEQ Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text("<="), OtherValue)
ElseIf CurrToken = TOK_GEQ Then
SkipLastToken
Set OtherValue = Term
Set Value = Concat3(Value, Text(">="), OtherValue)
ElseIf CurrToken = TOK_UNKNOWN Then
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
Else
Set Expression = Value
Exit Function
End If
Loop
Set Expression = Value
Exit Function
ParseExp_ErrHandler:
SetErrSource "ParseExp"
Err.Raise Err.Number
End Function
Private Function Term() As clsBox
'On Error GoTo ParseTerm_ErrHandler
Dim Value As clsBox
Dim OtherValue As clsBox
Dim CurrToken As ParserTokens
Set Value = Factor
Do While mPosition <= Len(mExpression)
CurrToken = GetToken
If CurrToken = TOK_MULTIPLY Then
SkipLastToken
Set OtherValue = Factor
Set Value = Concat3(Value, Text("*"), OtherValue)
ElseIf CurrToken = TOK_DIVIDE Then
SkipLastToken
Set OtherValue = Factor
Set Value = Fraction(Value, OtherValue)
ElseIf CurrToken = TOK_AND Then
SkipLastToken
Set OtherValue = Factor
Set Value = Concat3(Value, Text("∧"), OtherValue)
ElseIf CurrToken = TOK_or Then
SkipLastToken
Set OtherValue = Factor
Set Value = Concat3(Value, Text("∨"), OtherValue)
ElseIf CurrToken = TOK_UNKNOWN Then
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
Else
Set Term = Value
Exit Function
End If
Loop
Set Term = Value
Exit Function
ParseTerm_ErrHandler:
SetErrSource "ParseTerm"
Err.Raise Err.Number
End Function
Private Function Factor() As clsBox
'On Error GoTo ParseFactor_ErrHandler
Dim Value As clsBox
Dim OtherValue As clsBox
Dim BracketTmp As clsBracket
Dim CurrToken As ParserTokens
Set Value = Element
Do While mPosition <= Len(mExpression)
CurrToken = GetToken
If CurrToken = TOK_POWER Then
SkipLastToken
Set OtherValue = Element
'Remove bracket if OtherValue is a super script
If OtherValue.ClassName = "bracket" Then
Set BracketTmp = OtherValue
Set Value = Power(Value, BracketTmp.Content)
Else
Set Value = Power(Value, OtherValue)
End If
ElseIf CurrToken = TOK_SUBSCRIPT Then
SkipLastToken
Set OtherValue = Element
'Remove bracket if OtherValue is a subscript script
If OtherValue.ClassName = "bracket" Then
Set BracketTmp = OtherValue
Set Value = Subscript(Value, BracketTmp.Content)
Else
Set Value = Subscript(Value, OtherValue)
End If
Else
Set Factor = Value
Exit Function
End If
Loop
Set Factor = Value
Exit Function
ParseFactor_ErrHandler:
SetErrSource "ParseFactor"
Err.Raise Err.Number
End Function
Private Function Element() As clsBox
'On Error GoTo ParseElement_ErrHandler
Dim Sign As String
Dim CurrToken As ParserTokens
Dim Value As clsBox
Sign = ""
CurrToken = GetToken
If CurrToken = TOK_SUBTRACT Then
Sign = "-"
SkipLastToken
ElseIf CurrToken = TOK_ADD Then
SkipLastToken
End If
CurrToken = GetToken
If CurrToken = TOK_OPEN_PARENTHESES Then
SkipLastToken
Set Value = Bracket(Expression)
CurrToken = GetToken
If CurrToken = TOK_CLOSE_PARENTHESES Then
SkipLastToken
Else
Err.Raise PERR_CLOSING_PARENTHESES_EXPECTED, , "')' Expected"
End If
Else
Set Value = Atom
End If
If Sign = "" Then
Set Element = Value
Else
Set Element = Concat2(Text("-"), Value)
End If
Exit Function
ParseElement_ErrHandler:
SetErrSource "Element"
Err.Raise Err.Number
End Function
Private Function Atom() As clsBox
'On Error GoTo ParseAtom_ErrHandler
Dim CurrPosition As Long
Dim CurrToken As ParserTokens
Dim Value As clsBox
Dim st As String
Dim i, j, k As Long
Dim ArgumentValue As clsBox
Dim ArgList() As clsBox
Dim nArg As Long
If mPosition > Len(mExpression) Then
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
CurrPosition = mPosition
If IsAlpha(Mid(mExpression, CurrPosition, 1)) Then
CurrPosition = CurrPosition + 1
Do While IsAlpha(Mid(mExpression, CurrPosition, 1))
CurrPosition = CurrPosition + 1
Loop
st = Mid(mExpression, mPosition, CurrPosition - mPosition)
mPosition = CurrPosition
SkipSpaces
CurrToken = GetToken
If CurrToken = TOK_OPEN_PARENTHESES Then
SkipLastToken
nArg = 0
Do While CurrPosition <= Len(mExpression)
Set ArgumentValue = Expression
nArg = nArg + 1
ReDim Preserve ArgList(1 To nArg)
Set ArgList(nArg) = ArgumentValue
CurrToken = GetToken
If CurrToken = TOK_CLOSE_PARENTHESES Then
SkipLastToken
Exit Do
ElseIf CurrToken = TOK_LIST_SEPERATOR Then
SkipLastToken
Else
Err.Raise PERR_CLOSING_PARENTHESES_EXPECTED
End If
Loop
Set Value = ParseFunction(st, ArgList, nArg)
Else
Set Value = Text(st)
mPosition = CurrPosition
SkipSpaces
End If
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Set Atom = Value
Exit Function
ParseAtom_ErrHandler:
SetErrSource "ParseAtom"
Err.Raise Err.Number
End Function
'Get current tocken and set length of that tocken
Private Function GetToken() As ParserTokens
Dim CurrToken As ParserTokens
Dim i As ParserTokens
If mPosition > Len(mExpression) Then
GetToken = TOK_UNKNOWN
Exit Function
End If
CurrToken = TOK_UNKNOWN
mLastTokenLength = 0
For i = TOK_FIRST To TOK_LAST
If Mid(mExpression, mPosition, Len(mTokenSymbols(i))) = mTokenSymbols(i) Then
CurrToken = i
mLastTokenLength = Len(mTokenSymbols(i))
Exit For
End If
Next
GetToken = CurrToken
End Function
Private Function ParseFunction(ByVal strTockenName As String, ArgList() As clsBox, ByVal nArg As Long) As clsBox
Dim v As clsBox
Dim v1 As clsBox
Dim i As Long
Dim t1 As clsText
Dim t2 As clsText
Select Case UCase(strTockenName)
Case "SQRT":
Set v = Root(ArgList(1))
Case "SUM"
If nArg = 1 Then
Set v = Sum(Nothing, Nothing, ArgList(1))
ElseIf nArg = 2 Then
Set v = Sum(ArgList(2), Nothing, ArgList(1))
ElseIf nArg = 3 Then
Set v = Sum(ArgList(2), ArgList(3), ArgList(1))
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "PROD"
If nArg = 1 Then
Set v = Prod(Nothing, Nothing, ArgList(1))
ElseIf nArg = 2 Then
Set v = Prod(ArgList(2), Nothing, ArgList(1))
ElseIf nArg = 3 Then
Set v = Prod(ArgList(2), ArgList(3), ArgList(1))
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "UNI"
If nArg = 1 Then
Set v = Uni(Nothing, Nothing, ArgList(1))
ElseIf nArg = 2 Then
Set v = Uni(ArgList(2), Nothing, ArgList(1))
ElseIf nArg = 3 Then
Set v = Uni(ArgList(2), ArgList(3), ArgList(1))
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "INT":
If nArg = 2 Then
Set v = InInt(Nothing, Nothing, Concat2(ArgList(1), ArgList(2)))
ElseIf nArg = 4 Then
Set v = InInt(ArgList(3), ArgList(4), Concat2(ArgList(1), ArgList(2)))
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "OVER"
Set v = Over(ArgList(1))
Case "VECTOR"
Set v = Vector(ArgList(1))
Case "ABS"
Set v = ABSFunc(ArgList(1))
Case "ANG"
Set v = Ang(ArgList(1))
Case "ARC"
Set v = Arc(ArgList(1))
Case "COMB"
Set v = ArgList(1)
For i = 2 To nArg
Set v = Concat2(v, ArgList(i))
Next
Case "MATRIX", "DET", "NMATRIX"
If nArg > 2 Then
If ArgList(1).ClassName = "text" And ArgList(2).ClassName = "text" Then
Set t1 = ArgList(1)
Set t2 = ArgList(2)
If UCase(strTockenName) = "DET" Then
Set v = Matrix(nArg, CLng(t1.Text), CLng(t2.Text), ArgList, True)
ElseIf UCase(strTockenName) = "NMATRIX" Then
Set v = Matrix(nArg, CLng(t1.Text), CLng(t2.Text), ArgList, False, False)
Else
Set v = Matrix(nArg, CLng(t1.Text), CLng(t2.Text), ArgList)
End If
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "EQU"
If nArg > 1 Then
If ArgList(1).ClassName = "text" Then
Set t1 = ArgList(1)
Set v = Equation(nArg, CLng(t1.Text), ArgList)
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case "LIM"
If nArg >= 2 Then
Set v = Lim(ArgList(1), ArgList(2))
ElseIf nArg = 1 Then
Set v = Lim(ArgList(1), Nothing)
Else
Err.Raise PERR_SYNTAX_ERROR, , GENERIC_SYNTAX_ERR_MSG
End If
Case Else
Set v1 = ArgList(1)
For i = 2 To nArg
Set v1 = Concat3(v1, Text(","), ArgList(i))
Next
Set v = Concat2(Text(strTockenName), Bracket(v1))
End Select
Set ParseFunction = v
End Function
'Bypassing current tocken
Private Sub SkipLastToken()
mPosition = mPosition + mLastTokenLength
SkipSpaces
End Sub
'Bypassin all spaces
Private Sub SkipSpaces()
Do While mPosition <= Len(mExpression) And _
(Mid(mExpression, mPosition, 1) = " " Or _
Mid(mExpression, mPosition, 1) = vbTab Or Mid(mExpression, mPosition, 1) = vbCr Or Mid(mExpression, mPosition, 1) = vbLf)
mPosition = mPosition + 1
Loop
End Sub
Private Function IsAlpha(ByVal ch As String)
Const ALPHASET = "&;:.[]!0123456789abcdefghijklmnopqrstuvwxyz"
ch = LCase(ch)
IsAlpha = ch <> "" And InStr(ALPHASET, ch) > 0
End Function
Private Function GetProjectName() As String
On Error Resume Next
Err.Raise 1, , " "
GetProjectName = Err.Source
Err.Clear
End Function
Private Sub SetErrSource(Name As String)
If Err.Source = mProjectName Then
Err.Source = Name
Else
Err.Source = Name & "->" & Err.Source
End If
End Sub
Public Property Get LastErrorPosition() As Long
LastErrorPosition = mPosition
End Property
Public Sub Initialize()
Dim i As Long
ReDim mTokenSymbols(TOK_FIRST To TOK_LAST)
mTokenSymbols(TOK_PM) = "+-"
mTokenSymbols(TOK_ADD) = "+"
mTokenSymbols(TOK_MP) = "-+"
mTokenSymbols(TOK_SUBTRACT) = "-"
mTokenSymbols(TOK_MULTIPLY) = "*"
mTokenSymbols(TOK_EQUAL) = "="
mTokenSymbols(TOK_DIVIDE) = "/"
mTokenSymbols(TOK_POWER) = "^"
mTokenSymbols(TOK_SUBSCRIPT) = "_"
mTokenSymbols(TOK_OPEN_PARENTHESES) = "("
mTokenSymbols(TOK_CLOSE_PARENTHESES) = ")"
mTokenSymbols(TOK_LIST_SEPERATOR) = ","
mTokenSymbols(TOK_DIFF) = "<>"
mTokenSymbols(TOK_LESS) = "<"
mTokenSymbols(TOK_LEQ) = "<="
mTokenSymbols(TOK_GRE) = ">"
mTokenSymbols(TOK_GEQ) = ">="
mTokenSymbols(TOK_AND) = "∧"
mTokenSymbols(TOK_or) = "∨"
ReDim mMathSymbols(1 To MAX_SYMBOLS)
For i = 1 To MAX_SYMBOLS
mMathSymbols(i).nFontIndex = 1
Next
mMathSymbols(1).strEntity = "α"
mMathSymbols(1).nCode = &H2C
mMathSymbols(2).strEntity = "β"
mMathSymbols(2).nCode = &H2D
mMathSymbols(3).strEntity = "χ"
mMathSymbols(3).nCode = &H41
mMathSymbols(4).strEntity = "δ"
mMathSymbols(4).nCode = &H2F
mMathSymbols(5).strEntity = "ε"
mMathSymbols(5).nCode = &H30
mMathSymbols(6).strEntity = "φ"
mMathSymbols(6).nCode = &H40
mMathSymbols(7).strEntity = "ϕ"
mMathSymbols(7).nCode = &H49
mMathSymbols(8).strEntity = "γ"
mMathSymbols(8).nCode = &H2E
mMathSymbols(9).strEntity = "η"
mMathSymbols(9).nCode = &H32
mMathSymbols(10).strEntity = "κ"
mMathSymbols(10).nCode = &H35
mMathSymbols(11).strEntity = "&lamda;"
mMathSymbols(11).nCode = &H36
mMathSymbols(12).strEntity = "μ"
mMathSymbols(12).nCode = &H37
mMathSymbols(13).strEntity = "ν"
mMathSymbols(13).nCode = &H38
mMathSymbols(14).strEntity = "π"
mMathSymbols(14).nCode = &H3B
mMathSymbols(15).strEntity = "ϖ"
mMathSymbols(15).nCode = &H46
mMathSymbols(16).strEntity = "θ"
mMathSymbols(16).nCode = &H33
mMathSymbols(17).strEntity = "ρ"
mMathSymbols(17).nCode = &H3C
mMathSymbols(18).strEntity = "σ"
mMathSymbols(18).nCode = &H3D
mMathSymbols(19).strEntity = "&finalsigma;"
mMathSymbols(19).nCode = &H48
mMathSymbols(20).strEntity = "τ"
mMathSymbols(20).nCode = &H3E
mMathSymbols(21).strEntity = "υ"
mMathSymbols(21).nCode = &H3F
mMathSymbols(22).strEntity = "ω"
mMathSymbols(22).nCode = &H43
mMathSymbols(23).strEntity = "ξ"
mMathSymbols(23).nCode = &H39
mMathSymbols(24).strEntity = "&pxi;"
mMathSymbols(24).nCode = &H42
mMathSymbols(25).strEntity = "ζ"
mMathSymbols(25).nCode = &H31
mMathSymbols(26).strEntity = "ο"
mMathSymbols(26).nCode = &H3A
mMathSymbols(27).strEntity = "Α"
mMathSymbols(27).nCode = &H63
mMathSymbols(28).strEntity = "Β"
mMathSymbols(28).nCode = &H64
mMathSymbols(29).strEntity = "Χ"
mMathSymbols(29).nCode = &H7A
mMathSymbols(30).strEntity = "Δ"
mMathSymbols(30).nCode = &H22
mMathSymbols(31).strEntity = "Ε"
mMathSymbols(31).nCode = &H67
mMathSymbols(32).strEntity = "Φ"
mMathSymbols(32).nCode = &H29
mMathSymbols(33).strEntity = "Γ"
mMathSymbols(33).nCode = &H21
mMathSymbols(34).strEntity = "Η"
mMathSymbols(34).nCode = &H6A
mMathSymbols(35).strEntity = "Ι"
mMathSymbols(35).nCode = &H6B
mMathSymbols(36).strEntity = "Κ"
mMathSymbols(36).nCode = &H6D
mMathSymbols(37).strEntity = "&Lamda;"
mMathSymbols(37).nCode = &H24
mMathSymbols(38).strEntity = "Μ"
mMathSymbols(38).nCode = &H6F
mMathSymbols(39).strEntity = "Ν"
mMathSymbols(39).nCode = &H70
mMathSymbols(40).strEntity = "Ο"
mMathSymbols(40).nCode = &H71
mMathSymbols(41).strEntity = "Π"
mMathSymbols(41).nCode = &H26
mMathSymbols(42).strEntity = "Θ"
mMathSymbols(42).nCode = &H23
mMathSymbols(43).strEntity = "Ρ"
mMathSymbols(43).nCode = &H72
mMathSymbols(44).strEntity = "Σ"
mMathSymbols(44).nCode = &H27
mMathSymbols(45).strEntity = "Τ"
mMathSymbols(45).nCode = &H76
mMathSymbols(46).strEntity = "Υ"
mMathSymbols(46).nCode = &H28
mMathSymbols(47).strEntity = "Ω"
mMathSymbols(47).nCode = &H2B
mMathSymbols(48).strEntity = "Ξ"
mMathSymbols(48).nCode = &H25
mMathSymbols(49).strEntity = "Ψ"
mMathSymbols(49).nCode = &H2A
mMathSymbols(50).strEntity = "Ζ"
mMathSymbols(50).nCode = &H7C
mMathSymbols(51).strEntity = "&infinity;"
mMathSymbols(51).nCode = &H54
For i = 51 To 83
mMathSymbols(i).nFontIndex = 2
Next
mMathSymbols(52).strEntity = "∧"
mMathSymbols(52).nCode = &H82
mMathSymbols(53).strEntity = "∨"
mMathSymbols(53).nCode = &H83
mMathSymbols(54).strEntity = "&larrow;"
mMathSymbols(54).nCode = &H43
mMathSymbols(55).strEntity = "&rarrow;"
mMathSymbols(55).nCode = &H44
mMathSymbols(56).strEntity = "&uarrow;"
mMathSymbols(56).nCode = &H45
mMathSymbols(57).strEntity = "&darrow;"
mMathSymbols(57).nCode = &H46
mMathSymbols(58).strEntity = "&lrarrow;"
mMathSymbols(58).nCode = &H47
mMathSymbols(59).strEntity = "&larrowd;"
mMathSymbols(59).nCode = &H4B
mMathSymbols(60).strEntity = "&rarrowd;"
mMathSymbols(60).nCode = &H4C
mMathSymbols(61).strEntity = "&uarrowd;"
mMathSymbols(61).nCode = &H4D
mMathSymbols(62).strEntity = "&darrowd;"
mMathSymbols(62).nCode = &H4E
mMathSymbols(63).strEntity = "&lrarrowd;"
mMathSymbols(63).nCode = &H4F
mMathSymbols(64).strEntity = "&urarrow;"
mMathSymbols(64).nCode = &H48
mMathSymbols(65).strEntity = "&drarrow;"
mMathSymbols(65).nCode = &H49
mMathSymbols(66).strEntity = "⊥"
mMathSymbols(66).nCode = &H62
mMathSymbols(67).strEntity = "∥"
mMathSymbols(67).nCode = &H8F
mMathSymbols(68).strEntity = "∅"
mMathSymbols(68).nCode = &H5E
mMathSymbols(69).strEntity = "∈"
mMathSymbols(69).nCode = &H55
mMathSymbols(70).strEntity = "&any;"
mMathSymbols(70).nCode = &H5B
mMathSymbols(71).strEntity = "∃"
mMathSymbols(71).nCode = &H5C
mMathSymbols(72).strEntity = "⊂"
mMathSymbols(72).nCode = &H3D
mMathSymbols(73).strEntity = "⊃"
mMathSymbols(73).nCode = &H3E
mMathSymbols(74).strEntity = "&vdots;"
mMathSymbols(74).nCode = &HB4
mMathSymbols(75).strEntity = "&lor;"
mMathSymbols(75).nCode = &H83
mMathSymbols(76).strEntity = "&land;"
mMathSymbols(76).nCode = &H82
mMathSymbols(77).strEntity = "≈"
mMathSymbols(77).nCode = &H3C
mMathSymbols(78).strEntity = "≡"
mMathSymbols(78).nCode = &H34
mMathSymbols(79).strEntity = "∝"
mMathSymbols(79).nCode = &H52
mMathSymbols(80).strEntity = "∼"
mMathSymbols(80).nCode = &H3B
mMathSymbols(81).strEntity = "≪"
mMathSymbols(81).nCode = &H3F
mMathSymbols(82).strEntity = "≫"
mMathSymbols(82).nCode = &H40
mMathSymbols(83).strEntity = "≃"
mMathSymbols(83).nCode = &H4A
ReDim mMathOPs(1 To MAX_MATHOP)
For i = 1 To MAX_MATHOP
mMathOPs(i).nFontIndex = 2
Next
mMathOPs(1).strOP = "+"
mMathOPs(1).nCode = &H21
mMathOPs(2).strOP = "="
mMathOPs(2).nCode = &H22
mMathOPs(3).strOP = "-"
mMathOPs(3).nCode = &H23
mMathOPs(4).strOP = "*"
mMathOPs(4).nCode = &H25
mMathOPs(5).strOP = "<="
mMathOPs(5).nCode = &HD4
mMathOPs(5).nFontIndex = 1
mMathOPs(6).strOP = ">="
mMathOPs(6).nCode = &HD5
mMathOPs(6).nFontIndex = 1
mMathOPs(7).strOP = "+-"
mMathOPs(7).nCode = &H29
mMathOPs(8).strOP = "-+"
mMathOPs(8).nCode = &H2A
mMathOPs(9).strOP = "<"
mMathOPs(9).nCode = &H5E
mMathOPs(9).nFontIndex = 1
mMathOPs(10).strOP = ">"
mMathOPs(10).nCode = &H60
mMathOPs(10).nFontIndex = 1
mMathOPs(11).strOP = "<>"
mMathOPs(11).nCode = &H22
mProjectName = GetProjectName
End Sub
'***************************************************************************
'Helper function to create a concatation with 2 factors
'***************************************************************************
Private Function Concat2(ByVal p1 As clsBox, ByVal p2 As clsBox) As clsConcat
Dim c As New clsConcat
c.NumberElement = 2
Set c.Part(1) = p1
Set c.Part(2) = p2
Set Concat2 = c
End Function
'****************************************************************************
'Helper function to create a concatation with 3 factors
'****************************************************************************
Private Function Concat3(ByVal p1 As clsBox, ByVal p2 As clsBox, ByVal p3 As clsBox) As clsConcat
Dim c As New clsConcat
c.NumberElement = 3
Set c.Part(1) = p1
Set c.Part(2) = p2
Set c.Part(3) = p3
Set Concat3 = c
End Function
'*****************************************************************************
'Helper function to create a concatation with 4 factors
'*****************************************************************************
Private Function Concat4(ByVal p1 As clsBox, ByVal p2 As clsBox, ByVal p3 As clsBox, ByVal p4 As clsBox) As clsConcat
Dim c As New clsConcat
c.NumberElement = 4
Set c.Part(1) = p1
Set c.Part(2) = p2
Set c.Part(3) = p3
Set c.Part(4) = p4
Set Concat4 = c
End Function
'******************************************************************************
'Helper function to create an atom factor(text object)
'******************************************************************************
Private Function Text(ByVal st As String) As clsText
Dim t As New clsText
t.Text = st
Set Text = t
End Function
'******************************************************************************
'Helper function to create a fraction
'******************************************************************************
Private Function Fraction(ByVal nu As clsBox, ByVal de As clsBox) As clsFraction
Dim f As New clsFraction
Set f.Numerator = nu
Set f.Denominator = de
Set Fraction = f
End Function
'*******************************************************************************
'Helper function to create an expression width brackets
'*******************************************************************************
Private Function Bracket(ByVal c As clsBox) As clsBracket
Dim b As New clsBracket
Set b.Content = c
Set Bracket = b
End Function
'*********************************************************************************
'Helper function to create a over operator
'*********************************************************************************
Private Function Over(ByVal c As clsBox) As clsOver
Dim o As New clsOver
Set o.Content = c
Set Over = o
End Function
'*********************************************************************************
'Helper function to create a power operator
'*********************************************************************************
Private Function Power(ByVal l As clsBox, ByVal r As clsBox) As clsPower
Dim p As New clsPower
Set p.Left = l
Set p.Right = r
Set Power = p
End Function
'***********************************************************************************
'Helper function to create a subscript expression
'***********************************************************************************
Private Function Subscript(ByVal b As clsBox, ByVal s As clsBox) As clsSubscript
Dim ss As New clsSubscript
Set ss.Base = b
Set ss.Subscript = s
Set Subscript = ss
End Function
'***********************************************************************************
'Helper function to create a root expression
'***********************************************************************************
Private Function Root(ByVal c As clsBox) As clsRoot
Dim r As New clsRoot
Set r.Content = c
Set Root = r
End Function
'***********************************************************************************
'Helper function to create a sum expression
'***********************************************************************************
Private Function Sum(ByVal b As clsBox, ByVal t As clsBox, ByVal c As clsBox) As clsISPU
Dim s As New clsISPU
Set s.Upper = t
Set s.Lower = b
Set s.Content = c
s.Sign = Chr(SUM_SIGN)
Set Sum = s
End Function
'***********************************************************************************
'Helper function to create a Integral expression
'***********************************************************************************
Private Function InInt(ByVal b As clsBox, ByVal t As clsBox, ByVal c As clsBox) As clsISPU
Dim i As New clsISPU
Set i.Upper = t
Set i.Lower = b
Set i.Content = c
i.Sign = Chr(INT_SIGN)
Set InInt = i
End Function
'***********************************************************************************
'Helper function to create a product expression
'***********************************************************************************
Private Function Prod(ByVal b As clsBox, ByVal t As clsBox, ByVal c As clsBox) As clsISPU
Dim i As New clsISPU
Set i.Upper = t
Set i.Lower = b
Set i.Content = c
i.Sign = Chr(PROD_SIGN)
Set Prod = i
End Function
'***********************************************************************************
'Helper function to create a union expression
'***********************************************************************************
Private Function Uni(ByVal b As clsBox, ByVal t As clsBox, ByVal c As clsBox) As clsISPU
Dim i As New clsISPU
Set i.Upper = t
Set i.Lower = b
Set i.Content = c
i.Sign = Chr(UNI_SIGN)
Set Uni = i
End Function
'***********************************************************************************
'Helper function to create a matrix expression
'***********************************************************************************
Private Function Matrix(ByVal nMax As Long, ByVal m As Long, ByVal n As Long, ElmList() As clsBox, Optional ByVal bDet As Boolean = False, Optional ByVal bBracket As Boolean = True) As clsBox
Dim mx As New clsMatrix
Dim i As Long, j As Long, k As Long
mx.CreateMatrix m, n
mx.IsDet = bDet
mx.IsBracket = bBracket
For i = 1 To m
For j = 1 To n
k = (i - 1) * n + j + 2
If k > nMax Then
Set mx.Element(i, j) = Text(".")
Else
Set mx.Element(i, j) = ElmList((i - 1) * n + j + 2)
End If
Next
Next
Set Matrix = mx
End Function
'***********************************************************************************
'Helper function to create an equation expression
'***********************************************************************************
Private Function Equation(ByVal nMax As Long, ByVal n As Long, EQ() As clsBox) As clsEquations
Dim e As New clsEquations
Dim i As Long
e.CreateEquation n
For i = 1 To n
If i + 1 > nMax Then
Set e.Equation(i) = Text(" ")
Else
Set e.Equation(i) = EQ(i + 1)
End If
Next
Set Equation = e
End Function
'***********************************************************************************
'Helper function to create a vector expression
'***********************************************************************************
Private Function Vector(box As clsBox) As clsOver
Dim o As New clsOver
o.OverStyle = OVER_VECTOR
Set o.Content = box
Set Vector = o
End Function
'***********************************************************************************
'Helper function to create a abs expression
'***********************************************************************************
Private Function ABSFunc(box As clsBox) As clsOver
Dim o As New clsOver
o.OverStyle = OVER_ABS
Set o.Content = box
Set ABSFunc = o
End Function