PDA

Click to See Complete Forum and Search --> : How do you use Binary to make files?


Iceman
Jan 19th, 2000, 06:36 AM
could u give an example of how to import/export binary into files? and search etc or give an example?

later,
Iceman

HarryW
Jan 19th, 2000, 06:41 AM
Sorry, maybe I'm being dumb, but which bit of exporting binary into files is the problem? I thought you could just put it there without too much fuss. I'm wrong, obviously, so enlighten me please :)

Iceman
Jan 19th, 2000, 07:00 AM
Could you just say how you put data in a blank file or edit data in a current one after searching for it? (by blank i mean when you use the "Open file for whatever as #x")

Is that a bit clearer?

later,
Iceman

I almost forgot of course i want to do this in binary not any other way i want to input the flat 1's and 0's nothing else really

[This message has been edited by Iceman (edited 01-19-2000).]

HarryW
Jan 19th, 2000, 07:05 AM
Generally, when I'm putting things in files I'll use fixed length strings or user-defined types, again any strings are of fixed length. That way you can easily work out the position of each record, as the position is

LOF\Len(one record)

You just use GET or PUT statements to retrieve or place data respectively. These functions are well documented in the help files.

Al Smith
Jan 19th, 2000, 08:22 AM
Hi,
Giving an example of waht you're trying to do will take more time than I have right now but the following might give you some ideas.
The 0's and 1's of a binary number are called bits.
8 of these bits are called a byte.
You can't put anything less than a byte into a file.
If you create a file with 0's and 1's each 0 or 1 will take up 8 bits or 1 byte. The binary loaded in the file will be 00110000 for a 0 and 00110001 for a 1. Each 0 of the binary means there is no "Magnetic dot" on the (sic) surface of the harddrive and a 1 means there is. The harddrive reads these magnetic dots, 8 at a time, and tells the CPU what number they represent.
Hex numbers are an easier way to represent binary numbers which is why Hex editors are used for "bit twiddling", but you are still twiddling the bits in groups of 8.
To do what you're trying you'll have to change the bits in groups of 8.

You could input the file one byte (character) at a time and change the ascii# to a hex, which is actually a string, e.g. alpha. If the hex$ from the input file <> the the hex$ you want to change write the chr$ of the ascii# to a new file as is. The chr$ will let you change the bits of a byte that is below ascii 32 or above ascii 127, the range of a keyboard.
If the hex$ from the input file = the hex$ you want to change write the new chr$ of the new ascii# to the file.
Al.




------------------
A computer is a tool, not a toy.
<A HREF="mailto:asmith3914@aol.com
asmith@spxateg.com">asmith3914@aol.com
asmith@spxateg.com</A>

Iceman
Jan 19th, 2000, 09:20 AM
I still don't get how i can write bytes/bits etc. to a file

Ill hope you will put an example up

later,
Iceman

P.S. You can mail me at
Iancallanan@hotmail.com
if you prefer

[This message has been edited by Iceman (edited 01-19-2000).]

ivyl
Jan 19th, 2000, 07:47 PM
Mayby this code can be of help to you:

Dim x As String * 1
Open FileName1$ For Binary As #1
Open FileName2$ For Binary As #2
While Not EOF(1)
Get #1, , x$
Put #2, , x$
Wend
Close

It copies each byte from FileName1$ to FileName2$

Iceman
Jan 20th, 2000, 04:34 AM
ok ill try that but one more thing...

How can i import what you see in a hex editor( or just binary numbers) into a file?

I tried
dim x as string * 1
x = 119 (the first number in a file i wanted to edit)
open filename(user chose it) for binary as #1
put #1 , , x
close
and the first hex number (in a hex editor) followed its code then checked it it put the asci char 1 in

also note that this came out the same way when i did x = 1
any help?

this is another change

i tried dim as byte and it worked fine thanks to everyone who has helped me so far...

but can you search for a number in the file?
later,
Iceman

[This message has been edited by Iceman (edited 01-20-2000).]

[This message has been edited by Iceman (edited 01-20-2000).]