This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoGdmath/InsereExpression.xba is in libreoffice-dmaths 3.4+dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="InsereExpression" script:language="StarBasic">&apos;OOoGdmath
&apos;Copyright (C) 2005-2009  Gilles Daurat

&apos;This program is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public License
&apos;as published by the Free Software Foundation; either version 2
&apos;of the License, or (at your option) any later version.

&apos;This program is distributed in the hope that it will be useful,
&apos;but WITHOUT ANY WARRANTY; without even the implied warranty of
&apos;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
&apos;GNU General Public License for more details.

&apos;You should have received a copy of the GNU General Public License
&apos;along with this program; if not, write to the Free Software
&apos;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

option explicit
public oDoc as object
Private Coperande(0 To 50) As String
Private Coperateur(0 To 50) As String
Private DeltaExposant As Integer
Private NiveauExposant As Integer
Private oi As Single
Private ni As Single

Sub Main()
	InsereExpression(ThisComponent)
End Sub

Function InsereEquation(oDoc) as Object
	dim odocument   as object
	dim odispatcher as object
	dim oEquation as Object
	dim lesObjets as Object
	dim i
	
	odocument   = oDoc.getcurrentController().Frame
	odispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)

	odispatcher.executeDispatch(odocument, &quot;.uno:InsertObjectStarMath&quot;, &quot;&quot;, 0, Array())
	odispatcher.executeDispatch(odocument, &quot;.uno:Escape&quot;, &quot;&quot;, 0, Array())
	
	lesObjets= oDoc.EmbeddedObjects
	For i=0 to lesObjets.Count-1
		if lesObjets(i).supportsService(&quot;com.sun.star.text.TextEmbeddedObject&quot;) then
			if (lesObjets(i).embeddedObject.supportsService(&quot;com.sun.star.formula.FormulaProperties&quot;)) then InsereEquation=lesObjets(i)
		end if
	next i
End Function

Sub SelectionneExpression(oDoc as Object)
dim Texte as string
Dim AncienTexte as string 
dim oViewCursor as Object, oText as object

	oViewCursor = oDoc.getcurrentcontroller().getViewCursor()
	oText=oDoc.Text
	Texte=&quot;&quot;
	do
		AncienTexte=Texte
		oViewCursor.goleft(1,True)
		Texte=oViewCursor.getString()
		dim a,b
		if Texte&lt;&gt;&quot;&quot; then a=(asc(left(Texte,1))&lt;&gt;13) else a=False
		b=(left(Texte,1)&lt;&gt;&quot; &quot;)
	Loop While ((Texte&lt;&gt;AncienTexte) and a and b)
	if (Texte&lt;&gt;AncienTexte) then 
		oViewCursor.goright(1,true)
	end if
End sub

Function RemplaceTexteSelectionne(texte as string) as boolean
  Dim oSelections As Object, oSel As Object, oText As Object
  Dim lSelCount As Long, lWhichSelection As Long
  &apos; The current selection in the current controller. 
  &apos;If there is no current controller, it returns NULL.
  oSelections = ThisComponent.getCurrentSelection()
  If Not IsNull(oSelections) Then
    oText = ThisComponent.Text
    lSelCount = oSelections.getCount()
    For lWhichSelection = 0 To lSelCount - 1
      oSel = oSelections.getByIndex(lWhichSelection)
      oSel.setString(texte)
    Next
  End If
  RemplaceTexteSelectionne=True
end function

Function RetourneTexteSelectionne(oDoc as Object) as string
  Dim oSelections As Object, oSel As Object, oText As Object
  Dim lSelCount As Long, lWhichSelection As Long
  dim STexte as string
  &apos; The current selection in the current controller. 
  &apos;If there is no current controller, it returns NULL.
  oSelections = oDoc.getCurrentSelection()
  If Not IsNull(oSelections) Then
    oText = oDoc.Text
    lSelCount = oSelections.getCount()
    For lWhichSelection = 0 To lSelCount - 1
      oSel = oSelections.getByIndex(lWhichSelection)
      STexte=oSel.getString()
    Next
  End If
  RetourneTexteSelectionne=STexte
end function

Function IsAnythingSelected(oDoc As Object) As Boolean
  Dim oSelections As Object, oSel As Object, oText As Object, oCursor As Object
  IsAnythingSelected = False
  If IsNull(oDoc) Then 
  	Exit Function
  end if
  &apos; The current selection in the current controller. 
  &apos;If there is no current controller, it returns NULL.
  oSelections = oDoc.getCurrentSelection()
  If IsNull(oSelections) Then
  	Exit Function
  end if
  If oSelections.getCount() = 0 Then 
  	Exit Function
  end if
  If oSelections.getCount() &gt; 1 Then 
    IsAnythingSelected = True
  Else
    oSel = oSelections.getByIndex(0)
    oCursor = oDoc.Text.CreateTextCursorByRange(oSel)
    If Not oCursor.IsCollapsed() Then
    	IsAnythingSelected = True
    end if
  End If
End Function

