Dear developers!
I try use PascalScript in Embarcadero Rad Studio XE2. My application is C++ Builder source. I recompiled Delphi file to HPP files and made Library and included in my project. Application compiled and linked without any problems;
I have code (as your example)
…
pPascalCompiler = new TPSPascalCompiler();
pPascalCompiler->OnUses = ScriptOnUses;
…
when calling void(procedure) - ScriptOnUses
bool __fastcall ScriptOnUses(TPSPascalCompiler * Sender, const AnsiString Name){
if (Name == “SYSTEM”){
TPSType * T = new TPSType();
TPSRecordType * RecT = new TPSRecordType();
…
parameter “Name” - is NULL. I read in manual - “Name” must be “SYSTEM” or Name of module.
I have question - can i use PascalScript in C++ Builder? If can, what is wrong in my way?
Thank you very much. Sorry for disturbance.
Best regards
I use break points…
Your code (work fine)
if @FOnUses <> nil then
begin
try
if not OnUses(Self, ‘SYSTEM’) then <-------- Call procedure
begin
Cleanup;
exit;
end;
except
on e: Exception do
begin
MakeError(’’, ecCustomError, tbtstring(e.Message));
Cleanup;
exit;
end;
end;
end;
My procedure:
bool __fastcall ScriptOnUses(TPSPascalCompiler * Sender, const AnsiString Name){
if (Name == “SYSTEM”){
TPSType * T = new TPSType();
TPSRecordType * RecT = new TPSRecordType();
Address of “Sender” my procedure obtain correct, but “Name” is NULL.
Next step, for
Sender->AddDelphiFunction(“function Random(x:integer):integer”);
your method is called, but not obtained string…
Problem receive string only …
Opssss…
My question is closed!
I change in HPP file AnsiString onto char *, as
typedef bool __fastcall (TPSOnUses)(TPSPascalCompiler Sender, const char * Name);
and change it at “ScriptOnUses”.
bool __fastcall ScriptOnUses(TPSPascalCompiler * Sender, const char * Name)
now work properly!