Re: How can I execute a line of code stored in a string?



"henryhamon" <henrygecko@xxxxxxxxx> schreef in bericht
news:1151514944.788601.291910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi everbody!

I need a Delphi function which I put a string and execute that...

exemple:

strCode := ' edit1.Text := strName ' + ';' ;

ExecuteString(strCodigo);

I don't know if is possible to do in Delphi...


I don't think you can do this in Delphi. But in typical cases the functions
you would like to call in this way are in one way or another similar. Like
"edit1.text:=someString", "edit2.text:=someOtherString", "edit3... etc.
Maybe a handful of different controls and some indexing. If that's the case,
put the indexed controls in a list and call elements in the list. Eg:
execList.add(edit1);
execList.add(edit2);

with execList[k] AS Tedit do text:=someString;
Tbutton(execList[i]).OnClick(NIL);

Tom



.


Quantcast