Opened 9 years ago
Closed 6 years ago
#3559 closed Feature Request (Fixed)
ArrayAdd item-delimited string erroneously stores Booleans as strings / Feature request func Bool()
| Reported by: | RTFC | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
Hi devs.
This is a combined Bug report + feature request. Example below.
Global $test[1][2] $test[0][0]=False $test[0][1]=True _ArrayAdd($test,False & "|" & True) for $cc=0 to 1 ConsoleWrite(IsBool($test[$cc][0]) & ", " & IsBool($test[$cc][1]) & @CRLF) Next
Note how the first row contains Booleans, but the second row does not.
This can be solved by adding a function Bool() that forces the contained expression to be evaluated as/converted into a boolean (in analogy to Number() & IsNumber(), Ptr() & IsPtr(), etc)
The fix for the above bug would then be to write:
_ArrayAdd($test,Bool(False) & "|" & Bool(True))
and/or _ArrayAdd would have to be smart enough to detect the difference between "True" and True, "False" and False.
Cheers,
RT
Attachments (0)
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Hi M23, thanks for having a look. I was trying to avoid having to construct temporary row arrays, and was wondering whether alternatives were possible. A boolean $iForce option would be a great help.
Related to this, it struck me as odd that function pairs Number()/IsNumber() and Ptr()/IsPtr() are not matched for Bool()/IsBool(). I think Bool() would be useful to have, but that's up to the devs, of course.
Thanks again and all the best,
RT
comment:3 by , 9 years ago
| Type: | Bug → Feature Request |
|---|
comment:5 by , 6 years ago
| Resolution: | → Fixed |
|---|---|
| Status: | new → closed |
$ARRAYFILL_FORCE_BOOLEAN added in 3.3.14.4

If you want to retain elements datatypes when adding to an array then do as the Help file suggests and add them as an array:
Looking at the _ArrayAdd code it should be relatively easy to add another $iForce option to retain Boolean datatypes - I will take a look.
M23