Re: Convert a binary file to letters.
Posted: Mon Jun 13, 2011 2:30 pm
So my code above should work fine using the ReadByte() function - vinostien seems to have mixed-up the names for 'bits' and 'bytes' at one of his first posts
http://www.purebasic.com
https://www.purebasic.fr/english/
I will try to explain why I need to try this/or read this file, I work as a thieft provenction officer for 12 buildings with (for youe eyes only) info in them, this file is one day tracking of badge numbers access panels, key pads and prox sencers, this file in question is about 3meg in size, the sample was a cut copy and paste of some random lines, what I am tring to do is convert and sort out one single badge number, keys pressed and location at all time of the day in question of this single badge number.Why? What do you hope to accomplish by viewing the file as letters?
Sounds like you're going for a sort of manual approach where you scan the file with your eyes looking for every instance of the badge number. Far better would be to write a simple program that reads the file, picks out each instance of the badge number and displays the location and time. An option to print it out would be useful as well. Such a program would be no more difficult to write than what you're trying to accomplish here.what I am tring to do is convert and sort out one single badge number, keys pressed and location at all time of the day in question of this single badge number.
Code: Select all
; _ _ __ _ _ __ ___ ____ __ ___ _ _
; ( )( )( )( \( )/ \ / __)(_ _)( )( _)( \( )
; \\// )( ) (( () )\__ \ )( )( ) _) ) (
; (__) (__)(_)\_)\__/ (___/ (__) (__)(___)(_)\_)
;
; 19jun011 file test 1.2.1
File.s = OpenFileRequester("Data File", "", "Any File|*.*", 0)
If (File)
If (ReadFile(0, File))
NewFile.s = File + ".txt"
If (CreateFile(1, NewFile))
While (Not Eof(0))
number.w =ReadWord(0)
OpenConsole()
PrintN(""+Str(number))
PrintN(""+Chr(number))
Debug(numbers)
Wend
EndIf
EndIf
EndIf
this part is confusing to me, I don't know how to change the coding to let me put what is in the file in to this datasection?DataSection
Data.b 0,1,0,0,1,0,0,0; Bits 0 and 1
Data.b '0','1','0','0','1','0','0','1'; Characters '0' and '1'
EndDataSection
Thought, you wanted to take the 8 bits (%01010101) of a character and write is as 8 bytes ("01010101") to a text file...vinostien wrote:?
Code: Select all
File.s = OpenFileRequester("Data File", "", "Any File|*.*", 0)
If (File)
If (ReadFile(0, File))
NewFile.s = File + ".txt"
If (CreateFile(1, NewFile))
While (Not Eof(0))
number.b =ReadByte(0)
Write(1,RSet(Bin(number),8,"0")
Debug str(number) + " = "+RSet(Bin(number),8,"0")
Wend
Close(1)
EndIf
EndIf
EndIf
You don't have to do that -- just open the file with the "binary" data and change the read command to the file number (so these code lines will look similar to the ReadFile(...) and ReadByte(...) statements in the code snippets abovevinostien wrote:this part is confusing to me, I don't know how to change the coding to let me put what is in the file in to this datasection?DataSection
Data.b 0,1,0,0,1,0,0,0; Bits 0 and 1
Data.b '0','1','0','0','1','0','0','1'; Characters '0' and '1'
EndDataSection
thanks vinostien
thank you very much again, I am sorry for the unknow terms in the computer language, Like I said I am very new to computers, and don't know much about them.now it is clear. You want something like this: