This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths/Parser.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
<?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="Parser" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) Andy Lewis.  (lewiss@ntlworld.com)
&apos;téléchargé sur www.ooomacros.org
&apos;updated by Jean-Luc Guillot 2010: 
&apos;   add some functions (min, max, sin, int,fact)
&apos;   add management of synonimous of functions
&apos;   understand constantes pi and e constants
&apos;   management of functions with optionals parameters
&apos;   add Statistical and mathematical Calc functions
&apos;   possibility to calculate f(x,y,z)
&apos;   
&apos;
&apos;This library is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU Lesser General Public Licence (LGPL)
&apos;as published by the Free Software Foundation; either
&apos;version 2.1 of the License, or (at your option) any later version.

&apos;This library 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 GNU
&apos;General Public License for more details.

&apos;You should have received a copy of the GNU General Public Licence (GPL)
&apos;along with this library; if not, write to the Free Software
&apos;Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
&apos;************************************************
&apos;Parser to evaluate functions typed in as a string
&apos;This needs tidying up really so no documentation yet  But it works

Option Explicit

&apos;This constant is used as an undefined value eg resulting from division by zero
Global Const notdef = 1e38

Public DegreesFlag as Boolean

Private l2$(50),l20$(50), ln2(50)
Private lp2, lp20  As Integer
Private a$, a0$
Private oFunctionAccess As Object
private CalcFunctions$ As string
&apos;___________________________________________________________________________________________

Sub convertfn (a$, l2$(), lp2, erflag)
Dim l1$(50), priority(50)
Dim la, c, p, s As Integer
Dim ch$, st$, fl$, FunctionsList$,sep$
sep$=&quot;no&quot;
a$ = LCase(a$)
FunctionsList$ = &quot;¦fact¦abs¦int¦uminus¦sin¦cos¦tan¦sqr¦exp¦ln¦log¦lg¦&quot;
FunctionsList$ = FunctionsList$+&quot;sign¦logten¦logtwo¦frac¦min¦max¦&quot;
FunctionsList$ = FunctionsList$+&quot;sec¦cosec¦cot¦sinh¦cosh¦tanh¦sech¦cosech¦coth¦&quot;
FunctionsList$ = FunctionsList$+&quot;arcsin¦arccos¦arctan¦arcsec¦arccosec¦arccot¦&quot;
FunctionsList$ = FunctionsList$+&quot;arsinh¦arcosh¦artanh¦arsech¦arcosech¦arcoth¦&quot;
&apos;Statistical Functions
CalcFunctions$ = &quot;¦betadist¦betainv¦chidist¦chisqdist¦chiinv¦chisqinv¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;confidence¦expondist¦finv¦fisher¦fisherinv¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;fdist¦gamma¦gammainv¦gammaln¦gammadist¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;gauss¦loginv¦lognormdist¦norminv¦normdist¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;normsinv¦normsdist¦phi¦tdist¦tinv¦weibull¦&quot;

&apos;Financial Functions
CalcFunctions$ = CalcFunctions$+&quot;db¦ddb¦sln¦syd¦vdb¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;cumipmt¦cumipmt_add¦cumprinc¦cumprinc_add¦fv¦ipmt¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;ispmt¦nper¦npv¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;rate¦rri¦duration¦&quot;
CalcFunctions$ = CalcFunctions$+&quot;effective¦effect_add¦nominal¦nominal_add¦&quot;

s = 0: la = Len(a$): c = 1: ch$ = Mid$(a$, c, 1)
Do While c &lt;= la
st$ = ch$: fl$ = &quot;C&quot;
Select Case ch$
Case &quot;a&quot; To &quot;z&quot;
  fl$ = &quot;S&quot;: st$ = &quot;&quot;
  Do While c &lt;= la And (ch$ &gt;= &quot;a&quot; And ch$ &lt;= &quot;z&quot;)
    st$ = st$ + ch$
    c = c + 1: ch$ = Mid$(a$, c, 1)
  Loop
Case &quot;0&quot; To &quot;9&quot;, &quot;.&quot;
  fl$ = &quot;N&quot;: st$ = &quot;&quot;
  Do While c &lt;= la And ((ch$ &gt;= &quot;0&quot; And ch$ &lt;= &quot;9&quot;) Or ch$ = &quot;.&quot;)
    st$ = st$ + ch$
    c = c + 1: ch$ = Mid$(a$, c, 1)
  Loop
