Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 5 Jahren
Letzter Beitrag:
vor 5 Jahren
Beteiligte Autoren:
Ado, Jose Antonio Garrido, Peter Holemans, ADo, Piet van Zanten

Documentation drives me crazy :)

Startbeitrag von ADo am 08.08.2013 15:06

Hi!

I want to define a dynamic array which holds an array of 7 int, so that i'm able to select one of the array with the 7 int for my procedure.

The Documentation for arrays produces only a bunch of questionmarks...

How to do that?

Thanks!

Best regards
Andreas

Antworten:

*argl* found the solution :(


Limits
Elements of an array
An array can be made of classes only if these classes have a constructor without parameter (or with optional parameters).
An array cannot include:
composite variables,
arrays.


von Ado - am 08.08.2013 15:22
Hi Ado,

But if an array needs to hold another array than we are talking about a multidimensional array. So this definition should work:
MyArr is array of 1 by 7 int

Check out the doc...

Cheers,

Peter

von Peter Holemans - am 09.08.2013 09:47
Hi Ado,

Alternatively you can use an array of structures holding an array.

Regards,
Piet

von Piet van Zanten - am 09.08.2013 09:49
Hi Peter & Piet!

I tried your version Peter but that did not work, i got some weird error messages. I found a solution in using indirection.

After starring to long on the documentation and trying different versions of arrays i found the solution in using indirection - not the elegant one but it worked at least.

Regards
Andreas

von Ado - am 09.08.2013 16:41
Peter: If an array needs to hold another array we are talking about an array of arrays, wich is not possible in WD.

Ado: Why don't you try with Piet suggestion? I think is elegant and with more posibilities (you can add procedures if you use objects instead of structures).

Exmaple (imagine its realted to cars):


Car[1].Speed
Car[1].Accel
//or
Car[1].MyValue[1]
Car[1].MyValue[2]


Regards,
José Antonio.

von Jose Antonio Garrido - am 10.08.2013 13:18
Well, I have been thinking about what Peter said, and....
He is correct.

Declaring an array of array is not allowed, but you can use a multidemensional array:

Myarr[1][1] = 312
Myarr[1][2] = 12

Regards,
José Antonio.

von Jose Antonio Garrido - am 10.08.2013 16:42
Hi Ado,

If you don't want to use multidimensional arrays, you can use the following workaround...

//Class declaration
oIntArray is CLASS
PUBLIC
List is array of int
PROTECTED
PRIVATE

//Use as array in array
MyAofA is array of oIntArray
TmpIntA is oIntArray
TmpIntA:List = [1,2,3,4,5,6,7,8,9,10]
Add(MyAofA,TmpIntA)
TmpIntA:List = [11,12,13,14,15,16,17,18,19,20]
Add(MyAofA,TmpIntA)


Your array of oIntArrayObjects now holds indirectly (via each oIntArray:List) two arrays of int...

This should work like a charm!

Cheers,

Peter H.

von Peter Holemans - am 12.08.2013 08:11
Thanks for all your suggestions, i really appreciate it.

Best regards
Andreas

von Ado - am 13.08.2013 22:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.