Solved

Execute code at runtime in delphi7

Posted on 2012-04-06
8
594 Views
Last Modified: 2012-06-21
Hello,

I am searching for a solution or a component which allows me to execute code at runtime.
for example..
i have a delphi form with a memo on it. i have a string built at runtime from values in a database like
if ('copy(memo1.lines[0],1,3)' = 'XYZ' ) then
showmessage(string from database)

can someone help me to get through this?

regards
prampatel
0
Comment
Question by:prampatel
8 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 37816432
The only way I can think of, is sending your code to Delphi command line compiler and then execute...
DCC32.EXE, the Delphi Command Line Compiler
0
 
LVL 30

Expert Comment

by:Marco Gasi
ID: 37816436
I'm sorry but I don't understand. In your example it seems like you are comparing the values of a certain portion of a memo text and a predefined string and if they match you show a message. Or you want that one writes code in the memo and the app have to execute it? If so, this is not possible, since Delphi is a compiled language. If the first thing is what you wnat to do, I don't see the problem... I think i'm missing something...
0
 

Author Comment

by:prampatel
ID: 37816443
hi,

thanx for the response..but i think that borland specifically mentions that the compiler cannot be used externally.
I think maybbe i need to use a scripting component to do this, but dont want to purchase one unless i am sure it can do what i need to do.

regards
prampatel
0
 
LVL 19

Expert Comment

by:Thommy
ID: 37816456
For using DCC32.EXE in your application you will need a Delphi license!!!
Compile Delphi Code In Runtime

Perhaps using a script component could be an option for you...
TORRY's: Components > Tools > Scripts
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:prampatel
ID: 37816500
hi marqusG,

"In your example it seems like you are comparing the values of a certain portion of a memo text and a predefined string and if they match you show a message."

that is exactly what i want to do.. but the strings to compare will be generated from values or commands stored in a database...

i dont have require the user to input code and execute it .

hope this clears the question.

hi thommy..i do have a license, but ill be deploying the application to multiple computers , in that case all of them will have delphi installed wont i?
i have looked at the torry scripts page, still wondering which one would be best for my requirement

regards
pram.patel
0
 

Author Comment

by:prampatel
ID: 37816560
hi marqusG,

sorry i misinterpreted your question .
i will be generating this string
maincmd := if ('copy(memo1.lines[0],1,3)' = 'XYZ' ) then.
so it could also be
maincmd := "shellexecute somefile"
or maincmd = "command from database,var from database,message from database"

thats what i am trying to do...

regards
prampatel
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 100 total points
ID: 37817592
the text in your memo must go through a parser/interpreter to examine what it has to do
... in essence you want "a programming language" for your customers

here is a sample
http://www.delphigeist.com/2009/11/another-interpreter-with-source-code.html

if you want to write your own interpreter, take a look at the design pattern for an interpreter
http://sourcemaking.com/design_patterns/interpreter/delphi
0
 

Author Comment

by:prampatel
ID: 37821325
hi Geert_Gruwez,

thanks for the solution..it works for me perfectly...have been able to make my own parser based on the links you have provided.

Thanx everyone for all the help.

regards
prampatel
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now