End Select
If fl$ = &quot;C&quot; Then c = c + 1: If c &lt;= la Then ch$ = Mid$(a$, c, 1)
If st$ = &quot;-&quot; And (s = 0 Or (priority(s) &gt;= 1 And priority(s) &lt;= 5) Or l1$(s)=&quot;;&quot; or l1$(s)=&quot;,&quot;) Then st$ = &quot;uminus&quot;: fl$ = &quot;S&quot;
If st$ = &quot; &quot; Or (st$ = &quot;+&quot; And (s = 0 Or (priority(s) &gt;= 1 And priority(s) &lt;= 5))) Then fl$ = &quot;X&quot;
erflag = 0
If fl$ = &quot;S&quot; Then
  If InStr(FunctionsList$, &quot;¦&quot; + st$ + &quot;¦&quot;) Then 
    p = 1 
  ElseIf InStr(CalcFunctions$, &quot;¦&quot; + st$ + &quot;¦&quot;) Then 
    if IsNull(oFunctionAccess) then oFunctionAccess=createUnoService( &quot;com.sun.star.sheet.FunctionAccess&quot; )
    p = 1 
  Else p = -1
  End If
End If
If fl$ = &quot;N&quot; Then p = 0
If fl$ = &quot;C&quot; Then
  Select Case st$
  Case &quot;^&quot;: p = 2
  Case &quot;*&quot;, &quot;/&quot;: p = 3
  Case &quot;+&quot;, &quot;-&quot;: p = 4
  Case &quot;(&quot;: p = 5
  Case &quot;)&quot;: p = 6
  Case &quot;,&quot;,&quot;;&quot;: p = 6 : sep$=&quot;yes&quot;
  Case Else: erflag = -1: Exit Sub
  End Select
End If
If fl$ &lt;&gt; &quot;X&quot; Then
  If s &gt; 0 And (priority(s) &lt;= 0 Or priority(s) = 6) And (p &lt;= 1 Or p = 5) Then
    rem doit gerer le ; ici 
    if sep$=&quot;no&quot; then
      s = s + 1: l1$(s) = &quot;*&quot;: priority(s) = 3
    else sep$=&quot;no&quot;
    end if
  End If
  s = s + 1: l1$(s) = st$: priority(s) = p
End If
Loop
prioritise l1$(), s, priority(), l2$(), lp2, erflag
End Sub

&apos;___________________________________________________________________________________________

Function evaluate (l2$(), lp2, X, erflag, optional Xname, optional Y, optional Yname, optional Z, optional Zname) as double
On Error GoTo errorhandler
Dim v(50)
Dim sp, pl2,nbArg,i As Integer
Dim CurValue As String
Dim PossibleX, PossibleY, PossibleZ As String
Dim Args() as double
  if Ismissing(Xname) then possibleX=&quot;¦x¦&quot; else PossibleX=&quot;¦&quot;+Xname+&quot;¦&quot;
  if Ismissing(Yname) then PossibleY=&quot;¦y¦&quot; else PossibleY=&quot;¦&quot;+Yname+&quot;¦&quot;
  if Ismissing(Zname) then PossibleZ=&quot;¦z¦&quot; else PossibleZ=&quot;¦&quot;+Zname+&quot;¦&quot;
  
  if Ismissing(Xname) and Ismissing(Y) and Ismissing(Z) then possibleX=&quot;¦x¦y¦z¦t¦u¦v¦&quot;

