[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When Writing then reading a multi dim array it is changed to single dim array


Can you write and read it as an array with the dimension specified?
I guess Interger[] does not serialize its dimensions.

Jussi

On Thu, Jul 4, 2024 at 3:03 AM Brian G <brian@xxxxxxxxxxxxxxxx> wrote:

> if I have a multi dimensional array and write it as an object, then read
> it back it becomes a single dimensional array.
>
> The number of entries remain the same, just the dimensions are lost.
>
> I don't know if this a bug or a feature?
>
> sample script
>
> -----------------------------------------------------
>
> #!/usr/bin/env gbs3
>
> Dim a As New Integer[5, 5, 5]
> Dim b As Integer[]
>
> Dim x As Pointer = Alloc(5000)
> Dim mfile As File
>
> mfile = Memory x For Write
> Write #mfile, a As Object
> Close mfile
>
> mfile = Memory x For Read
> b = Read #mfile As Object
>
> Print Subst("Before saving array  count=&1, Dim=&2", a.count, a.dim)
> Print Subst("After reading array  count=&1, Dim=&2", b.count, b.dim)   '
> they don't match
>
> Quit 0
> Catch
> Error "Script Error >";; error.text & "\n" & error.where
>
>
> ------------------------------------------------------------------------------------------
>
> --
> ~~~~ Brian
>
>

Follow-Ups:
Re: When Writing then reading a multi dim array it is changed to single dim arrayJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>