Function InsereExpression(oDoc as Object) as object
dim Texte as string,Texte1 as string
dim TexteFonction
dim i as integer, a as integer, aa as integer
dim oCursor, oText

    If Not IsAnythingSelected(oDoc) Then
    	SelectionneExpression(oDoc)
    end if
    If IsAnythingSelected(oDoc) Then
    	Texte=RetourneTexteSelectionne(oDoc)
    	
        TexteFonction = Array(&quot;COS&quot;, &quot;SIN&quot;, &quot;TAN&quot;, &quot;RAC&quot;, &quot;EXP&quot;, &quot;LN&quot;, &quot;LOG&quot;, &quot;ABS&quot;, &quot;NOR&quot;, &quot;MES&quot;, &quot;VEC&quot;, &quot;BAR&quot;, &quot;INT&quot;, &quot;SOM&quot;, &quot;PRO&quot;, &quot;SYS&quot;, &quot;LIM&quot;, &quot;ANG&quot;)
        For i = 0 To 17
            a = InStr(1, Texte, TexteFonction(i))
            If a &lt;&gt; 0 Then
            	if i=5 then 
            		aa=a + 2
            	else
            		aa=a+3
            	end if
            		
                If aa &lt;= Len(Texte) Then
                    If InStr(1, &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, UCase(mid(Texte,aa,1))) &lt;&gt; 0 Then a = 0
                End If
            End If
            While (a &lt;&gt; 0)
                Texte=left(Texte,a-1) &amp; &quot;%&quot; &amp; mid(Texte,a)
                aa=a+len(TexteFonction(i))
                Texte1= left(Texte,aa)
                if i=5 then 
                	Texte1=Texte1 &amp; &quot;n&quot;
                end if
                Texte=Texte1 &amp; &quot;%&quot; &amp; mid(Texte,aa+1)
                a = InStr(aa, UCase(Texte), TexteFonction(i))
                If a &lt;&gt; 0 Then
                	if i=5 then 
                		aa=a + 2
                	else
                		aa=a+ 3
                	end if
                    If aa &lt;= Len(Texte) Then
                        If InStr(1, &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, UCase(mid(Texte,aa,1))) &lt;&gt; 0 Then 
                        	a = 0
                        end if
                    End If
                End If
            Wend
        Next i
		oCursor = oDoc.currentcontroller.getViewCursor()
		oText=oDoc.Text
		oText.insertString(oCursor,CalculeExpression(Texte),True)
		InsereExpression = InsereEquation(oDoc)
    Else
        MsgBoxP &quot;message5&quot;
    End If
End Function

Sub SupprimeEspace(texte$)
dim i,j
dim c as string

    i = Len(texte$)
    j = 1
    Do
        Select Case Mid(texte$, j, 1)
        Case &quot; &quot;, Chr$(160)
            texte$ = Left$(texte$, j - 1) &amp; Right$(texte$, Len(texte$) - j)
        Case &quot;$&quot;
            Do
                j = j + 1
                i = i - 1
                c = Mid$(texte$, j, 1)
            Loop While (c &lt;&gt; &quot;$&quot;) And (j &lt; 1000)
            j = j + 1
        Case Else
            j = j + 1
        End Select
        i = i - 1
    Loop While (i &gt; 0)
End Sub

Sub AjouteParentheses(texte, carac)
Dim a, variab

    a = InStr(1, texte, &quot;%&quot; &amp; carac)
    While (a &lt;&gt; 0)
        If a + 1 + len(carac) &lt;= Len(texte) Then
            variab = Mid$(texte, a + 1 + len(carac), 1)
        Else
            variab = &quot;?&quot;
        End If
        If InStr(1, &quot;abcdefghijklmnopqrstuvwxyz&quot;, variab) &lt;&gt; 0 Then
            texte = Left(texte, a + 1) &amp; &quot;(&quot; &amp; variab &amp; &quot;)&quot; &amp; Right(texte, Len(texte) - a - 2)
        Else
            If variab = &quot;\&quot; Then
                j = a + 3
                i = j
                While (j &lt;= Len(texte)) And (InStr(1, &quot;abcdefghijklmnopqrstuvwxyz&quot;, Mid$(texte, j, 1)) &lt;&gt; 0)
                    j = j + 1
                Wend
                texte = Left(texte, a + 1) &amp; &quot;(\&quot; &amp; Mid(texte, i, j - i) &amp; &quot;)&quot; &amp; Right(texte, Len(texte) + 1 - j)
            End If
        End If
        a = InStr(a + 1, texte, &quot;%&quot; &amp; carac)
    Wend
End Sub

Function CalculeExpression(texte as string ) as String
Dim nombre, i, a, c, ai, cuf, LeChamp$, ii, Delimit, cp, ca
Dim ccs as string, cs as string, TheTest as Boolean, voperande$, b, aa, bb
Dim j, k, cc
Dim espace3 as string, espace4 as string, espace1 as string, espace2 as string

    espace3=&quot; &quot;
    espace4=&quot; &quot;