sp = 0: pl2 = 0: erflag = 0
Do While pl2 &lt; lp2
  pl2 = pl2 + 1
  CurValue=l2$(pl2)
  If Left$(CurValue, 1) = &quot;#&quot; Then
    sp = sp + 1: v(sp) = Val(Mid$(CurValue, 2))
  ElseIf Instr(PossibleX, CurValue)  Then
    sp = sp + 1: v(sp) = X
  ElseIf Instr(PossibleY, CurValue)  Then
    sp = sp + 1: v(sp) = Y
  ElseIf Instr(PossibleZ, CurValue)  Then
    sp = sp + 1: v(sp) = Z
  ElseIf CurValue=&quot;rnd&quot;  Then
    sp = sp + 1: v(sp) = rnd()
  ElseIf CurValue=&quot;e&quot;  Then
    sp = sp + 1: v(sp) = 2.71828182845904
  ElseIf sp = 0 Then
    erflag = -3: Exit Function
  ElseIf CurValue &gt;= &quot;a&quot; And CurValue &lt;= &quot;z&quot; Then
    If InStr(CalcFunctions$,&quot;¦&quot;+l2$(pl2)+&quot;¦&quot;) then
        nbArg=ln2(pl2)
        redim Args(nbArg-1)
        sp = sp - nbArg+1
        for i =0 to nbArg-1
          Args(i)=v(sp+i)
        next
        v(sp)=oFunctionAccess.CallFunction( l2$(pl2),Args )    
    else
    Select Case l2$(pl2)
    Case &quot;sin&quot;: v(sp) = Sin(angle(v(sp)))
    Case &quot;cos&quot;: v(sp) = Cos(angle(v(sp)))
    Case &quot;tan&quot;: if Cos(angle(v(sp)))=0 Then erflag=-4 Else v(sp) = Tan(angle(v(sp)))
    Case &quot;uminus&quot;: v(sp) = -v(sp)
    Case &quot;sign&quot;: if v(sp)&lt;0 then v(sp)=-1 else if v(sp)=0 then v(sp)=0 else v(sp)=1
    Case &quot;abs&quot;: v(sp) = abs(v(sp))
    Case &quot;int&quot;: v(sp) = int(v(sp))
    Case &quot;frac&quot;: v(sp) = v(sp)-int(v(sp))
    Case &quot;min&quot; :
        nbArg=ln2(pl2)
        sp = sp - nbArg+1
        for i =1 to nbArg-1
          if v(sp)&gt;v(sp+i) then v(sp)=v(sp+i)
        next
    Case &quot;max&quot; :
        nbArg=ln2(pl2)
        sp = sp - nbArg+1
        for i =1 to nbArg-1
          if v(sp)&lt;v(sp+i) then v(sp)=v(sp+i)
        next
    Case &quot;sqr&quot;: If v(sp) &lt; 0 Then erflag = -4 Else v(sp) = Sqr(v(sp))
    Case &quot;ln&quot;: If v(sp) &lt;= 0 Then erflag = -4 Else v(sp) = Log(v(sp))
    Case &quot;log&quot;, &quot;lg&quot;: If v(sp) &lt;= 0 Then erflag = -4 Else v(sp) = Log(v(sp))
    Case &quot;logten&quot;: If v(sp) &lt;= 0 Then erflag = -4 Else v(sp) = Log(v(sp))/Log(10)
    Case &quot;logtwo&quot;: If v(sp) &lt;= 0 Then erflag = -4 Else v(sp) = Log(v(sp))/Log(2)
    Case &quot;fact&quot;: If ( v(sp) &lt; 0) or (v(sp)&gt;31) or (v(sp)&lt;&gt;int(v(sp))) Then erflag = -4 Else v(sp) = Fact(v(sp))
    Case &quot;exp&quot;: v(sp) = Exp(v(sp))
    Case &quot;sec&quot;: If Cos(angle(v(sp))) = 0 Then erflag = -4 Else v(sp) = 1 / Cos(angle(v(sp)))
    Case &quot;cosec&quot;: If Sin(angle(v(sp))) = 0 Then erflag = -4 Else v(sp) = 1 / Sin(angle(v(sp)))
    Case &quot;cot&quot;: If Tan(angle(v(sp))) = 0 Then erflag = -4 Else v(sp) = 1 / Tan(angle(v(sp)))
    Case &quot;arcsin&quot;:
      If v(sp) &lt; -1 Or v(sp) &gt; 1 Then
		erflag = -4
      ElseIf v(sp) = 1 Then
		v(sp) = 2 * Atn(1)
      ElseIf v(sp) = -1 Then
		v(sp) = -2 * Atn(1)
      Else
		v(sp) = Atn(v(sp) / Sqr(-v(sp) * v(sp) + 1))
      End If
      v(sp)=toAngle(v(sp))
    Case &quot;arccos&quot;:
      If v(sp) &lt; -1 Or v(sp) &gt; 1 Then
		erflag = -4
      ElseIf v(sp) = 1 Then
		v(sp) = 0
      ElseIf v(sp) = -1 Then
		v(sp) = 4 * Atn(1)
      Else
		v(sp) = Atn(-v(sp) / Sqr(-v(sp) * v(sp) + 1)) + 1.5708
      End If
      v(sp)=toAngle(v(sp))
    Case &quot;arctan&quot;: v(sp) = toAngle(Atn(v(sp)))
    Case &quot;arcsec&quot;:
    	If v(sp) &gt;= -1 And v(sp) &lt;= 1 Then
    		erflag = -4
    	Else
    		v(sp) = toAngle(Atn(v(sp) / Sqr(v(sp) * v(sp) - 1)) + Sgn(Sgn(v(sp)) - 1) * 1.5708)
		End If
    Case &quot;arccosec&quot;:
    	If v(sp) &gt;= -1 And v(sp) &lt;= 1 Then
    		erflag = -4
    	Else
    		v(sp) = toAngle(Atn(v(sp) / Sqr(v(sp) * v(sp) - 1)) + (Sgn(v(sp)) - 1) * 1.5708)
    	End If
    Case &quot;arccot&quot;: v(sp) = toAngle(Atn(v(sp)) + 1.5708)
    Case &quot;sinh&quot;: v(sp) = (Exp(v(sp)) - Exp(-v(sp))) / 2
    Case &quot;cosh&quot;: v(sp) = (Exp(v(sp)) + Exp(-v(sp))) / 2
    Case &quot;tanh&quot;: v(sp) = (Exp(v(sp)) - Exp(-v(sp))) / (Exp(v(sp)) + Exp(-v(sp)))
    Case &quot;sech&quot;: v(sp) = 2 / (Exp(v(sp)) + Exp(-v(sp)))
    Case &quot;cosech&quot;: If v(sp) = 0 Then erflag = -4 Else v(sp) = 2 / (Exp(v(sp)) - Exp(-v(sp)))
    Case &quot;coth&quot;: If v(sp) = 0 Then erflag = -4 Else v(sp) = (Exp(v(sp)) + Exp(-v(sp))) / (Exp(v(sp)) - Exp(-v(sp)))
    Case &quot;arsinh&quot;: v(sp) = Log(v(sp) + Sqr(v(sp) * v(sp) + 1))
    Case &quot;arcosh&quot;: If v(sp) &lt;= 1 Then erflag = -4 Else v(sp) = Log(v(sp) + Sqr(v(sp) * v(sp) - 1))
    Case &quot;artanh&quot;: If v(sp) &gt;= 1 Or v(sp) &lt;= -1 Then erflag = -4 Else v(sp) = Log((1 + v(sp)) / (1 - v(sp))) / 2
    Case &quot;arsech&quot;: If v(sp) &lt;= 0 Or v(sp) &gt; 1 Then erflag = -4 Else v(sp) = Log((Sqr(-v(sp) * v(sp) + 1) + 1) / v(sp))
    Case &quot;arcosech&quot;: If Abs(v(sp)) &lt; .0000000001 Then erflag = -4 Else v(sp) = Log((Sgn(v(sp)) * Sqr(v(sp) * v(sp) + 1) + 1) / v(sp))
    Case &quot;arcoth&quot;: If v(sp) &lt;= 1 And v(sp) &gt;= -1 Then erflag = -4 Else v(sp) = Log((v(sp) + 1) / (v(sp) - 1)) / 2
    End Select
    
    End If
  ElseIf sp &lt;= 1 Then
    erflag = -5: Exit Function
  Else
    sp = sp - 1
    Select Case l2$(pl2)
    Case &quot;+&quot;: v(sp) = v(sp) + v(sp + 1)
    Case &quot;-&quot;: v(sp) = v(sp) - v(sp + 1)
    Case &quot;*&quot;: v(sp) = v(sp) * v(sp + 1)
    Case &quot;/&quot;: If v(sp + 1) = 0 Then erflag = -4 Else v(sp) = v(sp) / v(sp + 1)
    Case &quot;^&quot;: v(sp) = v(sp) ^ v(sp + 1)
    End Select
  End If
