Hi Robert, Chris, any guy who knows,
Please help me get the correct syntax for declaring and initializing a 2D 'rectangular' array of the .NET variety.
So far in my research on Arrays I have been doing okay - until I hit the wall just now trying to convert the attached C# code.
TIA,
Phil.
P.S. here is some syntax which I got to work for me :-
2D 'matrix' .NET arrays - HELP syntax !!!
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
-
- Posts: 176
- Joined: Sat Dec 05, 2015 10:44 am
- Location: Germany
2D 'matrix' .NET arrays - HELP syntax !!!
Hi Phil, Chris,
this works
but this
gives XS9008 Untyped arrays are not available in the selected dialect 'Core'
Here
XS9002: Parser: unexpected input 'numbersTwo'
The same with
Sorry, I'm not the guy who knows
Frank
this works
Code: Select all
LOCAL numbersOne AS INT[]
numbersOne := <INT>{1,2,3,4,5,6}
Code: Select all
LOCAL numbersTwo AS INT[,]
numbersTwo := {{1,2},{3,4},{5,6}}
Here
Code: Select all
numbersTwo := <INT>,<INT>{{1,2},{3,4},{5,6}}
The same with
Code: Select all
numbersTwo := <<INT>,<INT>>{{1,2},{3,4},{5,6}}
Frank
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
2D 'matrix' .NET arrays - HELP syntax !!!
Yep! - Frank,
Now you see how I was getting into a mess - I think I tried just about every sensible (and desperate) combination of syntaxes - I got a lot of .... selected dialect 'Core' error messages.
Its the 2D, 3D, .... XD which is giving me issues.
Hopefully Robert, Chris, Nikkos may be able to shed some light :unsure:
HELP still required !
Phil.
Wales, UK.
Now you see how I was getting into a mess - I think I tried just about every sensible (and desperate) combination of syntaxes - I got a lot of .... selected dialect 'Core' error messages.
Its the 2D, 3D, .... XD which is giving me issues.
Hopefully Robert, Chris, Nikkos may be able to shed some light :unsure:
HELP still required !
Phil.
Wales, UK.
-
- Posts: 176
- Joined: Sat Dec 05, 2015 10:44 am
- Location: Germany
2D 'matrix' .NET arrays - HELP syntax !!!
Hi Phil,
look what I found in old code:
LOCAL avals AS Double[][]
avals := <Double[]>{<Double>{1.0, 4.0, 7.0, 10.0}, <Double>{2.0, 5.0, 8.0, 11.0}, <Double>{3.0, 6.0, 9.0, 12.0}}
But realise: Double[][] is not the same as Double[,]. It is an one dimensional array of one dimensional arrays.
With that construction we can get a complete column of values by
local oneColumn as Double[]
oneColumn := avals[0] // One dimensional access to the first column.
oneColumn:Length is 4 now.
This lets us sort rows or rearrange arrays a little bit easier.
Frank
look what I found in old code:
LOCAL avals AS Double[][]
avals := <Double[]>{<Double>{1.0, 4.0, 7.0, 10.0}, <Double>{2.0, 5.0, 8.0, 11.0}, <Double>{3.0, 6.0, 9.0, 12.0}}
But realise: Double[][] is not the same as Double[,]. It is an one dimensional array of one dimensional arrays.
With that construction we can get a complete column of values by
local oneColumn as Double[]
oneColumn := avals[0] // One dimensional access to the first column.
oneColumn:Length is 4 now.
This lets us sort rows or rearrange arrays a little bit easier.
Frank
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
2D 'matrix' .NET arrays - HELP syntax !!!
Hi Frank,
Yes, and thanks ;-0) for the tip and sharing.
This is called a 'jagged array' I believe, and as you can see in the image of my eNotes sections the one I want is a 'multi-dimensional array' :-
And I will do 'Mixed' arrays as well.
Your previous help with __ARRAYBASE__ has worked out very well this afternoon - THANKS!
Phil.
Yes, and thanks ;-0) for the tip and sharing.
This is called a 'jagged array' I believe, and as you can see in the image of my eNotes sections the one I want is a 'multi-dimensional array' :-
And I will do 'Mixed' arrays as well.
Your previous help with __ARRAYBASE__ has worked out very well this afternoon - THANKS!
Phil.
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
2D 'matrix' .NET arrays - HELP syntax !!!
Hi Frank,
Following your syntax 'format' and others similar, the following seems the most likely to be correct I feel. But it does not work for me in X#.
I have a gut feeling that the compiler may not be 100% on the topic of multi-dimensional arrays.
We need to wait for Robert and his TEAM![Wink ;-)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
Cheers,
Phil.
Following your syntax 'format' and others similar, the following seems the most likely to be correct I feel. But it does not work for me in X#.
I have a gut feeling that the compiler may not be 100% on the topic of multi-dimensional arrays.
We need to wait for Robert and his TEAM
![Wink ;-)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_wink.gif)
Cheers,
Phil.
2D 'matrix' .NET arrays - HELP syntax !!!
Hi guys,
Sorry for the delay, I was also trying to find out if it's a bug or feature that this is not working currently![Smile :)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_smile.gif)
I think it's a mixup, the compiler confuses the VO-style ARRAY syntax with the .Net style array initialization here. I'll log this as a bug so it will be taken care off, for now you'll need to initialize the array elements the old-fashioned way (a[1,1] := 1 etc).
Chris
Sorry for the delay, I was also trying to find out if it's a bug or feature that this is not working currently
![Smile :)](https://dt9qzg9h465rt.cloudfront.net/phpBB3/images/smilies/icon_e_smile.gif)
I think it's a mixup, the compiler confuses the VO-style ARRAY syntax with the .Net style array initialization here. I'll log this as a bug so it will be taken care off, for now you'll need to initialize the array elements the old-fashioned way (a[1,1] := 1 etc).
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
2D 'matrix' .NET arrays - HELP syntax !!!
Thanks Chris,
I had a feeling something not quite right was up ! Thanks for getting back to us.
For now I will do as you say and get on with researching and writing the rest of my session material and eNotes for Cologne 2018.
If I find anything else 'odd' I will get back to you.
Best wishes,
Phil.
Wales, UK.
I had a feeling something not quite right was up ! Thanks for getting back to us.
For now I will do as you say and get on with researching and writing the rest of my session material and eNotes for Cologne 2018.
If I find anything else 'odd' I will get back to you.
Best wishes,
Phil.
Wales, UK.
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
2D 'matrix' .NET arrays - HELP syntax !!!
Hi Frank,
Thanks for the jagged array sample reminder.
I used it this afternoon to research and add detail to the sub-section in my ClickStart eNotes on Arrays in X# code syntax.
I attach a small sample image.
My brain now dead, and time for tea ;-0)
Cheers,
Phil.
Thanks for the jagged array sample reminder.
I used it this afternoon to research and add detail to the sub-section in my ClickStart eNotes on Arrays in X# code syntax.
I attach a small sample image.
My brain now dead, and time for tea ;-0)
Cheers,
Phil.