#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 by , 9 years ago
comment:2 by , 9 years ago
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 by , 5 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → 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 by , 5 years ago
I published my function for nested arrays (not read-only).
https://www.autoitscript.com/forum/topic/205675-nested-arrays

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