functions interpreting non-numeric strings as 0

Report problems with documented functionality
User avatar
Posts: 5740
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
- (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
Posts: 1044
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina

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.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina
(If any of my code written for v2 has stopped working, send me a private message. I appreciate that you correct my English.)
Posts: 3526
Joined: 17 Jul 2016, 01:02

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.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests