functions interpreting non-numeric strings as 0

Report problems with documented functionality
User avatar
jeeswg
Posts: 5149
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.)
User avatar
Flipeador
Posts: 1018
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
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.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2 My GDI+ Library
Helgef
Posts: 3195
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: No registered users and 3 guests