Author Topic: How i save quickly big array ?  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
How i save quickly big array ?
« on: May 30, 2020, 12:49:25 am »

Hi! How to quickly save disk to a large array in qb64?

for example
dim x (49000,59,59,59) as _bit _ unsigned

Printed sequentially with print # a lot of time.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How i save quickly big array ?
« Reply #1 on: May 30, 2020, 01:49:56 am »
dim x (49000,59,59,59) as _bit _ unsigned
DIM M AS _MEM
M =_MEM(x())
t$ = SPACE$(M.SIZE)
_MEMGET M, M.OFFSET, t$

OPEN "YOUR FILE.ext" FOR BINARY AS #1
PUT #1, 1, t$
CLOSE
_MEMFREE M
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: How i save quickly big array ?
« Reply #2 on: May 30, 2020, 05:39:17 am »
shows error

 [ You are not allowed to view this attachment ]  


if I write * some after _UNSIGNED, it will show an error on line 2
« Last Edit: May 30, 2020, 05:41:04 am by MasterGy »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How i save quickly big array ?
« Reply #3 on: May 30, 2020, 08:51:37 am »
Try _UNSIGNED _BIT.  If you look, you'll see I only copy/pasted the array as you'd defined it in your first post...

... Though, I can't help to think if you can't debug such an error on your own, you're probably not ready to try and write code which utilizes large multi-dimensional arrays.  You need to work on understanding the fundamentals a _BIT more, before doing whatever it is you're attempting to do, I think.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: How i save quickly big array ?
« Reply #4 on: May 30, 2020, 09:54:38 am »

thank you for trying to help me

i have already tried an old varing solution, it only works on a small scale. mem-es like because easily and quickly, multiple mbyte can be mobilized.

the reason I came here to ask, from there led to the failure of -bit mem. I have several alternative “make solutions” to it, but I wanted it to work like this, so I’m already over the debugger.

If anyone has a working code for this, thanks.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: How i save quickly big array ?
« Reply #5 on: May 30, 2020, 10:09:03 am »
Just so you know, _BIT is not recommended to be used. It is only partly implemented with in QB64. You would be better off using _BYTE or INTEGER.

as for quickly saving it:

Code: QB64: [Select]
  1. DIM X (49000,59,59,59) AS _UNSIGNED _BYTE  ' _bit _ unsigned 'use BYTE as BIT is not always good and UNSIGNED comes before
  2.  
  3. OPEN "YOUR FILE.dat" FOR BINARY AS #1
  4. PUT #1, , X
  5.  

Just note that as you are trying to save 10,063,571,000 bytes of data your hard drive may take a few moments to complete the action.

QB64 uses a _BYTE with _BIT anyway, so using _BIT * 1 simply uses 1 bit of a BYTE and wastes the other 7, and _BIT * 8 would use the whole byte so using _BYTE is recommend over using _BIT.
« Last Edit: May 30, 2020, 10:13:39 am by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: How i save quickly big array ?
« Reply #6 on: May 30, 2020, 10:28:48 am »
"A QB64 egyébként _BYTE-t használ a _BIT-rel, tehát a _BIT * 1 használata egyszerűen 1 bit BYTE-t használ, és a másik 7-et pazarolja, és a _BIT * 8 az egész bájtot használja, tehát a _BYTE használata ajánlott, mint a _BIT használata."



it helped me understand! !! thank you for your  reply!
« Last Edit: May 30, 2020, 10:30:21 am by MasterGy »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: How i save quickly big array ?
« Reply #7 on: May 30, 2020, 10:57:19 am »
Glad it translated well enough to be understood! 
Your welcome.
Makes me feel useful the few times my knowledge helps.
Granted after becoming radioactive I only have a half-life!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: How i save quickly big array ?
« Reply #8 on: May 30, 2020, 01:35:13 pm »
after I solved it so I couldn’t redeem it, once in a while, I solved it in an array handling so you can get everyone 8 bits. works and saves.

The other half of the day was spent on how I could reload the file into the array. I can't figure it out.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: How i save quickly big array ?
« Reply #9 on: May 30, 2020, 02:02:31 pm »

I'm sorry, I solved it.
I thought of all sorts of complicated things, no, like that, while:

OPEN filename $ FOR BINARY AS # 1
GET # 1, 1, array ()
CLOSE 1

:)