Solved

About FileRead()

Posted on 1998-04-15
2
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1361555
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
ID: 1361556
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

615 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