functions interpreting non-numeric strings as 0

Report problems with documented functionality
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

functions interpreting non-numeric strings as 0

20 Aug 2018, 15:30

- Certain functions appear to be interpreting non-numeric strings as 0

Code: Select all

q:: ;non-number interpreted as 0 (a blank string is the expected output)
MsgBox, % Round(3.5, "a") ;4
MsgBox, % InStr("tttt", "t", 0, "a") ;4
MsgBox, % StrReplace("tttt", "t", "r",, "a") ;tttt
return
- (I was working on some custom AHK functions in C++, and wanted to see how the built-in functions identified non-numeric strings in parameters that aren't the 1st parameter, but it appears that they don't currently do this!)
- (For some functions, interpreting a non-numeric string as 0 will give a blank string by coincidence.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: functions interpreting non-numeric strings as 0

20 Aug 2018, 16:00

Also some AHKv2 functions do not throw exceptions. :shock: Although coming from v1 nothing surprises me.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: functions interpreting non-numeric strings as 0

20 Aug 2018, 16:54

It is a bug, in your code, you are not using the functions as documented. The parameters are documented as numbers. Unless there is any documentation stating that parameters are verified, this is not a bug in the program, but rather a limitation of the implementation, or a design choice if you like. It is not limited to functions.

Hopefully this will cause exceptions in v2, a blank string in v1 would be more suitable.

Cheers.

Return to “Bug Reports”

Who is online

Users browsing this forum: CrowexBR and 38 guests