Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute code at runtime in delphi7

Posted on 2012-04-06
8
Medium Priority
?
644 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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.

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
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

721 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