Loop
If sp &lt;&gt; 1 Then evaluate = 999: erflag = -6: Exit Function
evaluate = v(1)
Exit Function
errorhandler:
  evaluate = notdef
  erflag = -9
End Function

&apos;___________________________________________________________________________________________

Function f (X) As Double
Dim erflag As Integer
f = evaluate(l2$(), lp2, X, erflag)
If erflag &lt; 0 Then f = notdef
End Function

Function f0 (X) As Double
Dim erflag0 As Integer
f0 = evaluate(l20$(), lp20, X, erflag0)
If erflag0 &lt; 0 Then f0 = notdef
End Function

Function f1 (X,Numero,NumInter) As Double
	Dim erflag as Integer	
	If Len(sNewFormulSpline(Numero,0,1))&lt;&gt;0 and NumInter&lt;Ubound(sNewFormulSpline(),2) Then
		If (X&gt;Csng(sNewFormulSpline(Numero,NumInter+1,1)) and Len(sNewFormulSpline(Numero,NumInter+1,0))&gt;0) Then
			NumInter = NumInter+1
			parse(sNewFormulSpline(Numero,NumInter,0),erflag)		
		EndIf
	Endif
&apos;	Print X,f(X)
	f1 = f(X)
End Function


&apos;___________________________________________________________________________________________

