Drifter Posted August 30, 2009 Share Posted August 30, 2009 I am working with a script that will draw parametric equations. However, i have a bit of a problem with it. I ask the user for an equation, lets say for X. An example would be sin($T) where $T is time. I managed to have it evaluate T and i get the string "sin(0)" by using: $mX = StringReplace($xEq,"$T",$T) (by the way $mX is where the mouses X coordinate is, and $xEq is the string equation) so now i have "sin(0)" how do i get that to evaluate? ive tried stuff like: $mX = Number($mX) but that seems to be only for direct numbers, like "4.62".... Any help? I need it to evaluate any string like: "(Sin(1.4) * Cos(1.4)) * 100 + 500" Any ideas? Thanks! Link to comment Share on other sites More sharing options...
Malkey Posted August 30, 2009 Share Posted August 30, 2009 I am working with a script that will draw parametric equations. However, i have a bit of a problem with it. I ask the user for an equation, lets say for X. An example would be sin($T) where $T is time. I managed to have it evaluate T and i get the string "sin(0)" by using: $mX = StringReplace($xEq,"$T",$T) (by the way $mX is where the mouses X coordinate is, and $xEq is the string equation) so now i have "sin(0)" how do i get that to evaluate? ive tried stuff like: $mX = Number($mX) but that seems to be only for direct numbers, like "4.62".... Any help? I need it to evaluate any string like: "(Sin(1.4) * Cos(1.4)) * 100 + 500" Any ideas? Thanks! I believe you require the Execute() command. Here is another similar example to the help file example. ; $iVar = 30 ; Degrees $sEq = "Sin($iVar*4*atan(1)/180) * 100 " ; 4*atan(1) = pi MsgBox(0, "Answer", Execute($sEq)) ; sin(30deg)*100 = 50 ; Link to comment Share on other sites More sharing options...
Drifter Posted August 31, 2009 Author Share Posted August 31, 2009 I believe you re correct. I don't even need to replace from the looks of it, thanks!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now