• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 522
  • Last Modified:

External Code // Scripting engine?


I have a query regarding running external code in delphi at runtime. Some time back, possibly a year or two ago, i was reading an article online about how Delphi can be used to run code written in a simple .txt document. Having reformatted my computor, and thinking this article was not needed, i did not think twice before deleting it. (But as you can guess by my question, i kind of need it now).

I am aware that it's possible to use scripting engines, and have listed a couple of these methods below, but i would like a solution similar to the article i used to have.
1. http://www.delphidevelopers.com/learnbooks/Scripting_your_Delphi_Application.htm
2. http://cc.borland.com/ccweb.exe/listing?id=18302

I would be extremely pleased if anyone has any information about how to get delphi to run code written in a seperate .txt document to my project. The code written in the .txt document will be written in normal delphi syntax. (eg, just general procedures, functions and so on...)
0
Greenandroid
Asked:
Greenandroid
  • 10
  • 7
  • 3
  • +2
13 Solutions
 
paulb1989Commented:
www.remobjects.com

Look for PascalScript
0
 
GreenandroidAuthor Commented:
Hmmm a good start, but possibly a little more complex than i need. This scripting engine is similar to the 2 i posted in my original post, but ideally id like a way to just include some code thats inside a .txt
0
 
Mohammed NasmanSoftware DeveloperCommented:
may this one help
http://www.lischke-online.de/DCG.php

for more advanced one and support many languages(pascal,Java, C++) look at FastScript
0
Industry Leaders: 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!

 
GreenandroidAuthor Commented:
too complex.

Just looking for a simple solution here.
Thanks anyway
0
 
paulb1989Commented:
If you just need to execute simple commands you may be best off writing your own simple scripting engine... You could do it simply by reading a text file into a TStringList, looping through the lines and acting according to the lines text.
0
 
BlackTigerXCommented:
0
 
GreenandroidAuthor Commented:
BlackTiger,

This is not the article i was looking for.. infact i have seen this article already (it is an EXACT copy of one of the two links i posted in my original question).

Paulb, the vague method you outlined is exactly what i am looking for, and is basically what the article i had read prior did. Unfortunately i do not have this any more, and hence why i am asking here for some code perhaps to do this. I do not have the time to write my own, nor do i know how to.
0
 
Eddie ShipmanAll-around developerCommented:
How about using PHP? You can load a script using PHP and PHP4Delphi. Check this out:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21056045.html
0
 
Eddie ShipmanAll-around developerCommented:
oops...
"The code written in the .txt document will be written in normal delphi syntax"

DreamScripter is what you need then.  
http://www.dreamcompany.com/scripter.html
0
 
GreenandroidAuthor Commented:
This DreamScripter is PERFECT for what i need, however i have 2 issues with using this. From what i can see, and having downloaded it, there is actually little (in fact no) documentation  for these components at all. The demo application available for download does everything i need my application to do, however does not include the source code.
The demos bundled with the components itself are of no real use to me. They do not show me how to implement the actual code input side of things.
My second issue is that this product costs. After 30 days it requires me to purchase the full edition, evidently something which i do not want to do (nor do i have the money to).

There must be something which is near enough identicle to this, which is free (and include some form of documentation).

Regards
James
0
 
Eddie ShipmanAll-around developerCommented:
Hey, sometimes, you have to pay to play!!
0
 
GreenandroidAuthor Commented:
Well i am paying for the code... albeit 125 EE points ;)
0
 
BlackTigerXCommented:
dream-com has been around for quite a while, their components rock... but of course not free... there are other solutions, not as good, that are free

http://www.dwscript.com/ and others
0
 
Eddie ShipmanAll-around developerCommented:
While I knew about DWS, I didn't know that it could be used outside an ISAPI/CGI module. Cool...
0
 
GreenandroidAuthor Commented:
dwscript intrigues me....

