Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
When you are declaring the array by writing A[3] As Single you declare an inline array, i.e. NOT a reference to an array. So you cannot write ThatStruct.A = AnArray. Instead you have to copy the contents from AnArray into A. 2012/7/4 Kevin Fishburne kevinfishbu...@eightvirtues.com On 07/04/2012 12:06 AM, Kevin Fishburne wrote: I need to create a 2D array of a structure like this: Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] When I try to assign a value to an array element like this: Normals[TileGridX, TileGridY].A = Convert.Normal(P1, P2, P3) I get a null object error. While the 2D array of structures seems to be created correctly, all its initial values are indeed null. Do I need to create the structure or array differently so I can properly assign values to it? Previously I knew all the dimensions of my arrays of structures so they were statically defined, but in this case I don't know the array dimensions until after the program has started running. Thanks everyone. One addition. I've discovered that if I publicly declare a 2D array of the structure it shows bad number of dimensions and out of bounds errors when I double-click it after creation: ' Tile grid normal structure. Public Struct Tile_Normals A As Single[] ' Normal for quad subsurface A. B As Single[] ' Normal for quad subsurface B. End Struct Public Normals[32, 32] As Struct Tile_Normals Declaring it as a 1D array it behaves normally: ' Tile grid normal structure. Public Struct Tile_Normals A As Single[] ' Normal for quad subsurface A. B As Single[] ' Normal for quad subsurface B. End Struct Public Normals[32] As Struct Tile_Normals It also doesn't make any difference if I define the structure like this: ' Tile grid normal structure. Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Maybe that's related to what's happening, or a separate issue? -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
On 07/04/2012 05:42 AM, Emil Lenngren wrote: When you are declaring the array by writing A[3] As Single you declare an inline array, i.e. NOT a reference to an array. So you cannot write ThatStruct.A = AnArray. Instead you have to copy the contents from AnArray into A. I'm not sure how to go about copying the contents, as even this gives me a null object error: Public Struct Surface_Normal N As Single[] End Struct Dim NormalsA As New Surface_Normal[TileGrid.Size + 2, TileGrid.Size + 2] NormalsA[0, 0].N[0] = 0 I spent about an hour last night trying every combination of declarations and assignments I could think of, all with various errors. Initially I wanted a structure so I could have a 2D array with each element having an A and B vector, but now I'm searching for ANY way to get it done. How can I declare a 2D array whose element is a 1D array of three singles? Despite reading the docs again and again I'm not clear on the syntax. -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
On Wed, 04 Jul 2012, Kevin Fishburne wrote: On 07/04/2012 05:42 AM, Emil Lenngren wrote: When you are declaring the array by writing A[3] As Single you declare an inline array, i.e. NOT a reference to an array. So you cannot write ThatStruct.A = AnArray. Instead you have to copy the contents from AnArray into A. I'm not sure how to go about copying the contents, as even this gives me a null object error: Public Struct Surface_Normal N As Single[] End Struct Dim NormalsA As New Surface_Normal[TileGrid.Size + 2, TileGrid.Size + 2] NormalsA[0, 0].N[0] = 0 I spent about an hour last night trying every combination of declarations and assignments I could think of, all with various errors. Initially I wanted a structure so I could have a 2D array with each element having an A and B vector, but now I'm searching for ANY way to get it done. How can I declare a 2D array whose element is a 1D array of three singles? Despite reading the docs again and again I'm not clear on the syntax. -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user You could have a one-dimensional Variant[] which contains other Variant[] (and so on n times) to get an n-dimensional matrix... -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
Le 04/07/2012 06:06, Kevin Fishburne a écrit : I need to create a 2D array of a structure like this: Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] -- There Tile_Normals is used like a class, not a structure. You must initialize each element of the array with a new Tile_Normals object (in other words, you can use a normal class instead of a structure). Or you can use embedded array of structures: Private Normals[10, 10] As Struct Tile_Normals But then the size of the array must be known at compile time! -- Benoît Minisini -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
As Benoît says, Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] only gives an array where you can store references to Tile_Normals. You also have to do: Dim I As Integer Dim J As Integer For I = 0 To TileGrid.Size - 1 For J = 0 To TileGrid.Size - 1 Normals[I, J] = New Tile_Normals Next Next Otherwise you will get null object errors. /Emil 2012/7/4 Benoît Minisini gam...@users.sourceforge.net Le 04/07/2012 06:06, Kevin Fishburne a écrit : I need to create a 2D array of a structure like this: Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] -- There Tile_Normals is used like a class, not a structure. You must initialize each element of the array with a new Tile_Normals object (in other words, you can use a normal class instead of a structure). Or you can use embedded array of structures: Private Normals[10, 10] As Struct Tile_Normals But then the size of the array must be known at compile time! -- Benoît Minisini -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
Le 04/07/2012 06:06, Kevin Fishburne a écrit : I need to create a 2D array of a structure like this: ... By the way, Kevin, did you try the jit compiler for your game? -- Benoît Minisini -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] gb3: using array of structures with dimensions unknown until runtime
I need to create a 2D array of a structure like this: Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] When I try to assign a value to an array element like this: Normals[TileGridX, TileGridY].A = Convert.Normal(P1, P2, P3) I get a null object error. While the 2D array of structures seems to be created correctly, all its initial values are indeed null. Do I need to create the structure or array differently so I can properly assign values to it? Previously I knew all the dimensions of my arrays of structures so they were statically defined, but in this case I don't know the array dimensions until after the program has started running. Thanks everyone. -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] gb3: using array of structures with dimensions unknown until runtime
On 07/04/2012 12:06 AM, Kevin Fishburne wrote: I need to create a 2D array of a structure like this: Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Dim Normals As New Tile_Normals[TileGrid.Size, TileGrid.Size] When I try to assign a value to an array element like this: Normals[TileGridX, TileGridY].A = Convert.Normal(P1, P2, P3) I get a null object error. While the 2D array of structures seems to be created correctly, all its initial values are indeed null. Do I need to create the structure or array differently so I can properly assign values to it? Previously I knew all the dimensions of my arrays of structures so they were statically defined, but in this case I don't know the array dimensions until after the program has started running. Thanks everyone. One addition. I've discovered that if I publicly declare a 2D array of the structure it shows bad number of dimensions and out of bounds errors when I double-click it after creation: ' Tile grid normal structure. Public Struct Tile_Normals A As Single[] ' Normal for quad subsurface A. B As Single[] ' Normal for quad subsurface B. End Struct Public Normals[32, 32] As Struct Tile_Normals Declaring it as a 1D array it behaves normally: ' Tile grid normal structure. Public Struct Tile_Normals A As Single[] ' Normal for quad subsurface A. B As Single[] ' Normal for quad subsurface B. End Struct Public Normals[32] As Struct Tile_Normals It also doesn't make any difference if I define the structure like this: ' Tile grid normal structure. Public Struct Tile_Normals A[3] As Single ' Normal for quad subsurface A. B[3] As Single ' Normal for quad subsurface B. End Struct Maybe that's related to what's happening, or a separate issue? -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user