[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


I don't understand, how do you write them separately 

~~~~~ Brian


From: user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx> on behalf of Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
Sent: Wednesday, July 3, 2024 5:27:19 PM
To: user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: When Writing then reading a multi dim array it is changed to single dim array

Yeah, it seems dimensions are not written. You need to write them separately.
https://gambaswiki.org/wiki/lang/datarep?nh

Jussi

On Thu, Jul 4, 2024 at 3:21 AM Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> wrote:
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>