
I have come across a wierd problem in string disection.
I wrote this bit of code to illustrate it ...
Please notice that math_b has a pair of brackets.
See what this does to the output!
Code: Select all
; Disect a string into its constituent parts for parsing ...
Dim s.s(64) ; hold the parts in this array
Global c.s
Global math_a.s
Global math_b.s
; setup example srings ...
math_a="14.582*3.2/4.5-625+10.1*17.2/13.4-25.123"
math_b="14.582*3.2/4.5-(625)+10.1*17.2/13.4-25.123"
Procedure Test(M.s)
For i=0 To 63
s(i)=""
Next
n=0
For i=1 To Len(M)
c=Mid(M,i,1)
If c="*" Or c="(" Or c="/" Or c=")" Or c="+" Or c="-"
n+1
s(n)=c
n+1
Else
s(n)=s(n)+c
EndIf
Next
WriteString(Chr(10)+Chr(10)+M+Chr(10)+Chr(10))
n=0
While s(n)>""
WriteString(":"+s(n)+","+Chr(10))
n+1
Wend
EndProcedure
; make an output file for the results ...
r=CreateFile(1,"output.txt")
Test(math_a)
Test(math_b)
CloseFile(1)
End

Is this a bug?
Is it deliberate for some purpose?
Can anyone see a way round it?