Page 1 of 1

early exit from #Warn loadtime error messages

Posted: 02 Dec 2019, 21:34
by jeeswg
If you use #Warn, and have local variables (not defined as local) with the same names as global variables, in a script, you can get a long stream of loadtime error messages.

This is a recurring problem when adding #Warn to old scripts, or using/including scripts by other people.

Code: Select all

#Warn

a := b := c := d := e := ""
f := g := h := i := j := ""
k := l := m := n := o := ""
p := q := r := s := t := ""
u := v := w := x := y := ""
z := ""
return

MyFunc()
{
	;local ;add this line to prevent the error messages
	a := b := c := d := e := ""
	f := g := h := i := j := ""
	k := l := m := n := o := ""
	p := q := r := s := t := ""
	u := v := w := x := y := ""
	z := ""
}

Note: at loadtime, there is no AHK tray icon with which to close the script.

Possible solutions could be:
- add a 'No' button to the MsgBox, to allow you to close the script
- state the script's PID in the loadtime error messages, so that you can find the AHK process in Task Manager and close it that way

Btw, is there any tidy way to close AHK during those loadtime messages, or must you force close the process? Thanks.

Re: early exit from #Warn loadtime error messages

Posted: 15 Jan 2020, 23:28
by Cerberus
I have experienced this issue as well, would be nice if some fix or work-around were introduced at some point.

Re: early exit from #Warn loadtime error messages

Posted: 16 Jan 2020, 21:21
by lmstearn
Doesn't this do anything?

Code: Select all

#Warn, LocalSameAsGlobal,  Off
Recommended use is for a debugger:

Code: Select all

#Warn All, OutputDebug
#Warn, LocalSameAsGlobal,  Off