?
Solved

Read Text File Lines in Seperate Variables

Posted on 2002-06-16
7
Medium Priority
?
154 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

864 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