For example:
var/formula = "1+1"
src << formula // outputs 1+1
formula = text2formula(formula) // something like this
src << formula // outputs 2
If it isn't possible currently, it would make a suggestion to improve BYOND. =)
~~> Dragon Lord
ID:268652
![]() Oct 1 2004, 1:47 pm
|
|
I've been thinking if it was possible to have a formula in text form turned to a real one?
For example: var/formula = "1+1" If it isn't possible currently, it would make a suggestion to improve BYOND. =) ~~> Dragon Lord |
![]() Oct 1 2004, 2:07 pm
|
|
I agree, I was trying to add a function like this to my Deluxe Calc. Basically all I can suggest is using some sort of advanced findtext code that looks for an expression, basically very hard in my opinion, and then uses the text it's found to calculate the answere based on variables equal to the numbers found....Im battering on here... no good at explainin'.
|
Sure you can do that. Make a function that reads through a text string number and symbol by number and symbol, taking the appropriate action at each. Make a while loop that continuously checks to see if there is another operation to be performed; and if there is, check to see what the next operator and number in line are and do the appropriate math with a switch. When it is done looping, you have your answer, so return it.
|