[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1035
  • Last Modified:

RemObjects PascalScript ?

I am trying to do some database stuff with RemObjects PascalScript. In particular, I would like to create an instance of a TSQLConnection & TSQLQuery (assign it a sql string) and perform the query.

These components are part of DBExpress. Is this possible, if so how?

I need better instructions than "register the classes", because, iv'e tried that and a million other things and can't seem to do this.

Im thinking ROPS needs to know about these classes and maybe even there hierarchy as well...... ??????

Has anyone done this or is there anyone that can show me a simple example how to do this... I would surely appreciate it...thanks!

500 Points for info on how to make PascalScript recognize these components, then how to create the script to create a TSQLConnection , TSQLQuery, assign it an SQL string and perform it.

THANKS!
0
unsysapps
Asked:
unsysapps
1 Solution
 
heretoreadCommented:
Think you will need to the source code to those components in order for the script engine to read it, Unless it can use DCU's.
0
 
unsysappsAuthor Commented:
I have the source code.....as I stated in my post, I am using the DBExpress components which come with delphi.
0
 
heretoreadCommented:
You didn't state you had access to source code.
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.

 
Mohammed NasmanSoftware DeveloperCommented:
Try to ask the question in the remObjects newsgroups, they have active newsgroups, and you will got answer from the author him self ;-)

http://www.remobjects.com/page.asp?id={C4764DFE-288D-4C17-90F8-FA5B7BFB3BCB}
0
 
unsysappsAuthor Commented:
heretoread ....OK...I Have Source Code!  Hows that...now can you give me something thats useful....like an example or snipplet how?

0
 
unsysappsAuthor Commented:
Thanks mnasman, but Im quite aware of remobjects website - and there newsgroups...which are not very active.
0
 
unsysappsAuthor Commented:

I need to get this script working using the RemObjects Script component.

program test;
var
 Conn: TSQLConnection;
begin
 Conn:= TSQLConnection.Create(Self);
 Conn.Free;
end.

I have followed everything I can find to read about.

I have a very small project with all source code (zipped up) ready for anyone who would like to tackle this.  Email me at holmesshane AT charter DOT net and I will send you the zipped up project.

OR you can get the zip (sholmes.zip) from the remObjects newsgroups:


project can be found here:

remobjects.public.binaries

and the original question asked here:

remobjects.public.pascalscript

THANKS

Shane
0
 
unsysappsAuthor Commented:
I have solved this issue:  Admin, please return my points - thanks!


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, SqlExpr, uPSComponent_Default, uPSComponent, uPSComponent_DB,
  uPSComponent_DBX, uPSCompiler, uPSDebugger, uPSRuntime,
  uPSR_DB,
  uPSC_DB,
  uPSR_DBX,
  uPSC_DBX,
  uPSR_dll,
  uPSC_dll,
  uPSR_std,
  uPSC_std,
  uPSR_forms,
  uPSC_forms,
  uPSR_menus,
  uPSC_menus,
  uPSC_comobj,
  uPSR_comobj,
  uPSC_buttons,
  uPSR_buttons,
  uPSC_classes,
  uPSR_classes,
  uPSC_extctrls,
  uPSR_extctrls,
  uPSR_stdctrls,
  uPSC_stdctrls,
  uPSC_graphics,
  uPSR_graphics,
  uPSC_controls,
  uPSR_controls,
  uPSC_dateutils,
  uPSR_dateutils;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Memo2: TMemo;
    PSScript1: TPSScript;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    Button2: TButton;
    Button3: TButton;
    PSImport_DB1: TPSImport_DB;
    PSImport_Classes1: TPSImport_Classes;
    PSImport_DBX1: TPSImport_DBX;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure PSScript1Execute(Sender: TPSScript);
    procedure PSScript1Compile(Sender: TPSScript);
    procedure PSScript1CompImport(Sender: TObject; x: TPSPascalCompiler);
    procedure PSScript1ExecImport(Sender: TObject; se: TPSExec;
      x: TPSRuntimeClassImporter);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 Compiled, Executed: Boolean;
 I: Integer;
begin
 //clear script memo
 memo2.Lines.Clear;
 //clear scripting component
 PSScript1.Script.Clear;
 //add memo lines to scripting component
 PSScript1.Script.AddStrings(memo1.Lines);
 //compile script
 Compiled:= PSScript1.Compile;
 //check to see if it compiled successfully or not
 if Compiled then
  memo2.Lines.Add('Compiled Successfully!')
 else
  memo2.Lines.Add('Compiled UnSuccessfully!');
 //if it didn't compile successfully then check the compiler messages
 if not Compiled then
  for I:= 0 to PSScript1.CompilerMessageCount - 1 do
   memo2.Lines.Add(PSScript1.CompilerMessages[I].MessageToString);
 //execute script
 Executed:= PSScript1.Execute;
 //check to see if script executed successfully
 if  Executed then
  memo2.Lines.Add('Executed Successfully!')
 else
  memo2.Lines.Add('Executed UnSuccessfully!');
 //if it didn't execute successfully then check the execution error
 if not Executed then memo2.Lines.Add( PSScript1.ExecErrorToString);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 if OpenDialog1.Execute then
  memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 if SaveDialog1.Execute then
  memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;

procedure TForm1.PSScript1Execute(Sender: TPSScript);
begin
 PSScript1.SetVarToInstance('SELF', Self);
 PSScript1.SetVarToInstance('APPLICATION', Application);
end;

procedure TForm1.PSScript1Compile(Sender: TPSScript);
begin
 Sender.AddRegisteredVariable('Self', 'TForm');
 Sender.AddRegisteredVariable('Application', 'TApplication');
