[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Read Text File Lines in Seperate Variables

Posted on 2002-06-16
7
Medium Priority
?
153 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Industry Leaders: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 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