Solved

STRING CODE EXECUTE

Posted on 2002-04-19
5
209 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

820 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