Solved

About FileRead()

Posted on 1998-04-15
2
229 Views
Last Modified: 2010-04-06
Can I, using FileRead(), read integers from a file and not bytes?
For example if my file is like this:

12 32

How can I read only the two numbers and not the space between them?

Thanks for your help
0
Comment
Question by:kkarnez
2 Comments
 
LVL 5

Expert Comment

by:inter
Comment Utility
Sorry, NO(with fileread)
The easiest way is to open file and read it as a traditional pascal as  
  ReadLn(f,integer1,integer2) which reads the above line.
Of course you can do it with FileRead but not automatically, you should parse the line by yourself.
Regards, Igor

0
 
LVL 3

Accepted Solution

by:
williams2 earned 10 total points
Comment Utility
As mentioned above, it's not possible to access data as integers directly. But you could read data like

FileRead(Handler,Byte0,1);
FileRead(Handler,Byte1,1);
FileRead(Handler,Byte2,1);
FileRead(Handler,Byte3,1);

If (Byte3 AND 127)>0 then
begin
  Dec(Byte3,127);
  i:= -(Byte3*$1000000+Byte2*$10000+byte1*$100+Byte0);
End else
  i:= Byte3*$1000000+Byte2*$10000+byte1*$100+Byte0;

But this is not a rather cool way to solve it. The FileRead operation is a lowlevel routine. Avoid using it if possible.

Regards
Williams
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now