Opened 16 years ago

Closed 16 years ago

#403 closed Bug (No Bug)

Different results for both for loops

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: for loop Cc:


The two available for loops create different results, when nummeric values are used. works as expected (results are numerical values), creates string values from numeric data types. I would expect both loops to do the same in this case.

;For loops create different results with numeric arrays
Dim $Array1[2]
Dim $Array2[2]

For $Item in $Array1
	$Item = 5

For $Index = 0 to 1
	$Array2[$Index] = 5

$Result1 = "Array1[0] is String: " & IsString($Array1[0]) & ", is Number: " & IsNumber($Array1[0])
$Result2 = "Array2[0] is String: " & IsString($Array2[0]) & ", is Number: " & IsNumber($Array2[0])

MsgBox(0, "For loop results", $Result1 & @CR & $Result2)

Attachments (0)

Change History (3)

comment:1 Changed 16 years ago by Valik

Now, give me an example where this matters. AutoIt's variables are variants. It shouldn't matter what the internal type is so long as it behaves correctly when you try to use it.

comment:2 Changed 16 years ago by Ultima

@OP: By any chance, have you bothered to try printing $Array1[0]? You'd easily notice that it *is* an empty string, even after the loop. What you don't seem to realize is that the "For ... In ... Next" loop is for read-only purposes, only. Setting $Item inside the loop does not set the corresponding element in $Array, as you apparently seem to think.

As such, this doesn't look at all like a bug to me.

comment:3 Changed 16 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

Ultima brings up a good point. One that needs documented. As a result I've created #407 and am closing this as no bug.

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.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.