Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:55:49+00:00 2026-06-14T05:55:49+00:00

I want to make a new .txt file which parameters i load from a

  • 0

I want to make a new .txt file which parameters i load from a .script file. It works fine in the root. .script file is in the root directry.The result is:

  1. 192.121.2.2 login Lucey password red
  2. 192.321.2.1 login Steve password apple

.

  if FindFirst('*.*', faAnyFile, Search) = 0 then
  begin
    while FindNext(Search) = 0 do
    begin
      if FileExists(Search.Name) then
      begin
        if pos('.txt', Search.Name) <> 0 then
        begin
          Assignfile(txtfile, Search.Name);
          Erase(txtfile);
        end;
      end;
    end;
  end;
  findclose(Search);

  if FindFirst('*.*', faAnyFile, Search) = 0 then
  begin
    while FindNext(Search) = 0 do
    begin
      if FileExists(Search) then
      begin
        if pos('.script', Search.Name) <> 0 then
        begin
          data_file := TStringList.Create;
          data_file.LoadFromFile(Search.Name);
          txtdata := data_file.Strings[1].+ 'login' + data_file.Strings[2] +
            'password' + data_file.Strings[3];
          txtfile := TStringList.Create;
          if FileExists('.txt') then
          begin
            txtfile.LoadFromFile('.txt');
          end;
          txtfile.Add(txtdata);
          txtfile.SaveToFile('.txt');
        end;
      end;
    end;
  end;

  findclose(Search);

But if i want to add C:\Script\Files the code i use is wrong, what is the problem? Pls help!

  if FindFirst('c:\Script\Files\*.*', faAnyFile, Search) = 0 then
  begin
    while FindNext(Search) = 0 do
    begin
      if FileExists(Search.Name) then
      begin
        if pos('c:\Script\Files\.txt', Search.Name) <> 0 then
        begin
          Assignfile(txtfile, Search.Name);
          Erase(txtfile);
        end;
      end;
    end;
  end;
  findclose(Search);

  if FindFirst('*.*', faAnyFile, Search) = 0 then
  begin
    while FindNext(Search) = 0 do
    begin
      if FileExists(Search) then
      begin
        if pos('.script', Search.Name) <> 0 then
        begin
          data_file := TStringList.Create;
          data_file.LoadFromFile(Search.Name);
          txtdata := data_file.Strings[1] + 'login' + data_file.Strings[2] +
            'password' + data_file.Strings[3];
          txtfile := TStringList.Create;
          if FileExists('c:\Script\Files\.txt') then
          begin
            txtfile.LoadFromFile('c:\Script\Files\.txt');
          end;
          txtfile.Add(txtdata);
          txtfile.SaveToFile('c:\Script\Files\.txt');
        end;
      end;
    end;
  end;

  findclose(Search);

The result is:

  1. 192.121.2.2 login Lucey password red
  2. 192.121.2.2 login Lucey password red
  3. 192.321.2.1 login Steve password apple

The 1st item shows twice etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:55:50+00:00Added an answer on June 14, 2026 at 5:55 am

    You have quite a lot of logic bugs in your code. Try this instead:

    if FindFirst('c:\Script\Files\*.txt',faAnyFile,Search) = 0 then
    begin
      repeat
        DeleteFile('c:\Script\Files\' + Search.Name);
      until FindNext(Search) <> 0;
      FindClose(Search);
    end;
    
    txtfile := TStringList.Create;
    try
      if FindFirst(PathToScriptFiles + '*.script',faAnyFile,Search) = 0 then
      begin
        repeat
          data_file := TStringList.Create;
          try
            data_file.LoadFromFile(PathToScriptFiles + Search.Name);
            txtdata := data_file.Strings[1] + ' login ' + data_file.Strings[2] + ' password ' + data_file.Strings[3];
            txtfile.Add(txtdata);
          finally
            data_file.Free;
          end;
        until FindNext(Search) <> 0;
        FindClose(Search);
      end;
      txtfile.SaveToFile('c:\Script\Files\.txt');
    finally
      txtfile.Free;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to take a character from a file.txt which has only one character
I want to make new stackpanal from another stackpanal already made before but if
I don't want to make a new instance of Form1 in the class, and
I am new android app developer i want make app for tablets and phone
I want to make a function for a new datatype in Standard ML, the
I am new to .NET and ideally want to make several layers of abstraction
I want to make a smart keyboard that can learn and save new words
i'm new to gooogle map developing.i want to make a map as follows. http://edition.cnn.com/SPECIALS/world/arab-unrest/index.html
I want to make routing for form when submitting the form, $reportRoute = new
We are designing a new application for Android and we want to make it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.