end;

procedure TForm1.PSScript1CompImport(Sender: TObject;
  x: TPSPascalCompiler);
begin
  SIRegister_Std(x);
  SIRegister_Classes(x, True);
  //SIRegister_Graphics(x, True);
  SIRegister_Controls(x);
  //SIRegister_StdCtrls(x);
  SIRegister_Forms(x);
  //SIRegister_ComObj(x);
  //SIRegister_Buttons(x);
  //SIRegister_ExtCtrls(x);
  //SIRegister_Menus(x);
  //RegisterDateTimeLibrary_C(x);
  SIRegister_DB(x);
  SIRegister_DBX(x);
end;

procedure TForm1.PSScript1ExecImport(Sender: TObject; se: TPSExec;
  x: TPSRuntimeClassImporter);
begin
  RIRegister_Std(x);
  RIRegister_Classes(x, True);
  //RIRegister_Graphics(x, True);
  RIRegister_Controls(x);
  //RIRegister_StdCtrls(x);
  RIRegister_Forms(x);
  //RIRegister_ComObj(se);
  //RIRegister_Buttons(x);
  //RIRegister_ExtCtrls(x);
  //RIRegister_Menus(x);
  //RegisterDateTimeLibrary_R(se);
  RIRegister_DB(x);
  RIRegister_DBX(x);
end;

end.


unit uPSR_DBX;
{$I PascalScript.inc}
Interface
Uses Classes, Sysutils, DB, SQLExpr, uPSRuntime, uPSUtils;

procedure RIRegisterTCustomConnection(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTSQLConnection(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTCustomSQLDataSet(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTSQLQuery(Cl: TPSRuntimeClassImporter);
procedure RIRegister_DBX(CL: TPSRuntimeClassImporter);

implementation

procedure RIRegisterTCustomConnection(Cl: TPSRuntimeClassImporter);
Begin
with Cl.Add(TCustomConnection) do
  begin
   //
  end;
end;

procedure RIRegisterTSQLConnection(Cl: TPSRuntimeClassImporter);
Begin
with Cl.Add(TSQLConnection) do
  begin
   //
  end;
end;

procedure RIRegisterTCustomSQLDataSet(Cl: TPSRuntimeClassImporter);
Begin
with Cl.Add(TCustomSQLDataSet) do
  begin
   //
  end;
end;

procedure RIRegisterTSQLQuery(Cl: TPSRuntimeClassImporter);
Begin
with Cl.Add(TSQLQuery) do
  begin
   //
  end;
end;

procedure RIRegister_DBX(CL: TPSRuntimeClassImporter);
begin
 RIRegisterTCustomConnection(Cl);
 RIRegisterTSQLConnection(Cl);
 RIRegisterTCustomSQLDataSet(Cl);
 RIRegisterTSQLQuery(Cl);
end;

{$IFDEF USEIMPORTER}
initialization
 RIImporter.Invoke(RIRegister_DBX);
{$ENDIF}
end.

unit uPSC_DBX;
{$I PascalScript.inc}
Interface
uses
  Classes, Sysutils, DB, SQLExpr, uPSCompiler, uPSUtils;

procedure SIRegisterTCustomConnection(CL: TPSPascalCompiler);
procedure SIRegisterTSQLConnection(CL: TPSPascalCompiler);
procedure SIRegisterTCustomSQLDataSet(CL: TPSPascalCompiler);
procedure SIRegisterTSQLQuery(CL: TPSPascalCompiler);
procedure SIRegister_DBX(Cl: TPSPascalCompiler);

implementation

Function RegClassS(cl : TPSPascalCompiler;Const InheritsFrom,Classname : String) : TPSCompileTimeClass;
begin
Result := cl.FindClass(Classname);
if Result = nil then
  Result := cl.AddClassN(cl.FindClass(InheritsFrom),Classname)
else
  Result.ClassInheritsFrom := cl.FindClass(InheritsFrom);
end;


procedure SIRegisterTCustomConnection(CL: TPSPascalCompiler);
Begin
With RegClassS(cl,'TComponent','TCustomConnection') do
begin
 //
end;
end;


procedure SIRegisterTSQLConnection(CL: TPSPascalCompiler);
Begin
With RegClassS(cl,'TCustomConnection','TSQLConnection') do
begin
 //
end;
end;

procedure SIRegisterTCustomSQLDataSet(CL: TPSPascalCompiler);
Begin
With RegClassS(cl,'TDataSet','TCustomSQLDataSet') do
begin
 //
end;
end;

procedure SIRegisterTSQLQuery(CL: TPSPascalCompiler);
Begin
With RegClassS(cl,'TCustomSQLDataSet','TSQLQuery') do
begin
 //
end;
end;

procedure SIRegister_DBX(Cl: TPSPascalCompiler);
Begin
 RegClassS(cl,'TComponent','TCustomConnection');
 RegClassS(cl,'TCustomConnection','TSQLConnection');
 RegClassS(cl,'TDataSet','TCustomSQLDataSet');
 RegClassS(cl,'TCustomSQLDataSet','TSQLQuery');

 SIRegisterTCustomConnection(Cl);
 SIRegisterTSQLConnection(Cl);
 SIRegisterTCustomSQLDataSet(Cl);
 SIRegisterTSQLQuery(Cl);
end;

{$IFDEF USEIMPORTER}
initialization
 CIImporter.AddCallBack(@SIRegister_DBX,PT_ClassImport);
{$ENDIF}
end.


0
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now