Modify

Opened 7 years ago

Closed 4 years ago

Last modified 3 years 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 7 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 7 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 4 years 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 3 years 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.

in reply to: ↑ description Changed by anonymous

Replying to j0kky:

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.
Author


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

 
Note: See TracTickets for help on using tickets.