[Ahk2] How to disable "Type mismatch"?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
HakitoJin
Posts: 17
Joined: 02 Oct 2016, 17:20

[Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 15:01

I just want my invalid expressions to return null like they used to, is that too much to ask?

Object warnings were annoying too until I found how to disable them in the documentation, so I'm hoping there's something for mismatch too.
Here's the code for that unrelated object warning thing, just call it once:

Code: Select all

NoObjectWarn() ;From Autohotkey's V2 Documentation, find it by going to "Object" and then "Debugging"
{
	Static Enabled
	iF not Enabled
		"".base.__Get:="".base.__Set:="".base.__Call:=Func("NoObjectWarn") , Enabled:=1
    return
}
Type mismatch must die.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 15:27

NO. This helps a lot when it comes to detecting errors, it is one of the best things that have been implemented. v1 is disgusting, v2 is a little more serious.
Anyway, you can always stay using v1.
HakitoJin
Posts: 17
Joined: 02 Oct 2016, 17:20

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 15:48

Type mismatch IS the error though.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 17:05

"Type mismatch" is an error message, not the error. The error is what you've done to cause the error message: attempted to perform math on an invalid value. You don't want to prevent the error; you want to change how the script reacts to the error.

The only way to do that is to modify the program itself, in C++.
HakitoJin
Posts: 17
Joined: 02 Oct 2016, 17:20

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 17:32

lexikos wrote:"Type mismatch" is an error message, not the error.
Yes I know, I am just saying it's as bad as an error message, and now I can't do iF(x+y="") to check if one of two numbers is empty, nor iF(x&1) to check for even numbers.
lexikos wrote:The only way to do that is to modify the program itself, in C++.
So... why wasn't the old way of dealing with errors kept as an option?
Surely performance is not the issue, because there's no way manually initializing variables using AHK is faster than having it done automatically in C++.
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 17:54

You can not do it that way because it is not what corresponds. V1 is full of bad programming practices, this is a clear example. You are trying to make something work in a very dirty way.
To check if it is a number use is or the Type function.
I think you should stay with v1.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: [Ahk2] How to disable "Type mismatch"?

25 Aug 2018, 17:55

HakitoJin wrote: and now I can't do iF(x+y="") to check if one of two numbers is empty, nor iF(x&1) to check for even numbers.
exactly. THESE are your errors. its not the error message's fault.

see Flipeador above for "is a number"

and to check for even numbers you should use Mod()
https://autohotkey.com/docs/commands/Math.htm#Mod


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 436 guests