04-29-2008, 07:49 PM
You are very welcome Ralph, I am glad it helped!
Hi LPG,
If I may give you a tip ?
Use an array to split the whole input string in to tokens.
This makes it easier to keep track of symbols like brackets etc. and once you know where to place the pow statement you can simply change the array.
So (5^5)^5 could look like this:
Token$(1) = "("
Token$(2) = "5"
Token$(3) = "^"
Token$(4) = "5"
Token$(5) = ")"
Token$(6) = "^"
Token$(7) = "5"
To become pow((pow(5,5)),5)
Token$(1) = "pow" + Token$(1)
Token$(2) = "(pow(" + Token$(2)
Token$(3) = ","
Token$(4) = "5"
Token$(5) = ")" + Token$(5)
Token$(6) = ","
Token$(7) = Token$(7) + ")"
Note that all tokens which are ^ simply become a comma.
The trick is to take track of the brackets!
I hope that helps.
And then one more tricky example when it comes to unary operators
If -8 - -5 = 1 - -2 ^ 2 Then
Becomes
If -8 - -5= 1- -pow(2,2) Then
Cheers,
Frontrunner
Hi LPG,
If I may give you a tip ?
Use an array to split the whole input string in to tokens.
This makes it easier to keep track of symbols like brackets etc. and once you know where to place the pow statement you can simply change the array.
So (5^5)^5 could look like this:
Token$(1) = "("
Token$(2) = "5"
Token$(3) = "^"
Token$(4) = "5"
Token$(5) = ")"
Token$(6) = "^"
Token$(7) = "5"
To become pow((pow(5,5)),5)
Token$(1) = "pow" + Token$(1)
Token$(2) = "(pow(" + Token$(2)
Token$(3) = ","
Token$(4) = "5"
Token$(5) = ")" + Token$(5)
Token$(6) = ","
Token$(7) = Token$(7) + ")"
Note that all tokens which are ^ simply become a comma.
The trick is to take track of the brackets!
I hope that helps.
And then one more tricky example when it comes to unary operators

If -8 - -5 = 1 - -2 ^ 2 Then
Becomes
If -8 - -5= 1- -pow(2,2) Then
Cheers,
Frontrunner