Solved

Event list in my component

Posted on 2002-06-17
2
136 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

12 Experts available now in Live!

Get 1:1 Help Now