Seite 1 von 1

array of array(s)

Verfasst: 27. November 2017, 14:38
von FDominicus
Auch eine Sache, die ich nicht verstehe:

Code: Alles auswählen

PROCEDURE TestProc3()

	tArr1 is array of arrays of 2 int
	tPartArr1 is array of 2 int
	
	tArr2 is Variant
	tPartArr2 is Variant
	
	// tArr1 = [ [1,2],
	// 	     [3,4]]
		     
	tArr2 =  [[ 1,2],
	          [3,4]]
	          
	          
	tPartArr1 = tArr2[1]
	
	tPartArr2 = tArr2[1]	          


Die Initialisierung von tArr1 funktioniert nicht. Eine Zuweisung wie untern von eine Variant zu einem array of 2 int funktioniert und auch die Zuweisung von einer Variant zu einer anderen.

Warum kann man tArr1 nicht so initialisieren?

funktionieren tut:

Code: Alles auswählen

  ArrayInsert(tArr1, 1, [1,2])
  ArrayInsert(tArr1, 2, [3,4])


Re: array of array(s)

Verfasst: 28. November 2017, 21:33
von Herbert
Mach es so:

tarr1 is array of 2,2 int

gemäss: http://doc.windev.com/?1514030&lang=en- ... APHE000190

Re: array of array(s)

Verfasst: 30. November 2017, 14:49
von FDominicus

Code: Alles auswählen


PROCEDURE TestProc3()

	tArr1 is array of 2,2 int
	tPartArr1 is array of 2 int
	
	tArr2 is Variant
	tPartArr2 is Variant
	
	tArr3 is array of arrays of 2 int
	
	// ArrayInsert(tArr1, 1, [1,2])
	// ArrayInsert(tArr1, 2, [3,4])
	// // 	     [3,4]]
	
	tArr1[1] = [1,2]
	tArr1[2] = [3,4]
		     
	tArr2 =  [[ 1,2],
	          [3,4]]
	          
	          
	tPartArr1 = tArr1[1]
	
	tPartArr2 = tArr2[1]	          


Ergibt Fehler:
Error:Array with 2 dimension(s): unable to access it with 1 dimension(s).
GlobalProcedures.TestProc3, Local Procedure, line 22, column 19
Error:Array with 2 dimension(s): unable to access it with 1 dimension(s).
GlobalProcedures.TestProc3, Local Procedure, line 16, column 7
Error:Array with 2 dimension(s): unable to access it with 1 dimension(s).
GlobalProcedures.TestProc3, Local Procedure, line 15, column 7
Warning : The local variable 'tArr3' is not used.
GlobalProcedures.TestProc3, Local Procedure, line 9, column 2

Was ich haben möchte ist schon ein Feld mit einem Feld von 2 int Elementen

Also [[1,2],[3.4]]
Und FeldAussen[1] = [1,2]

Jedenfalls klappt es mit Array Insert genau so.

Code: Alles auswählen

PROCEDURE TestProc3()

	tArr1 is array of array of 2 int
	tPartArr1 is array of 2 int
	
	tArr2 is Variant
	tPartArr2 is Variant
	
	tArr3 is array of arrays of 2 int
	
	ArrayInsert(tArr1, 1, [1,2])
	ArrayInsert(tArr1, 2, [3,4])
	// // 	     [3,4]]
	
	tPartArr1 = tArr1[1]
	
	tPartArr2 = tArr2[1]	       


Gehe ich über die Vaiant Schiene funktioniert es auch ohne Probleme

Re: array of array(s)

Verfasst: 30. November 2017, 17:44
von Herbert
Klar geht das.
Nur ist ArrayInsert für 1-dim Arrays. Siehe Beschreibung.
https://doc.windev.com/en-US/?3075009&name=ArrayInsert