Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2008, 06:50 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default A complex file parser

I need help building a program in VB 2008. Basically, I want to point it at a Binary file, and then have it take the binary, and do the following with it:

1. Take a pair of bits from the beginning of the file
2. Consider the bits, and do the following:
--If they are 00 or 11, toss both of them from the file.
--If the are 01 or 10, keep the first bit, and toss the second one from the file.
3. Move on to the next 2 bits. Repeat.

It needs to do this to the entire file. I plan to simply type in the file location (Like c:\documents and settings\my user name\my documents\randump\dump1.bin) into a text box. It is named "find". The parse will be started by a button named "parse".

There are just possible problems:
1. There is a big chance that the amount of bits removed won't be divisible by 8. This will create an uneven byte at the end. Does the computer care, or should I be worried?
2. When the binary files are opened in notepad, they look like characters. The program needs to see the bits, not characters.

I'm a VB noob, so can somebody show me how one is to do this?

And if you need any more information about the form setup, please ask.

Thanks in advance,

Vistro

 
Old February 17th, 2008, 06:54 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BTW, I am not in any classes. This is, therefor, not homework. Everything I know about VB I learned from trial and error... and a book that came with the software.

 
Old February 19th, 2008, 02:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Files are not organized in bits, but in bytes. The smallest unit you can retrieve from a file, or put into a file, is a byte.

With that said, prehaps the thing to do—if you are absolutely wedded to this bit-centric approach—is to open an input file and a separate output file. Get a byte from the input file, start parsing til you reach the end of the byte. While parsing, concatenate, or build, your results using a variable. When you have a full 8 bits in your variable, write the byte to your output file. If your tallying takes you across a byte boundary, fill in the last bit of the byte, write it, and continue with this tally event by filling in the 1st bit of the next byte.

Odd task; why do you want to do this, out of curiosity.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to deal with complex conditions in XSL file? Mateo1041 XSLT 10 October 9th, 2008 11:34 AM
How to upload complex xml file to 1 db table vangogh XML 3 October 8th, 2007 04:43 AM
Importing a Complex Excel file paige BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 February 7th, 2007 03:22 PM
Parser Error ashokparchuri General .NET 0 June 3rd, 2005 03:14 AM
XML File not found error from xerces parser P.J.Kim XML 0 October 19th, 2004 05:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.