QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: MasterGy on May 30, 2020, 12:49:25 am

Title: How i save quickly big array ?
Post by: MasterGy 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.
Title: Re: How i save quickly big array ?
Post by: SMcNeill 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
Title: Re: How i save quickly big array ?
Post by: MasterGy on May 30, 2020, 05:39:17 am
shows error

 [ This attachment cannot be displayed inline in 'Print Page' view ]  


if I write * some after _UNSIGNED, it will show an error on line 2
Title: Re: How i save quickly big array ?
Post by: SMcNeill 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.
Title: Re: How i save quickly big array ?
Post by: MasterGy 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.
Title: Re: How i save quickly big array ?
Post by: Cobalt 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.
Title: Re: How i save quickly big array ?
Post by: MasterGy 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!
Title: Re: How i save quickly big array ?
Post by: Cobalt 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.
Title: Re: How i save quickly big array ?
Post by: MasterGy 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.
Title: Re: How i save quickly big array ?
Post by: MasterGy 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

:)