DaleHohm Posted May 18, 2005 Share Posted May 18, 2005 There's trouble with Eval in 3.1.1.32 -- it works once, but then gets stuck...ConsoleWrite("--> " & @AutoItVersion & @CR) Eval("ConsoleWrite('--> Foo' & @CR)") Eval("ConsoleWrite('--> Bar' & @CR)") Eval("MsgBox(64,'Test','Hi')")returns:--> 3.1.1.32 --> Foo --> Foo --> FooAlso, I'm confused about what in intended to work in the Eval "expression"... the MsgBox and ConsoleWrite commands work (when I only use one call) but other commands (I tried assigning variables and using Dim's) fail with syntax errors:C:\AutoItScripts\WFM\xxx.au3 (9) : ==> Error in exp[b][/b]ression.: Eval("Global Const $x = 7") ^ ERRORDale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
TuMbLeWeEd Posted May 18, 2005 Share Posted May 18, 2005 (edited) There's trouble with Eval in 3.1.1.32 -- it works once, but then gets stuck...ConsoleWrite("--> " & @AutoItVersion & @CR) Eval("ConsoleWrite('--> Foo' & @CR)") Eval("ConsoleWrite('--> Bar' & @CR)") Eval("MsgBox(64,'Test','Hi')")returns:--> 3.1.1.32 --> Foo --> Foo --> FooAlso, I'm confused about what in intended to work in the Eval "expression"... the MsgBox and ConsoleWrite commands work (when I only use one call) but other commands (I tried assigning variables and using Dim's) fail with syntax errors:C:\AutoItScripts\WFM\xxx.au3 (9) : ==> Error in exp[b][/b]ression.: Eval("Global Const $x = 7") ^ ERRORDale<{POST_SNAPBACK}>$a_1 = 10 $a_2 = 11 $a_3 = 12 $a_4 = 13 $a_5 = 14 $a_6 = 15 $a_7 = 16 For $i = 1 to 20 $test = Eval("a_" & $i) If not @error then consolewrite($Test & @LF) NextEDIT:Very usefull for vars made with the "Assign" funcPut parts of a variable name together as strings and get the value if anyBut there is a problem, instead of setting the @error value when $i reaches 8,it does this:X:\AutoIt\PROJECTS\Process_window_contol_grabber\test3.au3 (9) : ==> Unknown function name.: $test = Eval("a_" & $i) ^ ERRORAs long as the variable name exist, no problem Edited May 18, 2005 by TuMbLeWeEd My AutoIt stuffChatBichProjectSelectorWindow control grabberUsefull LinksPort forwarding with routers Link to comment Share on other sites More sharing options...
SvenP Posted May 18, 2005 Share Posted May 18, 2005 errors:C:\AutoItScripts\WFM\xxx.au3 (9) : ==> Error in exp[b][/b]ression.: Eval("Global Const $x = 7") ^ ERRORDale<{POST_SNAPBACK}>Dale,Eval is for 'expression evaluation'. It has nothing to do with 'variable assignments'. so Eval ('$a = 1') does NOT assign the value 1 to $a, it EVALUATES whether $a is equal to 1 or not. Therefor you can't use statements like Dim or Const in Eval().The AutoIt helpfile currently says: "Return the value of the variable whose name is given by the expression.". You have to add a line: "Or returns the result of the expression given in the string".-Sven Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 $a_1 = 10 $a_2 = 11 $a_3 = 12 $a_4 = 13 $a_5 = 14 $a_6 = 15 $a_7 = 16 For $i = 1 to 20 $test = Eval("a_" & $i) If not @error then consolewrite($Test & @LF) NextEDIT:Very usefull for vars made with the "Assign" funcPut parts of a variable name together as strings and get the value if anyBut there is a problem, instead of setting the @error value when $i reaches 8,it does this:X:\AutoIt\PROJECTS\Process_window_contol_grabber\test3.au3 (9) : ==> Unknown function name.: $test = Eval("a_" & $i) ^ ERRORAs long as the variable name exist, no problem<{POST_SNAPBACK}>I am not sure I can fix very easily. The way the new eval work is first verify if the result of the expression correspond to a defined variable and if not evaluate the expression "a_8" is failing. I need to find a way to suppress in this case the error message.Stay tune Link to comment Share on other sites More sharing options...
TuMbLeWeEd Posted May 18, 2005 Share Posted May 18, 2005 (edited) SvenP:I know, i'm verry bad at explenationsThe Isdeclared check overcomes this error (no @error then offcourse)only thing to add should be: check first if the var is Assigned(confusion) in te C++ code (to me that is, no C++ hero at all)=>You do that i think (verify if the result of the expression correspond to a defined variable) =>problem there?My best solution would be:just use the same code as the IsDeclared func to check firs (thats my logic offcourse)noticed this while trying to get passed the Eval error, was going by the name (did not check the help file)The IsDeclared function overcomes the problem, so my first reaction was to declare the varsbut declaring the vars did not helpWas a bit confused until checked the help file wich says:In the function explenation:Check if a variable has been declared. <= thinking, wat is the problem thenin the example:If Not IsDeclared ("a") then MsgBox(0,"", "$a is NOT declared") ; $a has never been assigned <== This is the real dealEndIfIsDeclared should realy be named IsAssignedThe function realy checks if the var is assignedI did 20 min on this post, so i'm realy bad at explaining (should be understandeble ) Edited May 18, 2005 by TuMbLeWeEd My AutoIt stuffChatBichProjectSelectorWindow control grabberUsefull LinksPort forwarding with routers Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 I did a fix so the error message box will not come out any more will be in 3.1.1.33 Thanks for finding the problem Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 There's trouble with Eval in 3.1.1.32 -- it works once, but then gets stuck...ConsoleWrite("--> " & @AutoItVersion & @CR) Eval("ConsoleWrite('--> Foo' & @CR)") Eval("ConsoleWrite('--> Bar' & @CR)") Eval("MsgBox(64,'Test','Hi')")returns:--> 3.1.1.32 --> Foo --> Foo --> FooAlso, I'm confused about what in intended to work in the Eval "expression"... the MsgBox and ConsoleWrite commands work (when I only use one call) but other commands (I tried assigning variables and using Dim's) fail with syntax errors:C:\AutoItScripts\WFM\xxx.au3 (9) : ==> Error in exp[b][/b]ression.: Eval("Global Const $x = 7") ^ ERRORDale<{POST_SNAPBACK}>I found the bug on the Foo Foo Foo will be ok in 3.1.1.33Thanks for testing Link to comment Share on other sites More sharing options...
TuMbLeWeEd Posted May 18, 2005 Share Posted May 18, 2005 I did a fix so the error message box will not come out any more will be in 3.1.1.33Thanks for finding the problem <{POST_SNAPBACK}>Try to test some more new stuff, as i'm no real coder i will run much faster in to you coders unforseen probsA tester only does wat looks logical to a normal user, and on an error the coder would say "Why did you do that, thats not how i entended it to work" (meaning: you dumb ass "lol") My AutoIt stuffChatBichProjectSelectorWindow control grabberUsefull LinksPort forwarding with routers Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 Try to test some more new stuff, as i'm no real coder i will run much faster in to you coders unforseen probsat least you are a fast and precise BetaTesterThanks for your testing Link to comment Share on other sites More sharing options...
DaleHohm Posted May 18, 2005 Author Share Posted May 18, 2005 Dale,Eval is for 'expression evaluation'. It has nothing to do with 'variable assignments'. so Eval ('$a = 1') does NOT assign the value 1 to $a, it EVALUATES whether $a is equal to 1 or not. Therefor you can't use statements like Dim or Const in Eval().The AutoIt helpfile currently says: "Return the value of the variable whose name is given by the expression.". You have to add a line: "Or returns the result of the expression given in the string".-Sven<{POST_SNAPBACK}>Yes, I thought I understood that -- but the fact that MsgBox and ConsoleWrite commands are actually exectud rather than simply being EVALuated confuses me. Can you help me understand the distinction?Thanks,Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 Yes, I thought I understood that -- but the fact that MsgBox and ConsoleWrite commands are actually exectud rather than simply being EVALuated confuses me. Can you help me understand the distinction?Thanks,Dale<{POST_SNAPBACK}>For Eval has 2 forms if the string correspond to a variable name you get the value. If not the string is considered as an expression and the result is return$v="a"Eval($v & '1) return the value of the variable $a1$a=1Eval("$a +1") return 2Eval("function1($n,$n)") return the value return by function1That's the reason why ConsoleWrite get executed. I am not sure in this case it is of great help. Link to comment Share on other sites More sharing options...
DaleHohm Posted May 18, 2005 Author Share Posted May 18, 2005 For Eval has 2 forms if the string correspond to a variable name you get the value. If not the string is considered as an expression and the result is return$v="a"Eval($v & '1) return the value of the variable $a1$a=1Eval("$a +1") return 2Eval("function1($n,$n)") return the value return by function1That's the reason why ConsoleWrite get executed. I am not sure in this case it is of great help.<{POST_SNAPBACK}>OK, so the definition of an "expression" is the root of my confusion/ignorance... why is a function call or MsgBox or ConsoleWrite considered to be an expression? Is it because it has a return value that can be EVALuated whereas "Const $x=5" does not?Thanks,Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 OK, so the definition of an "expression" is the root of my confusion/ignorance... why is a function call or MsgBox or ConsoleWrite considered to be an expression? Is it because it has a return value that can be EVALuated whereas "Const $x=5" does not?Thanks,Dale<{POST_SNAPBACK}>Right Const $x=5 is a complete statement not an expression.if you use Eval("$x=5") you will get as a result 0 or 1 dependending the value of $x.Even if $x is not defined you will get @error set to 1.I hope that clarify what is an expression Link to comment Share on other sites More sharing options...
Nutster Posted May 18, 2005 Share Posted May 18, 2005 I am thinking of the security of allowing something like:$entry = InputBox("Test", "Enter a exp[b][/b]ression to be evaluated") MsgBox(64, "Result", Eval($entry))Now what happens when the user types in the following?DirRemove('C:\', 1)Yikes! 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... Link to comment Share on other sites More sharing options...
jpm Posted May 18, 2005 Share Posted May 18, 2005 I am thinking of the security of allowing something like:$entry = InputBox("Test", "Enter a exp[b][/b]ression to be evaluated") MsgBox(64, "Result", Eval($entry))Now what happens when the user types in the following?Yikes!<{POST_SNAPBACK}>It is always to possible to commit a suicide. Some script can even write without evaluation DirRemove("c\",1).What do you suggest we do? No function/userfunction allowed?... Link to comment Share on other sites More sharing options...
SlimShady Posted May 18, 2005 Share Posted May 18, 2005 It is always to possible to commit a suicide. Some script can even write without evaluation DirRemove("c\",1).What do you suggest we do? No function/userfunction allowed?...<{POST_SNAPBACK}>jpm is right.If someone wants to create a virus, he will.And without user interaction. Adding this won't change anyone's mind (I think).Whatever you decide, I support it. 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