Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

STRING CODE EXECUTE

Posted on 2002-04-19
5
Medium Priority
?
231 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 1200 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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