Solved

Execute code at runtime in delphi7

Posted on 2012-04-06
8
628 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
[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
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 31

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 38

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

628 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