Error: No object to invoke

Discuss the future of the AutoHotkey language

Should this error be removed?

Poll ended at 27 Jul 2014, 10:57

No, keep it as it is
1
17%
Yes, revert back to return empty string
1
17%
Make it optional and return empty string by default
4
67%
Make it optional and throw error by default
0
No votes
 
Total votes: 6
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Error: No object to invoke

07 Jul 2014, 23:03

arcticir,
You don't want to use IsObject() a lot? Then don't.

Code: Select all

HU.INI := IniToObj("hy.ini") || {}

locale := HU.INI.HY && HU.INI.HY.locale || "EN"

Run, % (HU.INI.Browser ? HU.INI.Browser.Chrome || HU.INI.Browser.Opera : "") " " (HU.INI.ip && HU.INI.ip.google || "www.google.com")
It's shorter than before...

You could write it exactly as before, but override __Get so that HU.INI.whatever always returns an object. If the INI file doesn't exist, have IniToObj() return an empty INI object.

There's nothing to stop you from changing the error behaviour yourself, if you don't mind sacrificing compatibility with other scripts/code. You can still override the default base object's meta-functions.
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: Error: No object to invoke

07 Jul 2014, 23:47

Thanks.

but it could have been more succinct:

Code: Select all

locale := HU.INI.HY.locale || "EN"


Is it possible error As an alternative option,Such as voting results?
I believe most people like me do not need this feature
While we want AHK more rigorous,Think is an improvement
But more often we need to write code easily.
Prevent rigorous Become a burden。
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Skip/disable/handle & Use default base

08 Jul 2014, 08:13

arcticir wrote:Is it possible error As an alternative option,Such as voting results?
Yes, see
lexikos wrote:You can still override the default base object's meta-functions.
Then could disable it or handle error (when access a string as object ) by themselves.
I think to skip the error is fine, maybe user only want to determine it from the last result (not in every step ).

Relative : V2 garbled data using default base (Default base used for skip and log 'no object to invoke' error.)
Last edited by RobertL on 01 Oct 2014, 20:54, edited 2 times in total.
我为人人,人人为己?
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: Error: No object to invoke

30 Sep 2014, 23:37

I regret, why not choose the voting result. :(

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 70 guests