Custom Query

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (313 - 315 of 3899)

Ticket Resolution Summary Owner Reporter
#2604 Rejected Array access on expression & first element DXRW4E
Description

Sorry for my English

can be enabled (in Array access on expression) to read\access the first item\element directly (without specify it), example

Local $aTest1[4] = [1,2,3,4], $aTest1[4] = ["One","Two","Three","Four"], $aTest3[4][4] = [[0,1,2,3],[4,5,6,7]]
If ($aTest1) = 1 Then
	;ect ect ect
EndIf

If ($aTest2) = "One" Then
	;ect ect ect
EndIf

If ($aTest3) = 0 Then
	;ect ect ect
EndIf

Ciao.

#2283 No Bug Array access when using nested arrays Mat
Description

If arrays are nested then it is not possible to access them using brackets directly.

Local $a1[3] = [0, 0, 0]
Local $a2[3] = [1, 2, 3]

$a1[2] = $a2

;MsgBox(0, "Test", ($a1[2])[1]) ; Works
MsgBox(0, "Test", $a1[2][1]) ; Doesn't

Furthermore, using parenthesis like above to try and assign to that does nothing at all (no error, no effect):

#include<Array.au3>


Local $a1[3] = [0, 0, 0]
Local $a2[3] = [1, 2, 3]

$a1[2] = $a2

($a1[2])[1] = 42

_ArrayDisplay($a1[2])
#2029 Rejected Array and variable handling / suggestion Shaggi
Description
  1. Accessing temporary arrays

This could be a cool feature, and in many cases reduce code in larger expressions. Also, it will solve the problems explained later down. Example:

Func n()
	Local $Array[2] = [1,2]
	Return $Array
EndFunc

MsgBox(0,"",n()[1])
  1. Ability to have 2 variables reference the same content.

This is already working through ByRef parameter passing, however when you return a referenced parameter it creates a copy. Example:

Global $Array[2] = ["foo","foo"]
$Array2 = n($Array)
$Array2[1] = "bar"
ConsoleWrite($Array[0] & @CRLF & $Array[1])

Func n(ByRef $Array)
	Return $Array
EndFunc

This is the same with normal variables.

  1. Nested arrays / Arrays in arrays and linked lists

Since arrays can store other arrays, why cant you access them without getting bounds errors? This seems more like a faulty parsing case than a limitation within autoit:

#include <Array.au3>
Dim $a[2]
Dim $b[2]

$b[0]="foo"
$b[1]="foo"
$a[0] = "bar"
$a[1] = $b

_ArrayDisplay($a)
_ArrayDisplay($a[1])

ConsoleWrite($A[0])
ConsoleWrite($A[1][0]) ;Error

It seems that when arrays are assigned to elements of others, they are stored as temporary variables - maybe this is related to #1? If this could be fixed, it would allow many things - like a more structured design like linked lists or better ability to write something object oriented. As it stands now, the only way to modify the contents of an nested array (without creating a copy of the index, modifying and assigning back) is through byref parameter functions, so you can access the element. Example:

#include <Array.au3>
Dim $a[2]
Dim $b[2]

$b[0]="foo"
$b[1]="foo"

$a[0] = "bar"
$a[1] = $b

_ArrayDisplay($a)
_ArrayDisplay($a[1])
Change($A[1])
_ArrayDisplay($a[1])

Func Change(Byref $A)
	$A[0] = "changed"
EndFunc

It is possible to do it this way, however when you have a nested array (c) inside a nested array (b) in a array (a), it's near impossible to change contents of c without creating a new array - because as #2 states, a ByRef parameter returned is a new copy. And since you can only access nested arrays through ByRef parameters, you actually have to create a recursive byref function, that "dereferences" the array each time. This is a costly process, and pretty stupid. Example:

Func _C_NestChangeVal(ByRef $Obj, $Val, $Ref1 = -1, $Ref2 = -1,$Ref3 = -1)
	Switch @NumParams
		Case 5
			_C_NestChangeVal($Obj[$Ref3],$Val,$Ref1,$Ref2)
		Case 4
			_C_NestChangeVal($Obj[$Ref2],$Val,$Ref1)
		Case 3
			$Obj[$Ref1] = $Val
	EndSwitch
EndFunc

I hope this will be implemented, and since (i think) AutoIt supports it all, it shouldn't be that hard to do.

Note: See TracQuery for help on using queries.