Solved

Is possible to load code from .txt file ?

Posted on 2003-11-10
26
376 Views
Last Modified: 2010-04-05
Hi experts. I have one question. Is possible to load code from .txt file ? So the program use code from .txt not from the program. Like mirc scripting or something like that. How I shuld do that ?
0
Comment
Question by:Polde
[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
  • 4
  • 3
  • 3
  • +7
26 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9713233
no, except
you code your own interpreter
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 30 total points
ID: 9713503
Hello

you can use Innerfuse Pascal Script to do that, it's free
http://www.carlo-kok.com/ifps3.php

or Fast Experts, but it's not free, but allow you to use Pascal and C++ code
http://www.fast-report.com/en/fastexperts.php

0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 9713619
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 27

Expert Comment

by:kretzschmar
ID: 9713710
well, ok, a third-party-interpreter instead of an own is also possible :-))
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 9713820
of course :-)
"No" means it's not available with Delphi, but he can write his own or use third party
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9714212
Yes you CAN use code in a text file. Use the Include directive:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{$I 'myfile.txt'}

procedure TForm1.FormCreate(Sender: TObject);
begin
      TestMe;
end;

end.

//// and in myfile.txt...

procedure TestMe;
begin
        ShowMessage('Hello, world!');
end;


Geoff M.
0
 
LVL 7

Expert Comment

by:jconde
ID: 9715157
You can add scripting capabilities by using an embedded language.  There's a very nice translation of the Zend (PHP) api to Delphi which you can download for free ... I think its called php4delphi in www.delphipages.com.

Back a few years there was another free component called TPasScript (or something of the sort also found in www.delphipages.com) which basically added a pascal interpreter to delphi written apps.

If you search the web a little, you can also easily include VBA scripting without problems.

BTW, perl was originally built with the intent to be an embedded library for a scripting language ... I don't know if there are any delphi components for this, but by looking at the neede functions it shouldn't be too hard.  The same goes for python.
0
 
LVL 2

Expert Comment

by:j42
ID: 9715158
You can install Delphi on your target system and use ShellExecute('C:\programs\borland\Delphi x\bin\delphi32.exe', ...) to compile a temporary *.exe file. Another ShellExecute('tmp.exe', ...) will start it.
0
 
LVL 1

Expert Comment

by:capaverde
ID: 9716397
Are you trying to write a trojan?
Why do you want to load code from .txt?
.exe is not ok?
0
 

Author Comment

by:Polde
ID: 9716906
Wowwww :)). So much answers :))) This is great :). No I dont want to write a trojan ! I dont havea time for this things. I wanna make my own IRC client and I realy didnt have any idea about scripting .)
0
 
LVL 2

Expert Comment

by:SaLz
ID: 9718442
you probly would be best using ini or xml for your scripting

ini is like a text file but it can hold your data like a database.

uses
INIFiles

procedure TForm1.Button1Click(Sender: TObject);
var
myINI : TINIFile;
begin
myINI := TINIFile.Create(ExtractFilePath(Application.EXEName) + 'tag.ini');

//Read
edit1.Text := myINI.ReadString('Table Name', 'User', 'String');
//Write
myINI.WriteString('Table Name', 'User', 'String');
//Delete
myINI.DeleteKey('Table Name', 'User',);

//Finishing
myINI.Free;

tag.ini

[Table Name]
User=SaLz


you will be able to store your data and retrieve it. this will be very good for your scripting.
0
 

Expert Comment

by:marklewiswork
ID: 9724925
Developer Express (www.devexpress.com) has a free library available.  One of the component descriptions is as follows:

dxfExpressionExplorer

This component may be considered an interpreter. It allows you to dynamically change calculation schemes in your program or the algorithm of the running program.

It can process arithmetic expressions and constructions: begin & end, if & then, if & then & else, for & to & do, while & do, repeat & until . It can also process one-argument functions.

I can only assume you can load a script at runtime.
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 9743598
If Geoff's code works then that method is very good.

Regards,

Hypoviax
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 9752423
ang on, the trouble with geoff's code it does not work outside of compilation.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9753479
That depends on exactly what the author wanted. I interpreted it as using code from a file other than the .pas file, ie at compile time. Others have interpreted it as using code at runtime. Without confirmation from the author, it is difficult to tell exactly what is required. So before you complain that my suggestion is wrong, why don't we wait to find out exactly what IS required? Fair enough, I may be wrong - but *you* might be wrong too.

Geoff M.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9753482
i guessed
>using code at runtime

;-)
0
 
LVL 5

Expert Comment

by:Hypoviax
ID: 9760495
I think this question is very confusing, and i agree with you Geoff, that until the author confirms whether or not that they want code to work at runtime or not, one can only answer the question to their interpretation.

I am sorry if i have offended you,

Regards,

Hypoviax
0
 
LVL 2

Expert Comment

by:SaLz
ID: 12766464
> No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

rofl thats an under statement, your a bit sloooow aint ya, call it more than a year rofl!! see am crying here already.
0
 
LVL 2

Expert Comment

by:SaLz
ID: 12768305
your doing a very good job, but when it says more than 21days, it really is an under statement, its been over a year, there really should be a page for admins so when they view that page, it will display all the questions for each of the categorys that are over 21 days and then the admins will deal with them as soon as possible.

sounds like common sense.

but, when its 1yr and
>No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

its just so funny, its like the admins are playing catch up, like this question had got lost for so long, but in the end it was finally found and dealt with, good job on dealing with it, was about time this question was closed. (1year to collect 30 points, mnasman, the long wait has paid off in the end)
0
 
LVL 2

Expert Comment

by:SaLz
ID: 12768441
forgive me, u do have quite a work load, if u need more admins, I'll be happy to apply.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 84
Dynamically Created Query 3 69
DBCtrlGrid, Delphi, Scroll 7 32
TlistView is Really heavy on Android 3 14
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

763 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