Any ways to warn me of misspelling by like "variables are not declared" etc?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Any ways to warn me of misspelling by like "variables are not declared" etc?

11 Nov 2018, 22:45

I'm completely newbie about code and don't know if it's viable for interpreted language, so plz pardon me if I'm wrong.

I'm just a little discouraged b/c just debugged for half an hour and turns out the reason of a bug is misspelling the variable. like:

Code: Select all

startXHigh[b]t[/b]light := {key1: 320, key2: 20, key3:500, key4:500}
start := startXHighlight["key1"]
MsgBox, % start
The script just behave strangely and didn't report error.

Which editor can warn me this kind of error? I'm using SciTE4AutoHotkey and don't know if it can do this or not. I guess this is the exclusive advantage of compiled language, but maybe there's some ways?
Last edited by pk23 on 16 Nov 2018, 10:04, edited 2 times in total.
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Any ways to warn me of misspelling by like "variables are not declared" etc?

11 Nov 2018, 23:16

Use the #warn directive. (Click on the highlighted word to see the documentation on #warn.)
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
pk23
Posts: 110
Joined: 24 Apr 2015, 00:49

Re: Any ways to warn me of misspelling by like "variables are not declared" etc?

16 Nov 2018, 09:58

TAC109 wrote:
11 Nov 2018, 23:16
Use the #warn directive. (Click on the highlighted word to see the documentation on #warn.)
Ty and sry for reply late. I just learned the #warn directive and may I ask one more questions?
After adding the #warn interpreter, AHK will also exam the #include file and report every one founded. Is there any way to make it only check the current script (without #include file)?
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Any ways to warn me of misspelling by like "variables are not declared" etc?

16 Nov 2018, 17:14

As far as I’m aware, #warn applies to the complete script without exception. You would have to declare all variables before use (which is good programming practice). For local variables in functions, use the local command to specify variables local to the function.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, jaka1, LuckyJoe, Rohwedder and 332 guests