# Pascal Script in C++ Builder

**URL:** https://talk.remobjects.com/t/pascal-script-in-c-builder/1805
**Category:** Pascal Script
**Created:** [March 24, 2013, 12:31pm UTC](https://talk.remobjects.com/t/pascal-script-in-c-builder/1805 "2013-03-24T12:31:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fencersilverma](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/f6c823/32.png) [@fencersilverma](https://talk.remobjects.com/u/fencersilverma)
#### Post date: [March 24, 2013, 12:31pm UTC](https://talk.remobjects.com/t/pascal-script-in-c-builder/1805/1 "2013-03-24T12:31:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fencersilverma](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/f6c823/32.png) [@fencersilverma](https://talk.remobjects.com/u/fencersilverma)
#### Post date: [March 24, 2013, 5:17pm UTC](https://talk.remobjects.com/t/pascal-script-in-c-builder/1805/2 "2013-03-24T17:17:17Z")

</div>

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 …

---

<div class="post-metadata">

### Author: ![fencersilverma](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/f6c823/32.png) [@fencersilverma](https://talk.remobjects.com/u/fencersilverma)
#### Post date: [March 24, 2013, 5:54pm UTC](https://talk.remobjects.com/t/pascal-script-in-c-builder/1805/3 "2013-03-24T17:54:42Z")

</div>

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!