Sub parse (a$, erflag)
  convertfn translateF(a$), l2$(), lp2, erflag
End Sub

Sub parse0 (a0$, erflag0)
  convertfn translateF(a0$), l20$(), lp20, erflag0
End Sub

&apos;___________________________________________________________________________________________

Sub prioritise (l1$(), s, priority(), l2$(), lp2, erflag)
Dim stack$(50), ps(50), lnsp(50)
Dim lp1, sp As Integer
lp1 = 0: lp2 = 0: sp = 0
Do While lp1 &lt; s
  lp1 = lp1 + 1
  Select Case priority(lp1)
  Case Is &lt; 0
    lp2 = lp2 + 1: l2$(lp2) = l1$(lp1)
  Case 0
    lp2 = lp2 + 1: l2$(lp2) = &quot;#&quot; + l1$(lp1)
  Case 6
    Do While stack$(sp) &lt;&gt; &quot;(&quot; And sp &gt; 0
      lp2 = lp2 + 1: 
      l2$(lp2) = stack$(sp)
      If sp&lt;50 Then ln2(lp2)=lnsp(sp+1)
      sp = sp - 1
    Loop
    if l1$(lp1)=&quot;)&quot; then
      sp = sp - 1: If sp &lt; 0 Then erflag = -2: Exit Sub
    else
      If sp &lt; 1 Then erflag = -2: Exit Sub
      lnsp(sp)=lnsp(sp)+1
    end if
    
  Case Else
    Do
      If sp = 0 Or priority(lp1) &lt; ps(sp) Or (priority(lp1) = 1 And ps(sp) = 1) Or l1$(lp1) = &quot;(&quot; Then
		sp = sp + 1: 
		stack$(sp) = l1$(lp1)
		ps(sp) = priority(lp1)
		if stack$(sp) = &quot;(&quot; then lnsp(sp)=1
		  Exit Do
		Else
		  lp2 = lp2 + 1: 
		  l2$(lp2) = stack$(sp)
		  if sp&lt;50 then ln2(lp2)=lnsp(sp+1)
		  sp = sp - 1
		End If
    Loop
  End Select
Loop
Do While sp &gt; 0
  If stack$(sp) = &quot;(&quot; Then
    erflag = -2: Exit Sub
  Else
    lp2 = lp2 + 1
    l2$(lp2) = stack$(sp)
    if sp&lt;50 then ln2(lp2)=lnsp(sp+1)
    sp = sp - 1
  End If
Loop
End Sub

&apos;___________________________________________________________________________________________

function angle(x as double) as double
	if degreesflag then angle=x/45*atn(1) else angle=x
end function

&apos;___________________________________________________________________________________________

function toAngle(x as double) as double
	if degreesflag then toAngle=x/atn(1)*45 else toAngle=x
end function

function translateF(byval FuncStr as string) as string
  Dim separator as string
  rem	Convert local decimal separator to &quot;.&quot; 
	separator =Mid(CStr(1.1),2,1)
	FuncStr = replace(FuncStr,separator,&quot;.&quot;)

	rem convert equation language to maths
	FuncStr = replace(FuncStr,&quot;cdot&quot;,&quot;*&quot;)
	FuncStr = replace(FuncStr,&quot;times&quot;,&quot;*&quot;)
	FuncStr = replace(FuncStr,&quot;over&quot;,&quot;/&quot;)
	FuncStr = replace(FuncStr,&quot;div&quot;,&quot;/&quot;)
	rem parenthesis
	FuncStr = replace(FuncStr,&quot;left&quot;,&quot;&quot;)
	FuncStr = replace(FuncStr,&quot;right&quot;,&quot;&quot;)
	FuncStr = replace(FuncStr,&quot;{&quot;,&quot;(&quot;)
	FuncStr = replace(FuncStr,&quot;}&quot;,&quot;)&quot;)
	FuncStr = replace(FuncStr,&quot;[&quot;,&quot;(&quot;)
	FuncStr = replace(FuncStr,&quot;]&quot;,&quot;)&quot;)
	rem spaces
	FuncStr = replace(FuncStr,&quot;~&quot;,&quot; &quot;)
	FuncStr = replace(FuncStr,&quot;`&quot;,&quot; &quot;)
	
	rem math constants
	FuncStr = replace(FuncStr,&quot;%pi&quot;,&quot;pi&quot;)
	FuncStr = replace(FuncStr,&quot;pi&quot;,&quot; 3.14159265358979 &quot;)
	FuncStr = replace(FuncStr,&quot;e^&quot;,&quot; 2.71828182845904^&quot;)
	
	rem functions
	FuncStr = replace(FuncStr,&quot;sqrt&quot;,&quot;sqr&quot;)
	FuncStr = replace(FuncStr,&quot;tg&quot;,&quot;tan&quot;)
	FuncStr = replace(FuncStr,&quot;cotan&quot;,&quot;cot&quot;)

	FuncStr = replace(FuncStr,&quot;csc&quot;,&quot;cosec&quot;)
	FuncStr = replace(FuncStr,&quot;arcsech&quot;,&quot;arsech&quot;)
	FuncStr = replace(FuncStr,&quot;arccosech&quot;,&quot;arcosech&quot;)

	FuncStr = replace(FuncStr,&quot;acot&quot;,&quot;arccot&quot;)
	FuncStr = replace(FuncStr,&quot;arcot&quot;,&quot;arccot&quot;)
	FuncStr = replace(FuncStr,&quot;arccoth&quot;,&quot;arcoth&quot;)

	FuncStr = replace(FuncStr,&quot;atan&quot;,&quot;arctan&quot;)
	FuncStr = replace(FuncStr,&quot;artan&quot;,&quot;arctan&quot;)
	FuncStr = replace(FuncStr,&quot;arctanh&quot;,&quot;artanh&quot;)

	FuncStr = replace(FuncStr,&quot;acos&quot;,&quot;arccos&quot;)
	FuncStr = replace(FuncStr,&quot;arcos&quot;,&quot;arccos&quot;)
	FuncStr = replace(FuncStr,&quot;arccosh&quot;,&quot;arcosh&quot;)

	FuncStr = replace(FuncStr,&quot;asin&quot;,&quot;arcsin&quot;)
	FuncStr = replace(FuncStr,&quot;arsin&quot;,&quot;arcsin&quot;)
	FuncStr = replace(FuncStr,&quot;arcsinh&quot;,&quot;arsinh&quot;)

	FuncStr = replace(FuncStr,&quot;log_10&quot;,&quot;logten&quot;)
	FuncStr = replace(FuncStr,&quot;log10&quot;,&quot;logten&quot;)
	FuncStr = replace(FuncStr,&quot;log2&quot;,&quot;logtwo&quot;)
	FuncStr = replace(FuncStr,&quot;log_2&quot;,&quot;logtwo&quot;)
	FuncStr = replace(FuncStr,&quot;factorial&quot;,&quot;fact&quot;)
	FuncStr = replace(FuncStr,&quot;rand&quot;,&quot;rnd&quot;)
	FuncStr = replace(FuncStr,&quot;random&quot;,&quot;rnd&quot;)
	FuncStr = replace(FuncStr,&quot;rnd()&quot;,&quot;rnd &quot;)

	translateF = FuncStr
end function

function fact(n as single) as double
	select case n
	case 0,1: fact=1
	case 2  : fact=2
	case 3  : fact=6
	case 4  : fact=24
	case 5  : fact=120
	case 6  : fact=720
	case 7  : fact=5040
	case 8  : fact=40320
	case 9  : fact=362880
	case 10 : fact=3628800
	case 11 : fact=39916800
	case 12 : fact=479001600
	case 13 : fact=6227020800
	case 14 : fact=87178291200
	case 15 : fact=1307674368000
	case 16 : fact=20922789888000
	case 17 : fact=355687428096000
	case 18 : fact=6.402373705728E+015
	case 19 : fact=1.216451004088E+017
	case 20 : fact=2.432902008177E+018
	case 21 : fact=5.109094217171E+019
	case 22 : fact=1.124000727778E+021
	case 23 : fact=2.585201673889E+022
	case 24 : fact=6.204484017332E+023
	case 25 : fact=1.551121004333E+025
	case 26 : fact=4.032914611266E+026
	case 27 : fact=1.088886945042E+028
	case 28 : fact=3.048883446117E+029
	case 29 : fact=8.841761993740E+030
	case 30 : fact=2.652528598122E+032
	case 31 : fact=8.222838654178E+033
	case else
		fact=notdef
	end select
  
end function


</script:module>