LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

What exactly is a DAT file?

Root / Programming Questions / [.]

MZ952Created:
I attempted to use a dat file in one of my programs and the information i stored in one of my arrays that i saved in the dat file was distorted. What are they and how o you use them correctly?

They're essentially files which you can store an array of integers inside of.
SAVE "DAT:MYFILE", MYARRAY
This will save your array to a DAT file.
LOAD "DAT:MYFILE", MYARRAY
This will load a DAT file into an array.

Yes, i've got that much. The problem i was having was the number i stored did not come back the same after loading. It came back filled with 0's, 9's and 2's i believe. I am starting to think that it has to do with the way SB stores numbers: binary. My number must be too large to store in a single element.

They're essentially files which you can store an array of integers inside of.
They can be reals too; it's implicit depending on the type of the array you're saving (real-type arrays save real-type DATs.) This may be the issue he's encountering.
Yes, i've got that much. The problem i was having was the number i stored did not come back the same after loading. It came back filled with 0's, 9's and 2's i believe. I am starting to think that it has to do with the way SB stores numbers: binary. My number must be too large to store in a single element.
Did you try to put reals in and got integers back, or vice-versa? Is the array you saved the same dimension and size of the array it's being loaded into? DATs are very picky, so could you try to describe your process? This may be user error or perhaps a bug; it shouldn't be changing your values on purpose. For reference: reals are doubles and ints are signed two's-complement 32-bit.

I had an issue like this when saving and retrieving arrays. I believe it was swapping INT to REAL because of the operations in between saving and loading. SB didn't know which I preferred because my array wasn't typed. To be safe, I made sure to declare my array as integer explicity with % and the issue went away. You might give that a try if you aren't already.