Solved

Execute code at runtime in delphi7

Posted on 2012-04-06
8
619 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
Technology Partners: 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 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to call a form that is in a DLL  from an application? 13 95
Find and Replace Stream with 0s 8 82
TlistView is Really heavy on Android 3 42
QuickReport, Delphi, Shape 12 44
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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