Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Execute code at runtime in delphi7

Posted on 2012-04-06
8
Medium Priority
?
662 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 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