Modify

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 Melba23, 9 years ago

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:

#include <Array.au3>

Global $aTest[1][2] = [[False, True]]

Global $aAdd[1][2] = [[False, True]]

_ArrayAdd($aTest, $aAdd)

For $cc = 0 To 1
	ConsoleWrite(IsBool($aTest[$cc][0]) & ", " & IsBool($aTest[$cc][1]) & @CRLF)
Next

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

comment:2 by RTFC, 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 Melba23, 9 years ago

Type: BugFeature Request

comment:4 by TicketCleanup, 9 years ago

Version: 3.3.14.0

Automatic ticket cleanup.

comment:5 by Melba23, 6 years ago

Resolution: Fixed
Status: newclosed

$ARRAYFILL_FORCE_BOOLEAN added in 3.3.14.4

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.