array of array(s)

Alle Themen rund um die Erstellung von Programmen
Antworten
FDominicus
Member
Beiträge: 65
Registriert: 9. Mai 2015, 08:19

array of array(s)

Beitrag 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])


Herbert
Site Admin
Beiträge: 529
Registriert: 23. Februar 2010, 08:06
Wohnort: Langenthal, Schweiz
Kontaktdaten:

Re: array of array(s)

Beitrag von Herbert »

Mach es so:

tarr1 is array of 2,2 int

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

FDominicus
Member
Beiträge: 65
Registriert: 9. Mai 2015, 08:19

Re: array of array(s)

Beitrag 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

Herbert
Site Admin
Beiträge: 529
Registriert: 23. Februar 2010, 08:06
Wohnort: Langenthal, Schweiz
Kontaktdaten:

Re: array of array(s)

Beitrag von Herbert »

Klar geht das.
Nur ist ArrayInsert für 1-dim Arrays. Siehe Beschreibung.
https://doc.windev.com/en-US/?3075009&name=ArrayInsert

Antworten