Solved

Loading and executing a custom script

Posted on 2004-04-25
6
147 Views
Last Modified: 2010-04-05
Hey guys/gals.
I have a question.. and i've broken ma head over this.  
Its sorta like Scripting
now i open a txt file and enter the following.

------------------
!StartHome*1*Procedure1
OpenFile c:\startup.exe
MoveFile c:\opener.exe c:\winxp\yah.exe
!endHome*1

!StartHome*2*Procedure2
OpenFile c:\somefile.exe
MoveFile c:\gaim.exe c:\games\gaim.exe
!endHome*2
---------------------------- now i save this txt file.
Now in my delphi app. i load this file to a memo or richedit. and i wana read it in this way.
i wana search for "!StartHome" First and then see wat item number it is. - item "1" then i wana look for "!endHome*<itemnumber>" like "!endHome*1"

now i wana be able to get the lines between ItemProcedures. like in Proc1. i should get the lines between starthome and endhome. and i wana read each and everyline after starthome*1 to endhome*1. the number of lines between them can be random. In such a scenario.
how am i able to start coding? just to read the lines.

thx
celina
0
Comment
Question by:sesycelina
[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
6 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10911254
Hi

//To read text file into memo
Memo1.Lines.LoadFromFile('YourFileNmae');

//to search first line with !StartHome
for i := 0 to Memo1.Lines.Count-1 do
  begin
  if Pos('!StartHome',Memo1.Lines[i]) > 0 then
    begin
// in line i there is text '!StartHome'
    end;
  end;

to search subsequent line start searching not from i := 0;

Hope this help for the beggining.
0
 

Author Comment

by:sesycelina
ID: 10911290
Yea, i kno this, but how do i read the lines between procedures.

like in delphi
begin
//code//
end
i wana read the lines between them.
0
 
LVL 17

Accepted Solution

by:
mokule earned 20 total points
ID: 10911348
So maybe this will help

var
  str: string;
  bRead: boolean;
begin
bRead := False;  // flag for reading
AssignFile(F,'YourFileNmae');
Reset(F);
while not Eof(F) do
  begin
  Readln(F,str)
  if bRead then
    begin
    if Pos('!endHome',str) > 0 then // end of block found
      begin
      break;
      end
    else
      Memo1.Lines.Add(str);
    end
  else if Pos('!StartHome',str) > 0 then // start of block found
    begin
// add counter here for not reading the first block but any other
    bRead := True;
    end;
  end;
CloseFile(F);
end;
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

631 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