Jump to content

Recommended Posts

I have a string that I want to evaluate, but both the following examples always return @error =1 B) :

$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? :whistle:

(I'm on AU3 v 3.0.100 with NT4, me)

Link to post
Share on other sites

Thanks for the prompt reply, Jon :evil: .. but ..

:angry: Ick! Such bad news! B)

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 :whistle: ))

Link to post
Share on other sites

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]

Link to post
Share on other sites

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()

MsgBox(4096,"", $ynResult)

P.S. True is any non-zero number (typically 1), and False is zero.

Edited 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!
Link to post
Share on other sites

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. :whistle:

David Nuttall
Nuttall 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...

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...