Modify

Opened 8 years ago

Closed 8 years ago

#3166 closed Bug (Fixed)

Error in Arrays wiki

Reported by: lorenzo.santina.dev@… Owned by:
Milestone: Component: Documentation
Version: 3.3.14.2 Severity: None
Keywords: Cc:

Description

At wiki page:
https://www.autoitscript.com/wiki/Arrays#Arrays_in_Arrays

in the seciton Arrays in Arrays there is this sentence:

"The thing is, there is no way to directly access that array stored in the element. You have to go through a variable to get access to the embedded array which may make your code overly complicated and difficult to debug."

This is NOT true.

In fact you CAN directly access the array stored in an element of another array, without go through a variable, doing so:

($arr[0])[0] ;first element of the array stored in the first element of $arr

I rewrote the script example in that page:

Local $arr[3]

Local $a1[3] = [2, "a1-1","a1-2"]
Local $a2[3] = [2, "a2-1","a2-2"]

$arr[0] = 2
$arr[1] = $a1
$arr[2] = $a2

For $i = 1 to $arr[0]
    If IsArray($arr[$i]) Then
        For $j = 1 to ($arr[$i])[0]
            ConsoleWrite("($arr[" & $i & "])[" & $j & "] := " & ($arr[$i])[$j] & @LF)
        Next
    Else
        ConsoleWrite("!>Oops!, What happened? Expected an array!" & @LF)
    EndIf
Next

Please update the wiki

Attachments (0)

Change History (6)

comment:1 Changed 8 years ago by Jpm

I never thought such syntax

($arr[$i])[$j]

was legal.

Is it described in the standard Help?

comment:2 follow-up: Changed 8 years ago by lorenzo.santina.dev@…

Yes, just found in AutoIt Language Reference..
Bottom of the page:
https://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm

"Data types in Arrays"

$aArray[0] = 1
$aArray[1] = True
$aArray[2] = "Text"
$aArray[3] = $aAnotherArray

Local $aInternal[3] = ["A", "B", "C"] ; Declare an array
Local $aContainer[1] = [$aInternal] ; Declare a container array holding the first
$sString = ($aContainer[0])[1] ; $sString holds "B"
; Note the requirement to enclose the first array element definition in ( )

comment:3 follow-up: Changed 8 years ago by TheDcoder

You can manually edit the wiki yourself by clicking edit link after the section's name (Here is the direct link for editing Arrays in Arrays)

comment:4 in reply to: ↑ 2 Changed 8 years ago by Jpm

Replying to lorenzo.santina.dev@…:

Yes, just found in AutoIt Language Reference..
Bottom of the page:
https://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm

"Data types in Arrays"

$aArray[0] = 1
$aArray[1] = True
$aArray[2] = "Text"
$aArray[3] = $aAnotherArray

Local $aInternal[3] = ["A", "B", "C"] ; Declare an array
Local $aContainer[1] = [$aInternal] ; Declare a container array holding the first
$sString = ($aContainer[0])[1] ; $sString holds "B"
; Note the requirement to enclose the first array element definition in ( )

Well done, I never figure out it wasso hard to find
Many thanks

Version 0, edited 8 years ago by Jpm (next)

comment:5 in reply to: ↑ 3 Changed 8 years ago by lorenzo.santina@…

Replying to TheDcoder:

You can manually edit the wiki yourself by clicking edit link after the section's name (Here is the direct link for editing Arrays in Arrays)

I can't see any "edit" button
If I try to login, none username is recognized and I can't find any registration page :/
If I open your link i can't obiously edit the text

comment:6 Changed 8 years ago by Melba23

  • Resolution set to Fixed
  • Status changed from new to closed

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

Action
as closed The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.