Modify

Opened 21 months ago

Last modified 20 months ago

#4020 assigned Bug

ConsoleWrite do not preserve @error

Reported by: Zvend Owned by: Jon
Milestone: Component: AutoIt
Version: 3.3.16.1 Severity: None
Keywords: Cc:

Description

The helpfile for ConsoleWrite says


"The @error and @extended are not set on return leaving them as they were before calling. Usefull when debugging with the SciTE debugging output."


Sadly it is not true...

Test()
ConsoleWrite(@error & @CRLF)



Func Test()
    SetError(1, 0)

    ConsoleWrite("Test" & @CRLF)

    Return
EndFunc

Attachments (0)

Change History (5)

comment:1 by Jos, 21 months ago

It looks like when a ConsoleWrite is used in the Func, the @error is not kept in the return information. These 2 versions work fine, where as the OP's script indeed doesn't work:

Test1()
ConsoleWrite("Test1 master:" & @error & @CRLF)
Func Test1()
	SetError(1)
	Return
EndFunc   ;==>Test1

Test2()
ConsoleWrite("Test2 master:" & @error & @CRLF)
Func Test2()
	SetError(1)
	ConsoleWrite("Test2 func:" & @error & @CRLF)
	Return SetError(@error)
EndFunc   ;==>Test2
Last edited 21 months ago by Jos (previous) (diff)

comment:2 by anonymous, 20 months ago

This ticket appears to be wrong... ConsoleWrite does work as documented in 3.3.16.1 !
Here's a wee better snippet demonstrating the behavior, comments say it all:

Test1()
ConsoleWrite("Test1 1: " & @error & @CRLF) ; 1234,  as expected, 
;in versions 3.15.0/1/2/3/4, 3.16.0/1

ConsoleWrite("Test1 2: " & @error & @CRLF) ; 1234  ONLY in 3.15.4 
; and 3.16.1; notably, 0(zero)  in 3.16.0!

Func Test1()
        SetError(1234)
        Return
EndFunc   ;==>Test1

Test2()
ConsoleWrite("Test2 1: " & @error & @CRLF) ; 1234 in 3.15.4 and 3.16.1, zero in other versions.
ConsoleWrite("Test2 2: " & @error & @CRLF) ; 1234 in 3.15.4 and 3.16.1, zero in other versions.
Func Test2()
        SetError(1234)
        ConsoleWrite("Test2 func 1: " & @error & @CRLF) ; 1234,  as expected, in 3.15.0 - 3.16.1
        ConsoleWrite("Test2 func 2: " & @error & @CRLF) ; 1234 in 3.15.4 and 3.16.1, zero in other versions.
        Return ; note the absence of SetError(@error); it's unnecessary for versions 3.15.4 and 3.16.1
        ; in other versions ConsoleWrite simply does NOT preserve @error, so SetError(@error) here would be useless.
EndFunc   ;==>Test2

comment:3 by anonymous, 20 months ago

also, the title is... inadequate! this ticket has nothing to do with SetError! SetError does, and always did, work as expected/documented.

comment:4 by J-Paul Mesnage, 20 months ago

Summary: SetError not working properlyConsoleWrite do not preserve @error

comment:5 by J-Paul Mesnage, 20 months ago

Owner: set to Jon
Status: newassigned

Fix sent to Jon

Modify Ticket

Action
as assigned The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.