Solved

Event list in my component

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 231
creating threads in delphi 1 203
Tvertscrollbox like a whatsapp layout 5 69
Delphi problems to abort a printjob 9 51
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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