If you're system is only going to run on Windows, you can't go wrong with
using VBScript (free and easy to use). I wrote a small and simple generic
function that I call whenever I need to execute a script. You need to
install the VB Script Engine AND Script Control available from
msdn.microsoft.com/scripting and then import/install the Script Control to
create the imported type library file mentioned below (also allow Delphi to
create a wrapper TClass around it).  Also remember that if you haven't used
COM objects in your app, you can always create COM *wrappers* for those
areas that you need to expose. If you followed a COM-based architecture to
start, well then it will all fall in place quite nicely.

interface
uses
  MSScriptControl_TLB;

const
  VBSCRIPT = 'VBScript';

// Central routine to execute a VBScript or JScript. Used throughout Saturn.
//      Example usage:
//        varRes := CoResult.Create;      - generic result COM object that
only has one variant Result property
//        varOrder := CoOrder.Create;   - order COM object
//        ExecuteScript(['Result', 'Order'], [varRes, varOrder],
'Result.Value = Order.Total + 25');
//        ShowMessage(FloatToStr(varRes.Value));

procedure ExecuteScript(const aObjectNames: array of string;
// name of object(s) in script
                                       const aObjects: array of IDispatch;
// actual objects
                                       const aScript: string;
// vbscript (no need for Sub Main)
                                       const aScriptLanguage: string =
VBSCRIPT);         // default language
var
  varScriptControl: TScriptControl;
  i: integer;
begin
  varScriptControl := TScriptControl.Create(nil);
  try
    with varScriptControl do
    begin
      Language := aScriptLanguage;
      Timeout := -1;                   // no timeout
      // Add Objects
      for i := low(aObjects) to high(aObjects) do
        AddObject(aObjectNames[i], aObjects[i], False);
      // Execute
      ExecuteStatement(aScript);
      Reset;
    end;
  finally
    varScriptControl.Free;
  end;
end;

HTH
Xander

----- Original Message -----
From: "Mark Derricutt" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 12:42 PM
Subject: [DUG]: Scripting Languages...


> 'allo - Once again I'm wanting to look into injecting a scripting language
> into a project I'm working, in the past I used the Python For Delphi
> project and loved it, but am not sure if I want to go with that this time.
>
> I was thinking along the lines of working with any registered
ActiveScript,
> but have no idea how to go about doing this.  I know Max wrote his own
> MaxBasic thing, but I fear thats beyond me :P
>
> Does anyone know of any URLs for implemented the MS scripting components
(I
> know they reek of security problems, but at the mo I'm keen on looking at
> various things.
>
> But, on the other side of scripting, I was wondering the best way of
> handling the recording of macros, and call back functions.
>
> I seem to recall when Max gave his demo, they had a line of code in each
> event that recording what was being done and any params needed or
> something?   Mmmm, I go read web sites about it and eat lunch....
>
>
>
> --
> There are exceptions, I'm sure, but the Windows 2000 on-line community
> seems to have, in general, the moral and spiritual qualities of your
> average porn site. (c) Bryan Pfaffenberger, Linux Journal, Jan 2001.
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
>


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to