[Gambas-user] Way to create dynamic Arrays
Gianluigi
gradobag at gradobag.it
Tue Aug 15 22:44:24 CEST 2023
Il 15/08/23 22:03, Jussi Lahtinen ha scritto:
> Next time it is better to attach a small project to illustrate your
> problem. Many times (like this one) the problem is not in the given code.
> However, you should not use "Samples" as variable name twice, once for
> public and once for the local.
>
> Jussi
>
> On Tue, Aug 15, 2023 at 10:47 PM Hartmut Wagener
> <hartmut.w.wagener at t-online.de> wrote:
>
> I have tried the dynamic arrays.
>
> I created an array
>
>
> Public Samples as Short[]
>
>
> Inside the program i used
>
>
> Dim Samples As New Short[countSamples]
>
>
> to add an array-entry.
>
>
> countSamples is incremented each new Sample.
>
>
> The program runs through the readin-phase, but there is no array
> created
> with all the samples.
>
>
> What is wrong?
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
> ----[http://gambaswiki.org/wiki/doc/netiquette ]----
Can this help?
'----------------------
Public Sub Main()
Dim countSamples As Short = 10
Dim Samples As New Short[countSamples]
For s As Short = 0 To countSamples - 1
Samples[s] = s
Print Samples[s]
Next
Samples.Clear
Print "--"
For s = 0 To countSamples + 10
Samples.Push(s)
Print Samples[s]
Next
End
'-------------------
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230815/863bc4b4/attachment.htm>
More information about the User
mailing list