Solved

Event list in my component

Posted on 2002-06-17
2
137 Views
Last Modified: 2010-04-04
Hey there ,
I write a component that do couple animations .
What I need is to create a property alike Lines on Memo component where to store a commands list ( alike Goto,DoThis...). When I give run I wish that my component to read each line and execute it .

Any codes ?

For another 100 points ... how can I execute a string as code ?
Alike'Label1.Color:=clRed' to change the label color ?
This is just an example . I don't know what the user wish .
0
Comment
Question by:ginsonic
2 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 7085935
Hi,
Something like:
-----
uses Classes, Extctrls;

type
  TCodeImage = class(TImage)
  private
    FLines: TStrings;
  protected
    procedure SetLines(Value: TStrings);
    function ExecLine(Value: string): boolean;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Run;
  published
    property Lines: TStrings read FLines write SetLines;
  end;

implementation

constructor TCodeImage.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLines := TStringList.Create;
end;

destructor TCodeImage.Destroy;
begin
  FLines.Free;
  inherited Destroy;
end;

procedure TCodeImage.SetLines(Value: TStrings);
begin
  FLines.Assign(Value);
end;

function TCodeImage.ExecLine(Value: string): boolean;
begin
  result := true;
//  Do exec here
end;

procedure TCodeImage.Run;
var
  i: integer;
begin
  if FLines.Count > 0 then begin
     for i := 0 to FLines.Count - 1 do begin
       if not ExecLine(FLines[i]) then begin
//         Raise exception or ShowMessage
         break;
       end;
     end;
  end;
end;
-----
Regards, Geo
0
 
LVL 2

Expert Comment

by:333
ID: 7086081
about executing string as code:
http://www.torry.net/scripts.htm has some components that parse strings and execute them. some of them are freeware with source, so you can see how this can be done.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now