Sign in to follow this  
Followers 0
crashdemons

Execute() strange fatal error

6 posts in this topic

#1 ·  Posted (edited)

Before I start:

I am using AutoIt 3.3.0.0

I did not find any direct references to this topic via Search.

I hope that I am not simply restating what is already known.

If I am just restating this, let me know.

- - - - -

I have an issue with Execute($str) causing a script to exit with an error in certain conditions.

The only fatal error I know of for Execute is for recursions that breach the max. (5100)

However, my issue is a bit different as a fatal error after 2 executes.

- My problem -

If an Execute string contains code that calls an Execute and the original string is an invalid expression - then the resulting error seems to be fatal. (guesstimation)

- What I tried -

Execute('Foo()0')

Func Foo()
    Execute('0')
EndFunc

or

Execute('Execute(0)0')

- What I Expected -

I expected @error to be set at the most, not a fatal, horrific, script-ending error

- What I got instead -

Instead I get this fatal error:

C:\Documents and Settings\[snip]\Desktop\bs.au3 (1) : ==> Error in expression.:
Execute('Foo()0')
^ ERROR

Now, indeed executing "Foo()0" is an error'd expression, but it should not be fatal to the entire script.

As an example, Execute("invalid") fails and returns "" with error<>0

After testing more I noted some things:

- The contents of Foo() *are* executed.

- I can do operations inside the function after the second Execute before the fatal error occurs.

- The fatal error seems to occur after the execution of "Foo()" in "Foo()0" finishes.

- This can be reproduced without any user functions: "Execute('Execute(0)0')"

- By modifying the example with )('s, you can get a fatal unbalanced bracket error.

Pure speculation at what is happening:

- Perhaps whatever is keeping track of whether the current execution is inside Execute looses track at the second Execute.

- How I *now* interpreted the flow of execution:

Execute "Foo()0"
{
        Executing part "Foo()"
        {
                Foo()
                {
                        Execute "0"  (succeeds and return 0)
                }
        }
        Executing ....
        Error in expression "Foo()0"
}
Execute ends with a *fatal* error; Error in expression "Execute('Foo()0')"

- My Question -

So, is this a bug?

If not, why not? (fatal error vs. @error)

Edit: cleanup

Edit: "expression" keeps getting replaced with "exp<b></b>ression" in normal code blocks every time I edit

Edit: removed user profile in script path in error message

Edit: typo

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites



Okay, almost 2 years and I still have this same issue.

Any solution?

Share this post


Link to post
Share on other sites

Func repeat($func, $limit)
$i = 1
While $i <= $limit Or $limit == 0
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ' | ' & $i & ') : Execute($func) = ' & Execute($func) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;Execute($func)
$i = $i + 1
WEnd
Return
EndFunc


Execute('Assign("test", 0, 2) repeat("Assign(""test"", 1, 4)", 5) MsgBox(0, "Test", $test)')

Outputs:

>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Program Files (x86)\AutoIt3\testes 2.au3"

@@ Debug(77 | 1) : Execute($func) = 1

>Error code: 0

@@ Debug(77 | 2) : Execute($func) = 1

>Error code: 0

@@ Debug(77 | 3) : Execute($func) = 1

>Error code: 0

@@ Debug(77 | 4) : Execute($func) = 1

>Error code: 0

@@ Debug(77 | 5) : Execute($func) = 1

>Error code: 0

C:\Program Files (x86)\AutoIt3\testes 2.au3 (717) : ==> Error in expression.:

Execute('Assign("test", 0, 2) repeat("Assign(""test"", 1, 4)", 5) MsgBox(0, "Test", $test)')

^ ERROR

->12:37:05 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 4.664

To use Call() i'll need to make many adjustments.

Share this post


Link to post
Share on other sites

Yes, you will need to write it correctly, obviously trying to execute multiple commands on the same line in an Execute isn't going to work because it throws an error when you do it. Just because it runs the function(s) doesn't mean it is the right way to do it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


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
Sign in to follow this  
Followers 0