yo, i need to access binary files - read and write to them and i use 'open "file.bin" for binary as #1' and then try using 'get #1,1,n' and all i get is zeros and when i use a string as n i just get nulls - i dont know what im doing wrong. please help! i need a tutorial on read/write with binary files or something - thanks all who read this and big thanks to all who help

-The Black Frog

• I'm not sure why this works and nothing else, but it does:
Get #1,1,n\$

And somewhere in your program before that put
n\$ = space\$(x)

where x is however many bytes you want to read at once. Basically, it will fill up the whole string with the proper records from file. You can use this to your advantage actually. I use this to make fast file access routines, since a string can be 65536 characters, you can read and write in 64KB chunks!

Use the same method to write binary files. For example, if you wanted to put "SomeMessage" 20 times into a new file, do like so:

[code]
n\$ = "SomeMessage"
open "file.bin" for binary as #1
For a = 1 to 20*len(n\$) step len(n\$)
put #1, a, n\$
next a
[/code]

Well, I hope that answers it.

: yo, i need to access binary files - read and write to them and i use 'open "file.bin" for binary as #1' and then try using 'get #1,1,n' and all i get is zeros and when i use a string as n i just get nulls - i dont know what im doing wrong. please help! i need a tutorial on read/write with binary files or something - thanks all who read this and big thanks to all who help
:
: -The Black Frog
:

• Hi,
This worked for me.

REM ** START CODE

OPEN "B", 1, "c:qb45stmove.exe"

k = 0
WHILE NOT EOF(1)
a\$ = INPUT\$(1, 1)
k = k + 1
WEND
REM k = the number of bytes read
PRINT k
CLOSE 1

REM ** END CODE

Hope this helps.

Pappy
You learn something everyday.