473,799 Members | 3,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read "binary" file sequentially?

1 New Member
Hi!! I have a question here where I used :
Expand|Select|Wrap|Line Numbers
  1. Open sourceDir & sourceFile For Input As af
  2. Do While Not EOF(af)
  3.  
  4.     Line Input #af, textline
  5.  
  6.     If Trim(textline) Like "fruits" Then
  7.         list_start = True
  8.     End If
  9.  
  10. Loop      'loop while not end of file
  11. Close #af 'close file
but the problem is that the whole file is read into textline instead of line by line, how can i change the file so that I'll be able to capture line by line?
(Opening the file using textpad and notepad produces different format, textpad will open it with line by line while notepad shows the whole file in a string) Thx a lot!!!!
Mar 28 '07 #1
2 1742
Dököll
2,364 Recognized Expert Top Contributor
Hey there buzzy!

There are a number of posts here on this very subject, some posted by me. Please search a little deeper, see what pops up. Try adding strGetWords to your search if you need to see something I have posted. I must caution, and this something I became aware of through hours of research, when you are reading from a text file, you will likely be reading a word within a word, whereby rain is found in train:-) Of course, if you are after a different medium, you should be ok with the code as is...

Good luck!

Dököll
Mar 28 '07 #2
Killer42
8,435 Recognized Expert Expert
Your file has the wrong delimiter characters at the end of each line. In the DOS/Windows world, it should have two characters - CR (Carriage Return, ASCII code 13) and LF (Line Feed, ASCII code 10). Generally just referred to as CRLF. It probably has just one or the other (CR or LF). This is common with files coming from other operating systems, such as Unix.

One quick and relatively simple way to correct the file is to open it in MS Word and save it again as plain text. Word will (probably) put in the proper delimiters.
Mar 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
35622
by: Phil Powell | last post by:
I have a PHP script that would read in a binary file and display it as if it were <img src>, how would you do that w/o changing the header's MIME type? The entire file does not need to be changed. Thanks Phil
3
2976
by: DrewM | last post by:
I'm using ASP to generate an RTF (rich text) file, via the FSO. No problems with text, but when it comes to inserting images, the files have to be embedded as either binary or hex. Try as I might, I can't get binary to work (Word b0rks trying to open the resulting file). When I create a simple RTF in Wordpad and then view its source, Wordpad seems to be embedding the image as hex. Does anyone have a suggestion as to how I could read an...
2
268
by: Pete | last post by:
Hi Could someone kindly help with the C# equivilent of the following 4 lines of C code. I'm *really* struggling with this. ( Colours.dat contains 300 RGB values ) COLORREF Colours;
8
37121
by: S Shulman | last post by:
Hi All I need to read a file to an array of bytes (any type of file) I tried using FileStream and BinaryReader but it doesn't seem to work Thank you, Shmuel
1
2276
by: Quinn | last post by:
Hi all, I have some binary files in the following format: text line 1 text line 2 .... text line N end of text single in binary 1 single in binary 2 single N EOF
4
3497
by: Matrixinline | last post by:
Hi All Here is my problem I am using a Unicode project and I tried to read the File like sPath = LPCTSTR; FILE* oFp = _tfopen(sPath,L"r"); while(!feof(oFp))
2
1898
by: kowndinya | last post by:
Hello, i want to read values from a binary file in VisualBasic 6.0 Initially i want to read only header of this binary file. I know this structure for this header. It is 100 bytes long and consists of 9 variables of Integer: Signed 32-bit integer (4 bytes) and 8 variables of Double: Signed 64-bit IEEE double-precision floating point number (8 bytes). when i tried to assign integer and double data type for these variables i am...
2
2079
by: tulasisridhar | last post by:
Hi All, I have binary file created in Unix I now need to read it using VB.net and doo some procesing. There is some conversion between bigendian and little endians. I know the structure of the file of the binary file..... Any suggestions
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.