[Gambas-user] Struct with Array Field
sharon at 455.co.il
Sat Apr 8 22:31:29 CEST 2023
---------- Original Message -----------
From: "Mayost Sharon" <sharon at 455.co.il>
To: Gambas Mailing List <user at lists.gambas-basic.org>
Sent: Sat, 8 Apr 2023 22:04:15 +0200
Subject: Re: [Gambas-user] Struct with Array Field
> ---------- Original Message -----------
> From: T Lee Davidson <t.lee.davidson at gmail.com>
> To: user at lists.gambas-basic.org
> Sent: Fri, 7 Apr 2023 13:08:35 -0400
> Subject: Re: [Gambas-user] Struct with Array Field
> > On 4/6/23 17:45, Jussi Lahtinen wrote:
> > >
> > > > In c terms which structure are interface for, strings and arrays are just pointer that are not initialized to a value until
> > > > something is assigned to them.
> > > >
> > > > When you do a mstrct = new mystruct it creates the structure with null pointers for those fields.
> > >
> > [snip]
> > >
> > > The topic was *objects *inside structure. They have only null pointers. Variables are valid without further actions.
> > > C does not have "new", but he was referring to the similar things that need to be done in C.
> > >
> > > Jussi
> > Yes, the original topic was arrays (objects) in a structure. To help clarify
> > for the OP, I gave examples of what did or did not need to be explicitly
> > initialized in a structure. Brian's response was to make a false statement
> > which, to help prevent confusion, needed to be corrected.
> > The statement, "When you do a mstrct = new mystruct it creates the structure
> > with null pointers for those fields," does not refer to what happens in C. And,
> > "those fields," obviously refers to "strings and arrays". As I explained, the
> > strings would be automatically initialized, but the arrays would not.
> > Is there anything incorrect about the following statement?
> > Simple native datatypes (such as String, Integer, Boolean) will be
> > automatically initialized. But, objects (such as String, Integer,
> > Boolean), which are objects of classes and have properties and methods,
> > must be initialized with the NEW keyword.
> > --
> > Lee
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> ------- End of Original Message -------
> If I have a structure that contains many array variables, etc.
> If I need to do NEW on every variable that is an array
> Why do I need it inside the structure?
> Is there a way in NEW once to execute on all variables?
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
------- End of Original Message -------
Maybe on purpose as long as you don't set NEW to the array then it remains empty
Public var_01 AS String
As long as I don't make NEW is NULL
But there is an option to make a statement
Public var_01 AS New String
In the structure he does not allow to do
public struct ami_response
string As String
event_list As New String
More information about the User