Solved

Event list in my component

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
When i run adoquery my application freezes 26 180
Base1 Encode/Decode 3 82
Sending files from  idTcpServer Socket to idTcpClient 2 44
Delphi: making a BW image transparent 10 62
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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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