It seems to work nicely, but i think it could be more hassle than its worth. Afterall, i'd have to pre-declare prog.info[] for each and every component in my entire program, aswell as assign a variable to each. I really think this is where dws lets itself down, and id probably have to write a considerable amount of documentation if i were to include the dws engine in my program.

Other suggestions....?
0
 
Eddie ShipmanAll-around developerCommented:
http://www.contextsoft.com/products/ctxscript/
The Trial is freeware and unlimited but there is no source. Source costs $29.
0
 
Eddie ShipmanAll-around developerCommented:
Or how wabout:
TjanScript: http://jansfreeware.com/janscript.zip
30-July-2000 size:296kb
TjanScript is Delphi native, Forth style, script component that supports include files, variants, variables, nested: procedures, if/else and repeat..until; external variables and system calls through events; XML DOM support including pattern based selection for server side page generation. The script is precompiled before it is run. Suitable for use as: general and server side scripting, expression evaluator, TDataSet onFilterRecord evaluator etc. Extensive help file and EXE demo included.
 
0
 
GreenandroidAuthor Commented:
Argh,

Thanks for your two submissions eddie, however i have issues with both. With ctxscript, you are required to declare all variables and components before usage, similar to dws (as previously posted). Janscript is just impossible to work with. Added to the fact that it has limited functionability, it also does not recognise simple delphi expressions, as mentioned in its help file. The way you use it to perform functions is rather bizarre (such as writting  2 2 + instead of 2+2 in order to return the value of 4).

Perhaps i should expand on exactly what i need this script to do, so rather than wasting both your time and mine, we all have a clearer idea of what is needed.

The article i tried and tested simply used a .txt file. When the txt file was present (in the same folder as the .exe), the content of the .txt were loaded into the program and executed as part of the code inside the .exe. Let me give you can example. For writing the onclick method for form1, you could write this whole procedure inside the txt file, in the exact syntax as you would write it in the program. The article was also a written example, and required no components.

Of course, i am not going to be fussy in the answer i get (to a certian extent). I do not require that it has no components, or loads from a txt file...this is all stuff i can do at a later date. All i require is something which enables me to write somewhere, whether its inside of a memo or other such item, and run any code i write. I also need it NOT to require me to predefine every procedure, variable or component im going to use. In all of the examples above, the scripts require me to input variables for all of my components, and could get rather monotomous having to do this on applications i have written, which contain several hundred components.

It would be nice to be able to write something such as form1.caption:='yay, it finally works', and have the code do this action, but EVERY set of scripting components i have tried above will simply provide an error, saying 'form1' is not a recognised word.

I am aware that there might not be an immediately obvious way of doing this, but i assure you that there is. This whole thread has bothered me soo much, im now manually searching my entire computor for any traces of files i may have compiled having used this article, and 'accidently' copied tto my computor after reformatting it.

Keep up the hunt folks :P

Regards
0
 
GreenandroidAuthor Commented:
Increase point vlaue
0
 
Eddie ShipmanAll-around developerCommented:
Well, I can find no references to any other articles about scripting in Delphi.
It would be great if you could remember more about the article.
0
 
GreenandroidAuthor Commented:
I would love to, but i've totally exausted my memory :P

Its a little like including .rc files. In delphi, you can specify what files to include, and the article used this to include a .txt or .dat file. Normal code was written in this file, and it run it. But perhaps my memory is failing me, as it was possible to change the contents of these included files, after the project had been compiled, and when the .xe was run again, the new code was executed.

If i hear no reply to this, i shall allocate the points according to input.

Regards
0
 
paulb1989Commented:
You cannot simply run code as if it were part of the exe unless you plan on writing a full blown compiler. Most use an interpretor such as PascalScript, DreamScripter or the MS ActiveX scripting control.
0
 
GreenandroidAuthor Commented:
Well it was not a compiler, but infact a rather small piece of script in comparison.
I have given up hope of finding this script now, so as i said previously, i will allocate points according to participants input.

Many Regards
Jay
0

Featured Post

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!

  • 10
  • 7
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now