Opened 7 years ago
Closed 4 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 Changed 7 years ago by Melba23
comment:2 Changed 7 years ago by RTFC
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 Changed 7 years ago by Melba23
- Type changed from Bug to Feature Request
comment:5 Changed 4 years ago by Melba23
- Resolution set to Fixed
- Status changed from new to closed
$ARRAYFILL_FORCE_BOOLEAN added in 3.3.14.4
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
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