If texte &lt;&gt; &quot;&quot; Then
    Call AjouteParentheses(texte, &quot;cos&quot;)
    Call AjouteParentheses(texte, &quot;sin&quot;)
    Call AjouteParentheses(texte, &quot;tan&quot;)
    Call AjouteParentheses(texte, &quot;rac&quot;)
    Call AjouteParentheses(texte, &quot;exp&quot;)
    Call AjouteParentheses(texte, &quot;lnn&quot;)
    Call AjouteParentheses(texte, &quot;log&quot;)
    Call AjouteParentheses(texte, &quot;abs&quot;)
    Call AjouteParentheses(texte, &quot;nor&quot;)
    Call AjouteParentheses(texte, &quot;mes&quot;)

    nombre = &quot;&quot;
    ni = 0
    oi = 0
    NiveauExposant = 4
    For i = 1 To Len(texte)
        c = Mid$(texte, i, 1)
        If c = &quot;%&quot; Then
            ai = i + 1
            a = InStr(i + 1, texte, &quot;%&quot;)
            c = Mid(texte, i + 1, a - i - 1)
            Select Case UCase(c)
            Case &quot;LNN&quot;
                c = &quot;n&quot;
            Case &quot;LOG&quot;
                c = &quot;g&quot;
            Case &quot;SOM&quot;
                c = &quot;x&quot;
            Case &quot;SYS&quot;
                c = &quot;y&quot;
            Case &quot;LIM&quot;
                c = &quot;j&quot;
            Case &quot;ANG&quot;
                c = &quot;h&quot;
            Case Else
                c = Left(c, 1)
            End Select
            i = a
        End If
        If c &lt;&gt; &quot;%&quot; Then
            If (InStr(1, &quot;()[]ƒ;=:+-*/^cCsStTrReElLgGAaMmNnVvBbIiXxPpYyJjHh$.,&quot;, c) = 0 Or ((nombre = &quot; &quot; Or nombre = &quot;&quot; Or Right(nombre, 1) = &quot;.&quot;) And c = &quot;.&quot;) Or (CestUnNombre(nombre) And c = &quot;,&quot;)) Or ((InStr(1, &quot;cCsStTrReElLgGAaMmNnVvBbIiXxPpYyJjHh&quot;, c) &lt;&gt; 0) And MIIf(i = Len(texte), True, (InStr(1, &quot;([&quot;, Mid$(texte, i + 1, 1)) = 0))) Then
                If c = Chr(34) Then
                    a = InStr(i + 1, texte, Chr(34))
                    If a &lt;&gt; 0 Then
                        nombre = nombre + Mid(texte, i + 1, a - i - 1)
                        i = a
                    End If
                Else
                    If Left(nombre, 1) = &quot;*&quot; And c &lt;&gt; &quot; &quot; Then
                        nombre = &quot;&quot;
                    End If
                    nombre = nombre + c
                End If
            Else
                If nombre &lt;&gt; &quot;&quot; And Left(nombre, 1) &lt;&gt; &quot;*&quot; And nombre &lt;&gt; &quot; &quot; Then
                    Coperande(ni) = FormatTexte(i - Len(nombre), nombre) + nombre
                    SupprimeEspaceOperandeDroite Coperande(ni)
                    SupprimeEspaceOperandeGauche Coperande(ni)
                    ni = ni + 1
                    nombre = &quot;*&quot;
                End If
                If c = &quot;-&quot; And (Left(nombre, 1) &lt;&gt; &quot;*&quot; Or nombre = &quot; &quot;) Then
                    Coperateur(oi) = FormatTexte(i - 1, &quot; O &quot;) + &quot; O &quot;
                    nombre = &quot;&quot;
                    oi = oi + 1
                Else
                    If c = &quot;+&quot; And (Left(nombre, 1) &lt;&gt; &quot;*&quot; Or nombre = &quot; &quot;) Then
                        Coperateur(oi) = FormatTexte(i - 1, &quot; K &quot;) + &quot; K &quot;
                        oi = oi + 1
                        nombre = &quot;&quot;
                    Else
                        If c = &quot;+&quot; Or c = &quot;-&quot; Then
                            &apos; il faut calculer l&apos;operation precedente
                            &apos; et prendre l&apos;oppose si necessaire
                            If oi &gt; 0 Then
                                Do While (InStr(1, &quot;[(=)]&quot;, ROperateur(Coperateur(oi - 1))) = 0)
                                    InsereOperation
                                    If oi = 0 Then Exit Do
                                Loop
                            End If
                            Coperateur(oi) = FormatTexte(i - 1, &quot; &quot; + c + &quot; &quot;) + &quot; &quot; + c + &quot; &quot;
                            oi = oi + 1
                            nombre = &quot;&quot;
                            NiveauExposant = 4
                        End If
                    End If
                End If
                Select Case UCase(c)
                    Case &quot;:&quot;
                        If oi &gt; 0 Then
                            If InStr(1, Chr(34) + &quot;:cCsStTrReElLgGAaMmNnVvBbIiXxPpYyJj$&quot;, ROperateur(Coperateur(oi - 1))) &lt;&gt; 0 Then InsereOperation
                        End If
                        Coperateur(oi) = FormatTexte(i - 1, &quot; &quot; + c + &quot; &quot;) + &quot; &quot; + c + &quot; &quot;
                        nombre = &quot;&quot;
                        oi = oi + 1
                    Case &quot;.&quot;, &quot;*&quot;, &quot;/&quot;, &quot;;&quot;, &quot;=&quot;, &quot;ƒ&quot;, &quot;,&quot;
                        If oi &gt; 0 Then
                            Do While NiveauPriorite(ROperateur(Coperateur(oi - 1))) &gt; NiveauPriorite(c)
                                InsereOperation
                                If oi = 0 Then Exit Do
                            Loop
                        End If
                        Coperateur(oi) = FormatTexte(i - 1, &quot; &quot; + c + &quot; &quot;) + &quot; &quot; + c + &quot; &quot;
                        nombre = &quot;&quot;
                        oi = oi + 1
                        NiveauExposant = 4
                    Case &quot;^&quot;
                        If oi &gt; 0 Then
                            Do While NiveauPriorite(ROperateur(Coperateur(oi - 1))) &gt;= NiveauPriorite(c)
                                InsereOperation
                                If oi = 0 Then Exit Do
                            Loop
                        End If
                        Coperateur(oi) = FormatTexte(i - 1, &quot; &quot; + c + &quot; &quot;) + &quot; &quot; + c + &quot; &quot;
                        nombre = &quot;&quot;
                        oi = oi + 1
                        NiveauExposant = 4
                    Case &quot;C&quot;, &quot;S&quot;, &quot;T&quot;, &quot;R&quot;, &quot;L&quot;, &quot;E&quot;, &quot;G&quot;, &quot;A&quot;, &quot;N&quot;, &quot;M&quot;, &quot;V&quot;, &quot;B&quot;, &quot;I&quot;, &quot;X&quot;, &quot;P&quot;, &quot;Y&quot;, &quot;J&quot;, &quot;H&quot;, &quot;$&quot;
                        cuf = False
                        If i &gt; 0 Then cuf = (Mid$(texte, i, 1) = &quot;%&quot;)
                        If c = &quot;$&quot; Then cuf = True
                        If cuf And (c = &quot;$&quot; Or Mid$(texte, i + 1, 1) = &quot;(&quot; Or Mid$(texte, i + 1, 1) = &quot;[&quot;) Then
                            If nombre = &quot;*&quot; Then
                                nombre = &quot;&quot;
                                If c = &quot;$&quot; Then
                                    Coperateur(oi) = FormatTexte(i, c) + &quot;..&quot;
                                Else
                                    Coperateur(oi) = FormatTexte(i, c) + &quot;.&quot;
                                End If
                                oi = oi + 1
                            Else
                                Coperateur(oi) = FormatTexte(ai, c) + c
                                nombre = &quot;&quot;
                                oi = oi + 1
                            End If
                            If c = &quot;$&quot; Then
                                LeChamp$ = &quot;&quot;
                                ii = i
                                Do
                                    i = i + 1
                                    c = Mid$(texte, i, 1)
                                    If c &lt;&gt; &quot;$&quot; Then LeChamp$ = LeChamp$ + c
                                Loop While (c &lt;&gt; &quot;$&quot;)
                                Coperande(ni) = FormatTexte(ii + 1, LeChamp$) + LeChamp$
                                ni = ni + 1
                            End If
                        Else
                            If nombre = &quot;*&quot; Then
                                Coperande(ni - 1) = Coperande(ni - 1) + c
                            Else
                                nombre = nombre + c
                            End If
                        End If
                    Case &quot;(&quot;, &quot;[&quot;, &quot;{&quot;
                        If nombre = &quot;*&quot; Then
                            nombre = &quot;&quot;
                            Coperateur(oi) = FormatTexte(i, c) + &quot;.&quot;
                            oi = oi + 1
                        End If
                        nombre = &quot;&quot;
                        Coperateur(oi) = FormatTexte(i, c + &quot; &quot;) + c + &quot; &quot;
                        oi = oi + 1
                        NiveauExposant = 4
                    Case &quot;)&quot;, &quot;]&quot;, &quot;}&quot;
                        Delimit = MIIf(c = &quot;)&quot;, &quot;(&quot;, MIif(c = &quot;]&quot;, &quot;[&quot;, &quot;{&quot;))
                        cp = &quot;$&quot;
                        ca = &quot;$&quot;
                        If oi &gt; 0 Then cp = ROperateur(Coperateur(oi - 1))
                        If oi &gt; 0 Then
                            Do While ROperateur(Coperateur(oi - 1)) &lt;&gt; Delimit
                                cp = ROperateur(Coperateur(oi - 1))
                                InsereOperation
                                If oi = 0 Then Exit Do
                            Loop
                            If oi &gt; 0 Then
                                Coperateur(oi - 1) = &quot;&quot;
                                oi = oi - 1
                            End If
                            if oi&gt;0 then
                            	if instr(1,&quot;vV&quot;, ROperateur(COperateur(oi-1))) then cp=ROperateur(COperateur(oi-1))
                            End if
                        End If
                        ccs = &quot;$&quot;
                        If oi &gt; 0 Then ca = ROperateur(Coperateur(oi - 1))
                        If i + 1 &lt;= Len(texte) Then ccs = Mid$(texte, i + 1, 1)
                        If ccs &lt;&gt; &quot;^&quot; And ccs &lt;&gt; &quot;/&quot; And ccs &lt;&gt; &quot;.&quot; Then If i + 2 &lt;= Len(texte) Then ccs = Mid$(texte, i + 2, 1)
                        If NiveauPriorite(ca) &gt;= NiveauPriorite(ccs) Or ca = &quot;y&quot; Then
                            cs = ca
                        Else
                            If NiveauPriorite(ccs) = 10 Then ccs = &quot;.&quot;
                            cs = ccs
                        End If
                        TheTest = (cp &lt;&gt; &quot;(&quot; Or cs = &quot;^&quot;) And (NiveauPrioritePar(cp) &lt;= NiveauPrioritePar(cs) And cp &lt;&gt; &quot;/&quot;) Or (cs = &quot;/&quot; And cp = &quot;^&quot;) Or (cp = &quot;/&quot; And cs = &quot;^&quot;)
                        a = InStr(1, Coperande(ni - 1), &quot;\g&quot;)
                        If a &lt;&gt; 0 Then
                            a = InStr(a + 2, Coperande(ni - 1), &quot;g&quot;)
                            a = InStr(a + 1, Coperande(ni - 1), &quot;g&quot;)
                            voperande$ = Right(Coperande(ni - 1), Len(Coperande(ni - 1)) - a)
                            SupprimeEspace voperande$
                        Else
                            voperande$ = Coperande(ni - 1)
                            SupprimeEspace voperande$
                        End If
                        If InStr(1, &quot;abcdefghijklmnopqrstuvwxyz&quot;, voperande$) &lt;&gt; 0 Then
                            SupprimeEspaceOperandeDroite Coperande(ni - 1)
                            SupprimeEspaceOperandeGauche Coperande(ni - 1)
                        End If
                        If (((cp = &quot;O&quot; Or cp = &quot;K&quot;) And cs &lt;&gt; &quot;/&quot;) Or TheTest Or (InStr(1, &quot;abcdefghijklmnopqrstuvwxyz&quot;, voperande$) &lt;&gt; 0 And cp = &quot;(&quot;)) And Not (InStr(1, &quot;abcdefghijklmnopqrstuvwxyz&quot;, voperande$) &lt;&gt; 0 And InStr(1, &quot;cslgt&quot;, LCase(cs)) &lt;&gt; 0) And InStr(1, &quot;reanmvbixpyjh&quot;, LCase(cs)) = 0 Then
                            If FractionDetectee(Coperande(ni - 1)) And InStr(1, &quot;ixpyj&quot;, cs) = 0 Then
                                Coperande(ni - 1) = &quot;left&quot; &amp; Delimit &amp; &quot;(&quot; &amp; espace1 &amp; Coperande(ni - 1) &amp; espace2 &amp; &quot;right&quot; &amp; c
                            Else
                                Coperande(ni - 1) = Delimit &amp; MIIf(FractionAGauche(Coperande(ni - 1)), espace4, espace3) &amp; Coperande(ni - 1) &amp; MIIf(FractionADroite(Coperande(ni - 1)), espace4, espace3) &amp; c
                            End If
                        Else
                            a = Asc(Left(voperande$, 1))
                            If (a = 45 Or a = 43) And cs &lt;&gt; &quot;/&quot; Then
                                If FractionDetectee(Coperande(ni - 1)) And InStr(1, &quot;ixpyj&quot;, cs) = 0 Then
                                    Coperande(ni - 1) = &quot;left&quot; &amp; Delimit &amp; espace1 &amp; Coperande(ni - 1) &amp; espace2 &amp; &quot;right&quot; &amp; c
                                Else
                                    Coperande(ni - 1) = Delimit &amp; MIIf(FractionAGauche(Coperande(ni - 1)), espace4, espace3) &amp; Coperande(ni - 1) &amp; MIIf(FractionADroite(Coperande(ni - 1)), espace4, espace3) &amp; c
                                End If
                            End If
                        End If
                        NiveauExposant = MIif(FractionDetectee(Coperande(ni - 1)), 8, 4)
                        nombre = &quot;*&quot;
                End Select
            End If
        End If
    Next i
    If nombre &lt;&gt; &quot;&quot; And nombre &lt;&gt; &quot;*&quot; And nombre &lt;&gt; &quot; &quot; Then
        If oi &gt; 0 Then
            If InStr(1, &quot;cstrleganmvbok&quot;, ROperateur(Coperateur(oi - 1))) &lt;&gt; 0 Then
                InsereOperation
            End If
        End If
        Coperande(ni) = FormatTexte(i - Len(nombre), nombre) + nombre
        SupprimeEspaceOperandeDroite Coperande(ni)
        SupprimeEspaceOperandeGauche Coperande(ni)
        ni = ni + 1
    End If
    While oi &gt; 0
        InsereOperation
    Wend
    For i = 1 To ni - 1
        Coperande(0) = Coperande(0) &amp; &quot; &quot; &amp; Coperande(i)
    Next i
    a = 0
    Do
        a = InStr(1, Coperande(0), &quot;\g&quot;)
        If a &lt;&gt; 0 Then
            a = a + 1
            b = InStr(a + 1, Coperande(0), &quot;g&quot;)
            cc = InStr(b + 1, Coperande(0), &quot;g&quot;)
            i = Val(Mid(Coperande(0), a + 1, b - a - 1))
            j = Val(Mid(Coperande(0), b + 1,cc - b - 1))
            COperande(0) = left(COperande(0),a-2) &amp; mid(COperande(0),cc+1)
        End If
    Loop While (a &lt;&gt; 0)
    CalculeExpression() = COperande(0)
   End if
End Function

Sub InsereOperation()
dim param() as string
dim a, FormatOperateur as string
dim espace1 as string, espace2 as string
dim espace3 as string, espace4 as string
dim fi,i,rac1,rac2
dim deb3

	espace1=&quot; &quot;
	espace2=&quot; &quot;
    If oi &gt; 0 Then
        a = InStr(1, Coperateur(oi - 1), &quot;\g&quot;)
        a = InStr(a + 2, Coperateur(oi - 1), &quot;g&quot;)
        a = InStr(a + 1, Coperateur(oi - 1), &quot;g&quot;)
        FormatOperateur = Left(Coperateur(oi - 1), a)
        Select Case UCase(ROperateur(Coperateur(oi - 1)))
            Case &quot;e&quot;,&quot;E&quot;
                Coperande(ni - 1) = &quot;{func e^{&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;g&quot;, &quot;G&quot;
                Coperande(ni - 1) = &quot;{log&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;l&quot;, &quot;L&quot;
                Coperande(ni - 1) = &quot;{ln &quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;n&quot;, &quot;N&quot;
                Coperande(ni - 1) = &quot;{ldline {&quot; &amp; Coperande(ni - 1) &amp; &quot;} rdline}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;v&quot;, &quot;V&quot;
                Coperande(ni - 1) = &quot;{widevec {&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;b&quot;, &quot;B&quot;
                Coperande(ni - 1) = &quot;{overstrike {&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;H&quot;,&quot;h&quot;
                Coperande(ni - 1) = &quot;{widehat {&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;m&quot;, &quot;M&quot;
                Coperande(ni - 1) = &quot;{overline {&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;a&quot;, &quot;A&quot;
                Coperande(ni - 1) = &quot;{abs {&quot; &amp; Coperande(ni - 1) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;r&quot;, &quot;R&quot;
                a = InStr(1, Coperande(ni - 1), &quot; \; &quot;)
                If a &lt;&gt; 0 Then
                    rac1 = Left$(Coperande(ni - 1), a - 1)
                    rac2 = Mid$(Coperande(ni - 1), a + 4)
                else
                	rac1=&quot;&quot;
                	rac2=COperande(ni-1)
                End If
                Coperande(ni - 1) = &quot;{nroot{&quot; &amp; rac1 &amp; &quot;}{&quot; &amp; rac2 &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;c&quot;, &quot;C&quot;
                Coperande(ni - 1) = &quot;{Cos &quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;s&quot;, &quot;S&quot;
                Coperande(ni - 1) = &quot;{Sin &quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;t&quot;, &quot;T&quot;
                Coperande(ni - 1) = &quot;{Tan &quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;I&quot;
                RemplaceTexte Coperande(ni - 1), &quot; \; &quot;, &quot;\;&quot;
                
                ChargeParametre Coperande(ni - 1), param, &quot;\;&quot;
                Coperande(ni - 1) = &quot;{int from{&quot; &amp; param(0) &amp; &quot;} to {&quot; &amp; param(1) &amp; &quot;} {&quot; &amp; param(2) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;X&quot;
                RemplaceTexte Coperande(ni - 1), &quot; \; &quot;, &quot;\;&quot;
                
                ChargeParametre Coperande(ni - 1), param(), &quot;\;&quot;
                Coperande(ni - 1) = &quot;{sum from{&quot; &amp; param(0) &amp; &quot;} to {&quot; &amp; param(1) &amp; &quot;} {&quot; &amp; param(2) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;P&quot;
                RemplaceTexte Coperande(ni - 1), &quot; \; &quot;, &quot;\;&quot;
                
                ChargeParametre Coperande(ni - 1), param(), &quot;\;&quot;
                Coperande(ni - 1) = &quot;{prod from {&quot; &amp; param(0) &amp; &quot;}to {&quot; &amp; param(1) &amp; &quot;} {&quot; &amp; param(2) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;Y&quot;
                RemplaceTexte Coperande(ni - 1), &quot; \; &quot;, &quot;\;&quot;
                
                fi = ChargeParametre(Coperande(ni - 1), param(), &quot;\;&quot;) - 1
                Coperande(ni - 1) = &quot;{alignl left lbrace stack {&quot; 
                For i = 0 To fi
                	if i=fi then
	                    Coperande(ni - 1) = Coperande(ni - 1) &amp; param(i) &amp; &quot;}&quot;
                    else
 	                   Coperande(ni - 1) = Coperande(ni - 1) &amp; param(i) &amp; &quot;#&quot;
	                end if
                Next i
                COperande(ni-1) = COperande(ni-1) &amp; &quot;right none}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;J&quot;
                RemplaceTexte Coperande(ni - 1), &quot; \; &quot;, &quot;\;&quot;
                
                ChargeParametre Coperande(ni - 1), param(), &quot;\;&quot;
                Coperande(ni - 1) = &quot;{Lim from {&quot; &amp; param(0) &amp; &quot; rightarrow &quot; &amp; param(1) &amp; &quot; } {&quot; &amp; param(2) &amp; &quot;}}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;K&quot;
                Coperateur(oi - 1) = FormatOperateur &amp; &quot; + &quot;
                SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                If ni &gt; 0 Then
                    Coperande(ni - 1) = Coperateur(oi - 1) &amp; Coperande(ni - 1)
                Else
                    SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                    Coperande(0) = Coperateur(oi - 1)
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;O&quot;
                Coperateur(oi - 1) = FormatOperateur &amp; &quot; - &quot;
                SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                If ni &gt; 0 Then
                    Coperande(ni - 1) = Coperateur(oi - 1) &amp; Coperande(ni - 1)
                Else
                    SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                    Coperande(0) = Coperateur(oi - 1)
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;^&quot;
                deb3 = Left(Coperande(ni - 2), 3)
                If InStr(1, Coperande(ni - 2), &quot;\g&quot;) = 1 Then
                    a = InStr(3, Coperande(ni - 2), &quot;g&quot;) + 1
                    a = InStr(a, Coperande(ni - 2), &quot;g&quot;) + 1
                    deb3 = Left(Mid(Coperande(ni - 2), a), 3)
                End If
                If deb3 = &quot;sin&quot; Or deb3 = &quot;cos&quot; Or deb3 = &quot;tan&quot; Then
                    Coperande(ni - 2) = &quot;{{&quot; &amp; Left(Coperande(ni - 2), a + 2) &amp; &quot;} ^ {&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot; &amp; Right(Coperande(ni - 2), Len(Coperande(ni - 2)) - (a + 2)) &amp; &quot;}&quot;
                Else
                    Coperande(ni - 2) = &quot;{&quot; &amp; Coperande(ni - 2) &amp; &quot;} ^ {&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
                NiveauExposant = NiveauExposant + 4
            Case &quot;=&quot;
                If ni &gt; 1 Then
                    Coperande(ni - 2) = Coperande(ni - 2) &amp; Coperateur(oi - 1) &amp; Coperande(ni - 1)
                    ni = ni - 1
                Else
                    SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                    If ni &gt; 0 Then
                        Coperande(ni - 1) = Coperateur(oi - 1) &amp; Coperande(ni - 1)
                    Else
                        SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                        Coperande(ni) = Coperateur(oi - 1)
                    End If
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;;&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; &quot; \; &quot; &amp; Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;,&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; &quot; , &quot; &amp; Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;|&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; &quot; ; &quot; &amp; Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;ƒ&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; FormatOperateur &amp; &quot;ƒ&quot; &amp; Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;+&quot;
                If ni &gt; 0 Then
                    If espace1 = &quot;&quot; And Not FractionADroite(Coperande(ni - 2)) Then SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                    If espace1 = &quot;&quot; And Not FractionAGauche(Coperande(ni - 1)) Then SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                    If espace2 = &quot;&quot; And FractionADroite(Coperande(ni - 2)) Then SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                    If espace2 = &quot;&quot; And FractionAGauche(Coperande(ni - 1)) Then SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                    Coperande(ni - 2) = Coperande(ni - 2) &amp; Coperateur(oi - 1) &amp; Coperande(ni - 1)
                    ni = ni - 1
                Else
                    SupprimeEspaceOperandeDroite Coperateur(oi - 1)
                    SupprimeEspaceOperandeGauche Coperateur(oi - 1)
                    Coperande(0) = Coperateur(oi - 1)
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;-&quot;
               	if FractionAGauche(Coperande(ni - 2)) then espace3=espace2 else espace4=espace1
               	if FractionADroite(Coperande(ni - 2)) then espace3=espace2 else espace4=espace1
                If ni &gt; 0 Then
                    Coperande(ni - 2) = Coperande(ni - 2) &amp; FormatOperateur &amp; espace3 &amp; &quot;-&quot; &amp; espace4 &amp; Coperande(ni - 1)
                    ni = ni - 1
                Else
                    Coperande(0) = FormatOperateur &amp; &quot;-&quot;
                    SupprimeEspaceOperandeDroite Coperande(0)
                    SupprimeEspaceOperandeGauche Coperande(0)
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;..&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; &quot; &quot; &amp; Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;.&quot;
                Coperande(ni - 2) = Coperande(ni - 2) &amp; &quot; &quot; &amp; Coperande(ni - 1)
&apos;                Coperande(ni - 2) = Coperande(ni - 2) + &quot; &quot; + Coperande(ni - 1)
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;:&quot;
                If ni &gt; 0 Then
                    Coperande(ni - 2) = &quot;{&quot; &amp; Coperande(ni - 2) &amp; &quot;} div {&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                    ni = ni - 1
                Else
                    Coperande(0) = &quot;{} div {&quot; &amp; Coperande(ni-1) &amp; &quot;}&quot;
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;*&quot;
                If ni &gt; 0 Then
                    Coperande(ni - 2) = &quot;{&quot; &amp; Coperande(ni - 2) &amp; &quot;} times {&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                    ni = ni - 1
                Else
                    Coperande(0) = &quot;{} times {&quot; &amp; Coperande(ni-1) &amp; &quot;}&quot;
                End If
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;/&quot;
                Coperande(ni - 2) = &quot;{&quot; &amp; Coperande(ni - 2) &amp; &quot;} over {&quot; &amp; Coperande(ni - 1) &amp; &quot;}&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
                ni=ni-1
            Case &quot;$&quot;
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
            Case Else
                Coperateur(oi) = &quot;&quot;
                oi = oi - 1
        End Select
    End If
End Sub

Function CestUnNombre(texte as string) As Boolean
Dim i

    CestUnNombre = False
    If Len(texte) &gt; 0 Then CestUnNombre = True
    For i = 1 To Len(texte)
        If InStr(1, &quot;0123456789 &quot;, Mid(texte, i, 1)) = 0 Then
            CestUnNombre = False
            Exit Function
        End If
    Next i
End Function

Function SupprimeEspaceOperandeDroite(texte) As Boolean
Dim seod, aa, a, ki, kj
    seod = 0
    SupprimeEspaceOperandeDroite = False
    Do
        aa = InStrD(1, texte, &quot;\g&quot;)
        If aa &gt; 0 Then
            ExtraitDebutFin aa, texte, ki, kj
            kj = kj - 1
            a = InStr(aa, texte, &quot;g&quot;) + 1
            a = InStr(a, texte, &quot;g&quot;) + 1
            a = InStr(a, texte, &quot;g&quot;) + kj + 1
            If Mid(texte, a, 1) = &quot; &quot; And a = Len(texte) Then
                texte = Left(texte, aa - 1) &amp; &quot;\g&quot; &amp; Trim(Str(ki)) &amp; &quot;g&quot; &amp; Trim(Str(kj)) &amp; &quot;g&quot; &amp; Mid(texte, a - kj, kj)
                seod = 1
                SupprimeEspaceOperandeDroite = True
            Else
                If Right(texte, 1) = &quot; &quot; Then
                    texte = Left(texte, Len(texte) - 1)
                    seod = 1
                    SupprimeEspaceOperandeDroite = True
                Else
                    seod = 0
                End If
            End If
        Else
            If Right(texte, 1) = &quot; &quot; Then
                texte = Left(texte, Len(texte) - 1)
                seod = 1
                SupprimeEspaceOperandeDroite = True
            Else
                seod = 0
            End If
        End If
    Loop While (seod = 1)
End Function

Function SupprimeEspaceOperandeGauche(texte) As Boolean
Dim ki, kj, a
    SupprimeEspaceOperandeGauche = False
    If InStr(1, texte, &quot;\g&quot;) = 1 Then
        ExtraitDebutFin 1, texte, ki, kj
        a = InStr(1, texte, &quot;g&quot;) + 1
        a = InStr(a, texte, &quot;g&quot;) + 1
        a = InStr(a, texte, &quot;g&quot;) + 1
        While (Mid(texte, a, 1) = &quot; &quot;)
            ki = ki + 1
            kj = kj - 1
            texte = &quot;\g&quot; &amp; Trim(Str(ki)) &amp; &quot;g&quot; &amp; Trim(Str(kj)) &amp; &quot;g&quot; &amp; Mid(texte, a + 1)
            a = Len(&quot;\g&quot; &amp; Trim(Str(ki)) &amp; &quot;g&quot; &amp; Trim(Str(kj)) &amp; &quot;g&quot;) + 1
            SupprimeEspaceOperandeGauche = True
        Wend
    Else
        While (Left(texte, 1) = &quot; &quot;)
            texte = Mid(texte, 2)
            SupprimeEspaceOperandeGauche = True
        Wend
    End If
End Function

Function NiveauPrioritePar(texte) As Integer
Dim npo
    npo = 10
    If InStr(1, &quot;cstrelganmvbixpyjh&quot;, texte) &lt;&gt; 0 Then npo = 0
    If InStr(1, &quot;^&quot;, texte) &lt;&gt; 0 Then npo = -10
    If InStr(1, &quot;OK&quot;, texte) &lt;&gt; 0 Then npo = -30
    If InStr(1, &quot;*.&quot;, texte) &lt;&gt; 0 Then npo = -40
    If InStr(1, &quot;+-&quot;, texte) &lt;&gt; 0 Then npo = -50
    If InStr(1, &quot;/&quot;, texte) &lt;&gt; 0 Then npo = -55
    If InStr(1, &quot;$)]}&quot;, texte) &lt;&gt; 0 Then npo = -60
    If InStr(1, &quot;=;ƒ,&quot;, texte) &lt;&gt; 0 Then npo = -70
    If InStr(1, &quot;([{&quot;, texte) &lt;&gt; 0 Then npo = -80
    NiveauPrioritePar = npo
End Function

Function NiveauPriorite(texte) As Integer
Dim npo

    npo = 10
    If InStr(1, &quot;cstrelganmvbixpyj&quot;, texte) &lt;&gt; 0 Then npo = 0
    If InStr(1, &quot;^&quot;, texte) &lt;&gt; 0 Then npo = -10
    If InStr(1, &quot;/&quot;, texte) &lt;&gt; 0 Then npo = -30
    If InStr(1, &quot;OK&quot;, texte) &lt;&gt; 0 Then npo = -40
    If InStr(1, &quot;*&quot;, texte) &lt;&gt; 0 Then npo = -45
    If InStr(1, &quot;.&quot;, texte) &lt;&gt; 0 Then npo = -48
    If InStr(1, &quot;+-&quot;, texte) &lt;&gt; 0 Then npo = -50
    If InStr(1, &quot;$)]}&quot;, texte) &lt;&gt; 0 Then npo = -60
    If InStr(1, &quot;=&quot;, texte) &lt;&gt; 0 Then npo = -65
    If InStr(1, &quot;;ƒ,&quot;, texte) &lt;&gt; 0 Then npo = -70
    If InStr(1, &quot;([{&quot;, texte) &lt;&gt; 0 Then npo = -80
    NiveauPriorite = npo
End Function

Function FormatTexte(i, texte) As String
Dim ii
    ii = i
&apos;    If Left(texte, 1) = &quot; &quot; Then
&apos;        texte = Mid(texte, 2)
&apos;        ii = ii + 1
&apos;    End If
 &apos;   If Right(texte, 1) = &quot; &quot; Then texte = Left(texte, Len(texte) - 1)
    FormatTexte = &quot;\g&quot; &amp; Trim(Str(ii)) &amp; &quot;g&quot; &amp; Trim(Str(Len(texte))) &amp; &quot;g&quot;
End Function

Function InStrD(isi, texte, texte1) As Integer
Dim nocur, a, i
    nocur = CompteTexte(isi, texte, texte1)
    If nocur &gt;= isi Then
        a = 1
        For i = 1 To nocur - isi + 1
            a = InStr(a, texte, texte1) + 1
        Next i
        InStrD = a - 1
    Else
        InStrD = 0
    End If
End Function

Function CompteTexte(Debut, texte1, texte2) As Integer
Dim a, nbtexte

    a = Debut
    nbtexte = 0
    Do
        a = InStr(a, texte1, texte2) + 1
        If Val(a) &gt; 1 Then nbtexte = nbtexte + 1
    Loop While (Val(a) &gt; 1)
    CompteTexte = nbtexte
End Function

Function ExtraitDebutFin(deb, texte, i, j) As Integer
Dim a, b, c
    a = InStr(deb, texte, &quot;\g&quot;) + 1
    If a &gt; 1 Then
        b = InStr(a + 1, texte, &quot;g&quot;)
        c = InStr(b + 1, texte, &quot;g&quot;)
        i = Val(Mid$(texte, a + 1, b - a - 1))
        j = Val(Mid$(texte, b + 1, c - b - 1))
        ExtraitDebutFin = InStr(c + 1, texte, &quot;\g&quot;)
    Else
        ExtraitDebutFin = 0
    End If
End Function

Function ROperateur(texte) As String
Dim i
    i = Len(texte)
    While (Mid(texte, i, 1) = &quot; &quot;)
        i = i - 1
    Wend
    ROperateur = Mid(texte, i, 1)
    If ROperateur = &quot;.&quot; Then If i &gt; 1 Then If Mid(texte, i - 1, 1) = &quot;.&quot; Then ROperateur = &quot;..&quot;
End Function

Function FractionDetectee(texte) As Boolean
    FractionDetectee = (InStr(1, texte, &quot;} over {&quot;) &lt;&gt; 0)
End Function

Function RemplaceTexte(texte As String, texte1 As String, texte2 As String, Optional a) As Integer
Dim remp As Boolean
Dim j As Integer
	if ismissing(a) then a=1
    remp = False
        If Len(texte) &gt; 0 And Len(texte1) &lt;= Len(texte) Then
            Do
                a = InStr(a, texte, texte1)
                If a &lt;&gt; 0 Then
                    texte = Left$(texte, a - 1) &amp; texte2 &amp; Right(texte, Len(texte) + 1 - a - Len(texte1))
                    remp = True
                End If
            Loop While (a &lt;&gt; 0)
        End If
    RemplaceTexte = remp
End Function

Function FractionADroite(texte As String) As Boolean
Dim b
    FractionADroite = False
    If Right(texte, 1) = &quot;}&quot; Then
        b = PositionAccolades2(texte, Len(texte) - 1)
        If Right(Left(texte, b - 1), 4) = &quot;over&quot; Then FractionADroite = True
    End If
End Function

Function FractionAGauche(texte As String) As Boolean
Dim a,b

    FractionAGauche = False
    If left(texte, 1) = &quot;{&quot; Then
        b = PositionAccolades(texte, 1)
        If Right(Left(texte, b - 1), 4) = &quot;over&quot; Then FractionAGauche = True
    End If
End Function

Function PositionAccolades(a$, p2)
Dim p As Integer, par As Integer
    
    p = p2
    par = 1
    Do
        p = p + 1
        Select Case Mid$(a$, p, 1)
        Case &quot;{&quot;: par = par + 1
        Case &quot;}&quot;: par = par - 1
        End Select
    Loop Until par = 0 Or p &gt; Len(a$)
    If par &lt;&gt; 0 Then
        PositionAccolades = -1
    Else
        PositionAccolades = p
    End If
End Function

Function PositionAccolades2(a$, p2)
Dim p As Integer, par As Integer
    
    p = p2
    par = 1
    Do
        p = p - 1
        Select Case Mid$(a$, p, 1)
        Case &quot;}&quot;: par = par + 1
        Case &quot;{&quot;: par = par - 1
        End Select
    Loop Until par = 0 Or p &lt; 1
    If par &lt;&gt; 0 Then
        PositionAccolades2 = -1
    Else
        PositionAccolades2 = p
    End If
End Function

Function ChargeParametre(texte$, tableau() As String, Optional Separateur)
Dim nbpv, j, i, a$

	if ismissing(Separateur) then Separateur=&quot;;&quot;
    texte$ = texte$ &amp; Separateur
    nbpv = 0
    For j = 1 To Len(texte$)
        If Mid$(texte$, j, Len(Separateur)) = Separateur Then nbpv = nbpv + 1
    Next j
    ReDim tableau(0 To nbpv - 1) as String
    For j = 0 To nbpv - 1
        tableau(j) = &quot;&quot;
    Next j
    i = 0
    For j = 1 To Len(texte$)
        a$ = Mid$(texte$, j, Len(Separateur))
        If a$ = Separateur Then
            i = i + 1
            j = j + Len(Separateur) - 1
        Else
            tableau(i) = tableau(i) &amp; Mid$(texte$, j, 1)
        End If
    Next j
    texte$ = Left$(texte$, Len(texte$) - Len(Separateur))
    ChargeParametre = i
End Function


</script:module>