?
Solved

Read Text File Lines in Seperate Variables

Posted on 2002-06-16
7
Medium Priority
?
151 Views
Last Modified: 2010-04-04
Hello its me again dinkleburger
I have a text file
in C:\windows\FILENAME.txt

the file looks like this

Line1 WHO
Line2 WHAT
Line3 WHY
Line4 WHERE
Line5 WHEN
Line6 HOW

QUESTION TIME     i want a procedure to read this File and Put WHO in Variable1

WHAT in Variable2
WHY in Variable3 etc etc

Thanks in advance again...
0
Comment
Question by:Dinkleburger
[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
  • 4
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 7082127
hmm, what about

var
  sl : tstringlist;
begin
  sl := tstringlist.create;
  try
    sl.loadfronfile('C:\windows\FILENAME.txt');
    variable1 := sl[0];
    variable2 := sl[1];
    ...
  finally
    sl.free;
  end;
end;

meikl ;-)

0
 

Author Comment

by:Dinkleburger
ID: 7082373
Hello Kretzschmar
i am getting undeclared identifier  loadfronfile ??
thanks
0
 

Author Comment

by:Dinkleburger
ID: 7082413
Hello Kretzschmar
i am getting undeclared identifier  loadfronfile ??
thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Dinkleburger
ID: 7082438
I found the problem with the undeclred identifier
fronfile was fromfile lol typo (smiles)

i guess its nearly there

with   variable1 := sl[0];
       variable2 := sl[1];
   i get incompatible types String and Pchar
how do i fix this
thanks Kretzschmar





0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 7082812
What type is Variable1, Variable, etc declared as.

If they are declared as PChar then either change them to a string or

variable1 := PChar(sl[0]);


The Crazy One
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7083132
yep, was a typo,
for conversion see crazyone's comment
(didn't know that your variableX are PChars)

meikl ;-)

0
 

Author Comment

by:Dinkleburger
ID: 7084121
Thanks people
that works fine
Regards Dinkleburger
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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