[Gambas-user] Struct with Array Field

vuott at tutanota.com vuott at tutanota.com
Wed Apr 5 15:52:25 CEST 2023


With NEW to Struct you create a mere "Object" of that declared Structure.
For each array member, you must create the respective "Object", except for "nested" arrays.



5 apr 2023, 15:43 da sharon at 455.co.il:

> first thanks
>
> Is it supposed to be like this?
> For each field that is an array I will have to say NEW separately
>
> The fields are inside a Struct
> I thought that if I do NEW to Struct
> This will do it on all fields
>
> Thanks
>
>
> ---------- Original Message -----------
> From: vuott--- via User <user at lists.gambas-basic.org>
> To: Gambas Mailing List <user at lists.gambas-basic.org>
> Cc: vuott at tutanota.com
> Sent: Wed, 5 Apr 2023 14:54:52 +0200 (CEST)
> Subject: Re: [Gambas-user] Struct with Array Field
>
>> Solution:
>>
>> Public Struct ami_response
>>   string As String
>>   event_list As String[]
>> End Struct
>>
>> Private v_response_temp As New Ami_response
>>
>> Public Sub Main()
>>
>>   v_response_temp.event_list = New String[]
>>
>>   v_response_temp.event_list.Add("Test")
>>   
>>   Print v_response_temp.event_list[0]
>>
>> End
>>
>> -----
>> 5 apr 2023, 13:26 da sharon at 455.co.il:
>>
>> > Hello
>> >
>> > How to add a Field that is an array inside a Struct
>> >
>> > i tried
>> >
>> > public struct ami_response
>> >  string As String
>> >  event_list As String[]
>> > End Struct
>> >
>> > Private v_response_temp As New Ami_response
>> >
>> > But when:
>> > v_response_temp.event_list.Add("Test")
>> > Returns error: Null Object
>> >
>> > Thank you
>> >
>> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>> >
>>
> ------- End of Original Message -------
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230405/5d3c27ff/attachment.htm>


More information about the User mailing list