Modify

Opened 5 years ago

Closed 11 months ago

Last modified 5 months ago

#3515 closed Feature Request (Rejected)

Assigning directly a value to an element of an array in array

Reported by: j0kky Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: array in array Cc:

Description

If you want to assign a value to an element of an array contained in another array, you should use another function with a ByRef parameter, it could be useful if we could assign directly that value, this is an example that works:

Local $a[3] = [1, 2], $b[3] = [3, 4]
$a[2] = $b
ModArray($a[2], 2, "Test")
ConsoleWrite(($a[2])[2] & @CRLF)

Func ModArray(ByRef $aArray, $iElement, $value)
    $aArray[$iElement] = $value
EndFunc

If I try to assign directly the value writing

($a[2])[2] = "Test"

I get the error:

Statement cannot be just an expression.

Attachments (0)

Change History (4)

comment:1 Changed 5 years ago by Jos

That error comes from au3check, not autoit3.
Don't think this format is supported anyways and doesn't work when ran without au3check.

Jos

comment:2 Changed 5 years ago by j0kky

It could be useful if the syntax:

(array)[element] = value

was accepted by Au3Check and correctly parsed by AutoIt3.
In fact, it will be useless for simple arrays, but it will be fundamental for array in array.

By now, the syntax

(array)[element]

is accepted only for reading values and this code returns the same error too:

Local $a[2]
($a)[0] = 1

comment:3 Changed 11 months ago by Jpm

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

Hi,
sorry to be so late on the subject.
what you propose is to do expression evaluation on the left side of a statement.
Such evaluation can only be done on the right side during the evaluation of an expression.
We will not make any improvement on such laft side statement

comment:4 in reply to: ↑ description Changed 5 months ago by kovlad

I published my function for nested arrays (not read-only).
https://www.autoitscript.com/forum/topic/205675-nested-arrays

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.