trids Posted March 25, 2004 Posted March 25, 2004 I have a string that I want to evaluate, but both the following examples always return @error =1 :$sEval = "23 >= 20" ; hoping for a true(-1?) or false value here $sEval = "23 + 20" ; expecting 43 here ;but here comes @error = 1 .. $ynResult = Eval($sEval)I can't seem to get an believable answer out of Eval(). What am I doing wrong? (I'm on AU3 v 3.0.100 with NT4, me)
Administrators Jon Posted March 25, 2004 Administrators Posted March 25, 2004 Eval doesn't execute code like that - it simply gives you the value of a variable. $test = 1 Eval("test") Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
trids Posted March 25, 2004 Author Posted March 25, 2004 Thanks for the prompt reply, Jon .. but .. Ick! Such bad news! I kind of got the idea that this was what Nutster was talking about when it was first suggested? Though I confess I may have misundserstood!Would this be a worth suggesting in the Ideas forum? Or is it a bit of a tall order?(( go on, admit - it can be very useful ))
MattNis Posted March 25, 2004 Posted March 25, 2004 originally I thought eval would do the same thing as you did, Trids. something like... $val = active eval("WinWait" & $val(window name, text)) [quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]
CyberSlug Posted March 25, 2004 Posted March 25, 2004 (edited) Trids, you could try a workaround like this:Write out the statement to a secondary script which you run to obtain the result. This example uses the clipboard to transfer the data.$sEval = "23 >= 20" $bak = ClipGet() FileDelete (@TempDir & "\foo.au3") FileWriteLine (@TempDir & "\foo.au3", "$x =" & $sEval) FileWriteLine (@TempDir & "\foo.au3", "ClipPut($x)" ) RunWait("C:\Program Files\AutoIt3\AutoIt3.exe " & '"foo.au3"', @TempDir) $ynResult = ClipGet() ClipPut($bak) MsgBox(4096,"", $ynResult)P.S. True is any non-zero number (typically 1), and False is zero. Edited March 25, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Nutster Posted April 1, 2004 Posted April 1, 2004 Sorry to mislead you guys, but that was what I was looking at doing. Jon implemented the much simpler version that just looks up variable values. You could try: $sEval = (23 >= 20) ; hoping for a true(-1?) or false value here MsgBox(0,"Testing", $sEval); Actual gives 1 (for true) $sEval = (23 + 20) ; expecting 43 here ;but here comes @error = 1 .. $ynResult = Eval($sEval) I would still like to do something like this, but I have to see how to prevent the calling of keywords, like Dim, While, If, and functions with side-effects, like FileRecycle, WinWait and ShutDown. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
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