*SAVE

Discussions related to database technologies, file handling, directories and storage
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

*SAVE

Post by Ric »

iI am trying to save the contents of an array to disc and then recover them

Code: Select all

   
      *FLOAT64
      DIM landscape%(31,255,31,1)
      *HEX64
      start%% = ^landscape%(0,0,0,0)
      file$ = "testLandscape"
      length% = 16777216

      OSCLI "SAVE """+file$+""" "+STR$~start%%+" +"+STR$~length%

Code: Select all

      file$ = "testLandscape"
      start%% = ^landscape%(0,0,0,0)
      max% = 16777216

      OSCLI "LOAD """+file$+""" "+STR$~start%%+" +"+STR$~max%
This is the code i have tried, but does not work, could some one please help and point out the error

Kind regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Hated Moron

Re: *SAVE

Post by Hated Moron »

Ric wrote: Thu 15 Dec 2022, 22:04 This is the code i have tried, but does not work, could some one please help and point out the error
In what way does it "not work"? I added some test code, to load the array with random values and then check it after reading back from the file, and it worked correctly here (in BBCSDL, but it should be compatible with BB4W):

Code: Select all

      HIMEM = PAGE + 5000000

      DIM landscape%(31,255,31,1)
      *HEX64
      start%% = ^landscape%(0,0,0,0)
      length% = ^landscape%(31,255,31,1) - start%% + 4
      file$ = @tmp$ + "testLandscape"

      seed% = RND(-12345)
      FOR I% = 0 TO 31
        FOR J% = 0 TO 255
          FOR K% = 0 TO 31
            FOR L% = 0 TO 1
              landscape%(I%,J%,K%,L%) = RND
            NEXT
          NEXT
        NEXT
      NEXT I%

      OSCLI "SAVE """+file$+""" "+STR$~start%%+" +"+STR$~length%

      landscape%() = 0

      OSCLI "LOAD """+file$+""" "+STR$~start%%+" +"+STR$~length%

      seed% = RND(-12345)
      FOR I% = 0 TO 31
        FOR J% = 0 TO 255
          FOR K% = 0 TO 31
            FOR L% = 0 TO 1
              IF landscape%(I%,J%,K%,L%) <> RND PRINT "Failed" : STOP
            NEXT
          NEXT
        NEXT
      NEXT I%

      PRINT "Test completed successfully"
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: *SAVE

Post by Ric »

Sorry Richard,

I had used an ENDPROC instead of a ENDIF and thus the array was not being populated!
However, when i change the size to 256*256*256*2*32 which is the size of the array i would like to deal with i get an unknown error in the *SAVE line, is there a maximum size that can be copied this way?

Kind regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Hated Moron

Re: *SAVE

Post by Hated Moron »

Ric wrote: Fri 16 Dec 2022, 17:38 I had used an ENDPROC instead of a ENDIF
I'm pretty sure that the Cross Reference Utility warns about that mistake, so if you didn't run it my sympathy is limited! I always use it because it's quite good at finding 'silly' mistakes, like typos, which can take a disproportionate amount of time to debug.

In fact I could have guessed you didn't run CrossRef, because it warns that your variable length% is incompatible with lowercase keywords (not that I would necessarily expect you to do anything about that, but I prefer to in order to keep the warnings to a minimum).
However, when i change the size to 256*256*256*2*32 which is the size of the array i would like to deal with...
Is that the number of bytes or the number of array elements? Either way it's larger than the amount of memory that can ordinarily be allocated to BBC BASIC (512 Mbytes for BB4W, 256 Mbytes for BBCSDL) so the issue is not so much that you cannot save an array that big but that you cannot even store it!
Ric
Posts: 208
Joined: Tue 17 Apr 2018, 21:03

Re: *SAVE

Post by Ric »

It is the size in bits
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023