2

i made button component in runtime and i want every button clicked there executing unique procedure.

for example

exec('showmessage('+quotedstr('hello word')+');');

How to executing string as procedure in delphi 7 like eval in php or livebinding in delphi xe3?

7
  • Delphi is compiled, so there's no such thing like eval in php, and you're maybe missunderstanding what LiveBinding is Commented Mar 5, 2013 at 17:05
  • Eh. Delphi is not PHP...and even in PHP, eval is almost always the wrong way to go about things. :P Does Delphi have any equivalent to lambdas, anonymous functions, or whatever? Commented Mar 5, 2013 at 17:06
  • 5
    you can use a scripting engine like remobjects.com/ps.aspx Commented Mar 5, 2013 at 17:07
  • 8
    Step away from the keyboard for a second. You're doing so many wrong things at once, it's scary. :P Delphi doesn't eval. Even if it did, eval'ing code out of a database is all kinds of brokenness waiting to happen. Step back and think about what you really want to do...and how that's likely to be feasible in a language that can't interpret itself on the fly. Commented Mar 5, 2013 at 17:07
  • 2
    If you stopped trying to store code in a database, then the whole problem of how to execute it would go away. Consider that. Why are you storing textual code in a database (or anywhere, for that matter)? Consider a template system instead; the database stores various values that you plug in to your already-written functions, so you just have to pass a limited number of values to those functions as parameters. Commented Mar 5, 2013 at 17:11

3 Answers 3

7

Delphi has no such facility. It's a compiled language, and the compiler only runs on the developer's system; you're not allowed to distribute the compiler with your program.

Instead, you can use any of a number of scripting tools, such as DWScript. It supports a language syntax similar to that of Delphi. It has some built-in functions, and you can define others from the host program to expose in the script environment.

Sign up to request clarification or add additional context in comments.

2 Comments

For scripting libraries, see this question...
Finally I found Tfsscript component of FastReport. there is a Evaluate function that I can use. thanks the suggestions.
4

What you are trying to do is not possible in Delphi. It does not have an interpreter. What you need is to embed a scripting language.

Comments

0

have a look at this while looking for an answer

http://blog.angress.de/cracking/dynamicprocexecution_delphi/

1 Comment

Link only answers are discouraged, and the link provided is not pertinent to this question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.