Solved

STRING CODE EXECUTE

Posted on 2002-04-19
5
215 Views
Last Modified: 2010-04-04
STRING CODE EXECUTE

I want to execute string code at runtime.
For example :
-----
Form2.Panel2.Color:=clRed;
-----

Thanks.
0
Comment
Question by:ghjlk
[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
5 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 300 total points
ID: 6955276
You have to use an interpreter for it... check out

http://www.carlo-kok.com/ifps3.php
0
 
LVL 17

Expert Comment

by:inthe
ID: 6955306
dwscript v2 is also quite popular and can do this:
http://www.dwscript.com/
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6955585
listening
0
 

Author Comment

by:ghjlk
ID: 6955592
// I want to execute code in richedit1.
// Could You give me an example with Your solutions.
// Thanks.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
RichEdit1.Clear;
RichEdit1.Lines.Add('Form2.Panel1.Color:=clRed;');
Form2.Show;
end;

end.




unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm2 = class(TForm)
    Panel1: TPanel;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6955805
Hi ghjlk,

something like this?

uses
   ..., TypInfo,.....

function SetPropertyValue(const FormName, ComponentName, PropName, Value: String): Boolean;
var
  I: Integer;
  C: TComponent;
begin
  Result := False;
  for I := 0 to Screen.FormCount - 1 do
    if CompareText(Screen.Forms[I].Name, FormName) = 0 then
    begin
      C := Screen.Forms[I].FindComponent(ComponentName);
      if C <> nil then
      begin
        if CompareText(PropName, 'COLOR') = 0 then
          SetPropValue(C, PropName, StringToColor(Value))
        else
          SetPropValue(C, PropName, Value);
        Result := True;
      end;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetPropertyValue('Form1', 'Label1', 'Color', 'clRed');
  SetPropertyValue('Form1', 'Label1', 'Left', '10');
  SetPropertyValue('Form1', 'Label1', 'Alignment', 'taRightJustify');
end;

-----
Igor.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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