Delphi Prism Script for .Net free project

I'm looking at Delphi Prism primarily because of the Script for .Net project you provide since I need to include ECMA Scripting within a .Net application.  The Script for .Net project is an incredibly usefull starting point for me.  However looking at your C# Debugger solution lvErrors on MainForm.cs does not seem to be used and when attempting to run an invalid script no error messages are displayed.  I've tried to understand what is happening and have debugged the code to a call to ECMAScriptLanguageCon
text.CompileSourceCode into which an ErrorSink class is passed as a parameter.  Although errors are being logged via the ErrorSink object in CompileSourceCode they are not being notified externally perhaps because errorSink._listener is set to nil at this point.  I cannot find where the ErrorSink is created nor how I can get the error messages back to MainForm.cs.  If you could point me in the right direction I would be most grateful.
0
Paul
12/8/2010 3:13:18 PM
embarcadero.delphiprism 374 articles. 0 followers. Follow

4 Replies
664 Views

Similar Articles

[PageSpeed] 7

On 8-12-2010 16:13, Paul Callow wrote:
> I'm looking at Delphi Prism primarily because of the Script for .Net
> project you provide since I need to include ECMA Scripting within a
> .Net application.  The Script for .Net project is an incredibly
> usefull starting point for me.  However looking at your C# Debugger
> solution lvErrors on MainForm.cs does not seem to be used and when
> attempting to run an invalid script no error messages are displayed.

Hrmm indeed. Nice catch. They do go to the edOutput field though.

> I've tried to understand what is happening and have debugged the code
> to a call to ECMAScriptLanguageCon text.CompileSourceCode into which
> an ErrorSink class is passed as a parameter.  Although errors are
> being logged via the ErrorSink object in CompileSourceCode they are
> not being notified externally perhaps because errorSink._listener is
> set to nil at this point.  I cannot find where the ErrorSink is
> created nor how I can get the error messages back to MainForm.cs.  If
> you could point me in the right direction I would be most grateful.

Basically the DLR raises an exception when that happens. Note that this 
is for syntax errors only, and javascript really has only a few of 
those. Runtime errors are either caught (js has a try/catch statemnet) 
or passed back to the caller, in which case they return back to the 
output panel.


--
Carlo Kok
0
Carlo
12/9/2010 8:54:04 AM
> {quote:title=Carlo Kok wrote:}{quote}
> On 8-12-2010 16:13, Paul Callow wrote:
> > I'm looking at Delphi Prism primarily because of the Script for .Net
> > project you provide since I need to include ECMA Scripting within a
> > .Net application.  The Script for .Net project is an incredibly
> > usefull starting point for me.  However looking at your C# Debugger
> > solution lvErrors on MainForm.cs does not seem to be used and when
> > attempting to run an invalid script no error messages are displayed.
> 
> Hrmm indeed. Nice catch. They do go to the edOutput field though.
> 
> > I've tried to understand what is happening and have debugged the code
> > to a call to ECMAScriptLanguageCon text.CompileSourceCode into which
> > an ErrorSink class is passed as a parameter.  Although errors are
> > being logged via the ErrorSink object in CompileSourceCode they are
> > not being notified externally perhaps because errorSink._listener is
> > set to nil at this point.  I cannot find where the ErrorSink is
> > created nor how I can get the error messages back to MainForm.cs.  If
> > you could point me in the right direction I would be most grateful.
> 
> Basically the DLR raises an exception when that happens. Note that this 
> is for syntax errors only, and javascript really has only a few of 
> those. Runtime errors are either caught (js has a try/catch statemnet) 
> or passed back to the caller, in which case they return back to the 
> output panel.
> 
> 
> --
> Carlo Kok

Many Thanks for your assistance.

edOutput only appears to capture the output from writeln() statements with this being setup by scriptEngine.Globals.SetVariable("writeln", new MyDelegate(...........

It is syntax errors that I'm investigating and the error I'm generating is "Closing parenthesis expected".  So using simple script 

writeln("Hello1");
writeln("Hello2"; 
writeln("Hello3");

I can see the error disappear down the errorSink in EcmaScriptLanguageContext.CompileSourceCode (LanguageContext.pas) but this syntax error does not get displayed in either lvErrors or edOutput and I cannot see any mechanism for displaying this syntax error.  It is this syntax error (and any other syntax error as appropriate) that I'd very much like to display but cannot work out whether there is a mechanism in your ScriptComponent to display these errors.

I've not looked at runtime errors much .... but after a quick test 

writeln("Hello1");
writeln("Hello2", 5 / 0);
writeln("Hello3");

these seem to also disappear and not get displayed in edOutput.
0
Paul
12/9/2010 11:01:51 AM
On 9-12-2010 12:01, Paul Callow wrote:
>> {quote:title=Carlo Kok wrote:}{quote}
>> On 8-12-2010 16:13, Paul Callow wrote:
>>> I'm looking at Delphi Prism primarily because of the Script for .Net
>>> project you provide since I need to include ECMA Scripting within a
>>> .Net application.  The Script for .Net project is an incredibly
>>> usefull starting point for me.  However looking at your C# Debugger
>>> solution lvErrors on MainForm.cs does not seem to be used and when
>>> attempting to run an invalid script no error messages are displayed.
>>
>> Hrmm indeed. Nice catch. They do go to the edOutput field though.
>>
>>> I've tried to understand what is happening and have debugged the code
>>> to a call to ECMAScriptLanguageCon text.CompileSourceCode into which
>>> an ErrorSink class is passed as a parameter.  Although errors are
>>> being logged via the ErrorSink object in CompileSourceCode they are
>>> not being notified externally perhaps because errorSink._listener is
>>> set to nil at this point.  I cannot find where the ErrorSink is
>>> created nor how I can get the error messages back to MainForm.cs.  If
>>> you could point me in the right direction I would be most grateful.
>>
>> Basically the DLR raises an exception when that happens. Note that this
>> is for syntax errors only, and javascript really has only a few of
>> those. Runtime errors are either caught (js has a try/catch statemnet)
>> or passed back to the caller, in which case they return back to the
>> output panel.
>>
>>
>> --
>> Carlo Kok
>
> Many Thanks for your assistance.
>
> edOutput only appears to capture the output from writeln() statements with this being setup by scriptEngine.Globals.SetVariable("writeln", new MyDelegate(...........
>
> It is syntax errors that I'm investigating and the error I'm generating is "Closing parenthesis expected".  So using simple script
>
> writeln("Hello1");
> writeln("Hello2";
> writeln("Hello3");
>
> I can see the error disappear down the errorSink in EcmaScriptLanguageContext.CompileSourceCode (LanguageContext.pas) but this syntax error does not get displayed in either lvErrors or edOutput and I cannot see any mechanism for displaying this syntax error.  It is this syntax error (and any other syntax error as appropriate) that I'd very much like to display but cannot work out whether there is a mechanism in your ScriptComponent to display these errors.
>
> I've not looked at runtime errors much .... but after a quick test
>
> writeln("Hello1");
> writeln("Hello2", 5 / 0);
> writeln("Hello3");
>
> these seem to also disappear and not get displayed in edOutput.

Odd. Just tried this in the debugger sample and I get:

Hello1

Exception:
System.DivideByZeroException: Attempted to divide by zero.
    at CallSite.Target(Closure , CallSite , Int32 , Int32 )
    at 
System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite 
site, T0 arg0, T1 arg1)
    at EcmaScript$2(Closure , Scope , LanguageContext )
    at RemObjects.Script.CompiledScriptCode.Run(Scope scope) in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\Common.pas:line 114
    at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
    at RemObjects.Script.EcmaScriptComponent.IntRun() in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
584
    at RemObjects.Script.ScriptComponent.<Run>b__0() in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
487
Exception:
System.DivideByZeroException: Attempted to divide by zero.
    at CallSite.Target(Closure , CallSite , Int32 , Int32 )
    at 
System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite 
site, T0 arg0, T1 arg1)
    at EcmaScript$2(Closure , Scope , LanguageContext )
    at RemObjects.Script.CompiledScriptCode.Run(Scope scope) in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\Common.pas:line 114
    at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
    at RemObjects.Script.EcmaScriptComponent.IntRun() in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
584
    at RemObjects.Script.ScriptComponent.<Run>b__0() in 
D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
487
0
Carlo
12/15/2010 7:30:10 AM
> {quote:title=Carlo Kok wrote:}{quote}
> On 9-12-2010 12:01, Paul Callow wrote:
> >> {quote:title=Carlo Kok wrote:}{quote}
> >> On 8-12-2010 16:13, Paul Callow wrote:
> >>> I'm looking at Delphi Prism primarily because of the Script for .Net
> >>> project you provide since I need to include ECMA Scripting within a
> >>> .Net application.  The Script for .Net project is an incredibly
> >>> usefull starting point for me.  However looking at your C# Debugger
> >>> solution lvErrors on MainForm.cs does not seem to be used and when
> >>> attempting to run an invalid script no error messages are displayed.
> >>
> >> Hrmm indeed. Nice catch. They do go to the edOutput field though.
> >>
> >>> I've tried to understand what is happening and have debugged the code
> >>> to a call to ECMAScriptLanguageCon text.CompileSourceCode into which
> >>> an ErrorSink class is passed as a parameter.  Although errors are
> >>> being logged via the ErrorSink object in CompileSourceCode they are
> >>> not being notified externally perhaps because errorSink._listener is
> >>> set to nil at this point.  I cannot find where the ErrorSink is
> >>> created nor how I can get the error messages back to MainForm.cs.  If
> >>> you could point me in the right direction I would be most grateful.
> >>
> >> Basically the DLR raises an exception when that happens. Note that this
> >> is for syntax errors only, and javascript really has only a few of
> >> those. Runtime errors are either caught (js has a try/catch statemnet)
> >> or passed back to the caller, in which case they return back to the
> >> output panel.
> >>
> >>
> >> --
> >> Carlo Kok
> >
> > Many Thanks for your assistance.
> >
> > edOutput only appears to capture the output from writeln() statements with this being setup by scriptEngine.Globals.SetVariable("writeln", new MyDelegate(...........
> >
> > It is syntax errors that I'm investigating and the error I'm generating is "Closing parenthesis expected".  So using simple script
> >
> > writeln("Hello1");
> > writeln("Hello2";
> > writeln("Hello3");
> >
> > I can see the error disappear down the errorSink in EcmaScriptLanguageContext.CompileSourceCode (LanguageContext.pas) but this syntax error does not get displayed in either lvErrors or edOutput and I cannot see any mechanism for displaying this syntax error.  It is this syntax error (and any other syntax error as appropriate) that I'd very much like to display but cannot work out whether there is a mechanism in your ScriptComponent to display these errors.
> >
> > I've not looked at runtime errors much .... but after a quick test
> >
> > writeln("Hello1");
> > writeln("Hello2", 5 / 0);
> > writeln("Hello3");
> >
> > these seem to also disappear and not get displayed in edOutput.
> 
> Odd. Just tried this in the debugger sample and I get:
> 
> Hello1
> 
> Exception:
> System.DivideByZeroException: Attempted to divide by zero.
>     at CallSite.Target(Closure , CallSite , Int32 , Int32 )
>     at 
> System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite 
> site, T0 arg0, T1 arg1)
>     at EcmaScript$2(Closure , Scope , LanguageContext )
>     at RemObjects.Script.CompiledScriptCode.Run(Scope scope) in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\Common.pas:line 114
>     at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
>     at RemObjects.Script.EcmaScriptComponent.IntRun() in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
> 584
>     at RemObjects.Script.ScriptComponent.<Run>b__0() in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
> 487
> Exception:
> System.DivideByZeroException: Attempted to divide by zero.
>     at CallSite.Target(Closure , CallSite , Int32 , Int32 )
>     at 
> System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite 
> site, T0 arg0, T1 arg1)
>     at EcmaScript$2(Closure , Scope , LanguageContext )
>     at RemObjects.Script.CompiledScriptCode.Run(Scope scope) in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\Common.pas:line 114
>     at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope)
>     at RemObjects.Script.EcmaScriptComponent.IntRun() in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
> 584
>     at RemObjects.Script.ScriptComponent.<Run>b__0() in 
> D:\Data\Projects\roscript\trunk\Source\RemObjects.Script\ScriptComponent.pas:line 
> 487

It is odd that this exception displays for you and not for me.  For me when following through the code this exception is handled by a try .. except block in ScriptComponent.Run and not subsequently raised.  Fortunately I now see that the exception is set to the ScriptComponent.RunException property which my application code is able to check in MainForm's ScriptEngine_StatusChanged method.  Do you have your compiler set to show exceptions when they are thrown - this might explain the difference in behaviou
r.

Anyway any ideas on my original question with respect to accessing information on syntax errors?  eg for the script

writeln("Hello1");
writeln("Hello2";
writeln("Hello3");

Many thanks.
0
Paul
12/15/2010 6:57:14 PM
Reply:

Similar Artilces:

Delphi Prism and ASP.NET MVC project templates
Hello. I have studied ASP.NET MVC lately for developing web applications with Delphi Prism. Are there plans to supply the same project templates for Oxygene as for C#? For the moment I'm using the template from the CodeRage presentation and C# templates. But it would be nice with updated Oxygene templates. -Bjarte Bjarte K. Vebjørnsen wrote: > Are there plans to supply the same project templates for Oxygene as > for C#? Yes, there sure is. -- Nick Hodges Delphi Product Manager - Embarcadero http://blogs.codegear.com/nickhodges > {quote:title=Nick ...

Converting Delphi for Win32 to Delphi .Net(Prism)
Hi, I am currently migrating a project from Delphi for Win32 to Delphi.net. Part of my code currently goes into a directory and pulls out a random file from this directory and loads the contents of the file for me. This code doesn't seem to work in Delphi.Net. It uses PString and a number of functions in SysUtils that don't seem to be present in Delphi.net's SysUtils file. If anyone can help me please, it would be greatly appreciated! Many thanks, Jonathan Mackey Jonathan Mackey a écrit : > I am currently migrating a project from Delphi for Win32 to &...

delphi.Net Delphi 2005 Project Upgrades?
Our company aquired the software property from another last year. Most of the projects were written in Delphi 2007. We purchased Delphi XE which gave us access to previous versions, including D 2007... all is well. However, 3 projects were written Delphi 2005 for .Net. The VM we received from this company included D2005 but it was licensed from the previous developer. I've contacted Embarcadero about obtaining a copy and or a license+registration for Delphi 2005 and was told this product is no longer available. I'm under the impression Delphi for .Net was abandoned. My qu...

Convert a Delphi 2006 WinForms project to Delphi Prism
How can I go about doing this short of recreating the project and transfering code? Just wondering what to expect if we go to Prism. Thanks. -- Don Gollahon Don Gollahon wrote: > How can I go about doing this short of recreating the project and > transfering code? > > Just wondering what to expect if we go to Prism. > > Thanks. Hi Don, Have you checked out the migration tool Oxidizer ? http://prismwiki.codegear.com/en/Oxidizer Cheers, John -- John Moshakis wrote: >Don Gollahon wrote: > >> How can I go about doing th...

Delphi Prism for cross-platform projects: Started a project
As I suspected Delphi Prism is ideal for my purposes. Since I am a hobby linguist, my program is a Hebrew verb conjugation application. I am trying to formulate all necessary rules including all exceptions in Pascal. Last year I implemented a working prototype in Objective-C. http://web.mac.com/ajbrehm/Home/Software.html It worked, but wasn't portable; and Cocoa is a bit of a hassle when it comes to string manipulation since it offers no native support for unicode regular expressions. I can re-use the GUI. This is how I am planning to proceed, slowly, of course, since I am lazy an...

The new Delphi.NET Beta (Prism) & .NET 4.0
It seams that Chris Pattinson is the first CodeGear insider that "exposed" somehow the new Delphi.NET... :) So Nick ... hurry up with the .NET roadmap ! :) Delphi Prism - new Delphi.NET Solution http://blogs.codegear.com/chrispattinson/2008/10/03/38898 "...Delphi Prism is the upcoming .NET solution using the Delphi language. To participate in this beta, you must sign the Non-Disclosure Agreement..." Delphi Prism Beta Opportunity https://beta.embarcadero.com/callout/default.html?callid=6E2829BA76664D57ABD8F26046781EA5 Regarding .NET 4.0 it is interesting to...

Free Example Code Asp.NET VB.NET C#.NET and free hosting
http://www23.brinkster.com/d880640/db/Menu.htm...

Free RAD Studio 2010 and Delphi Prism 2011 with purchase of Delphi 2010
Hi All, For those of you who complain that Delphi (and RAD Studio) is too expensive... for a few short weeks there are two overlapping special offers from Embarcadero that you can use to move up to RAD Studio 2010 including the latest Delphi Prism 2011 for the price of a single Delphi 2010 (New User or Upgrade)... The first "RAD Studio PROMO" offer is still valid until June 28th: when you order Delphi 2010, you get RAD Studio 2010 delivered instead (including Delphi 2010, C++Builder 2010 and Delphi Prism 2010). As of May 26th, the "Delphi Prism 2011" of...

Delphi Prism August release and Prism with Windows 7 and .NET 4.0
I still cannot see the download for the Prism August release. Any idea when it will be up or what I am missing? Also, does/will Prism have specific support for new features of Windows 7? How fare are we with support for .NET 4? Andrew, > I still cannot see the download for the Prism August release. Has it been announced as being available yet? I don't think it has. > Any idea when it will be up or what I am missing? Afaik the planned release date for all of RAD Studio 2010 is August 25. But that's not an official announcement, just what i hear. > Also,...

Any difference between Delphi Prism 2011 and Delphi Prism XE?
Looking at the features in Delphi Prism XE, they look the same as the new items in the 2011 release back in may. I there anything new in the XE release? or did they simply change the product branding? Just wondering if I need to update it or now when i download the rest. Thanks, Hi Dan, > Looking at the features in Delphi Prism XE, they look the same as the new items in the 2011 release back in may. I there anything new in the XE release? or did they simply change the product branding? Just wondering if I need to update it or now when i download the rest. See http://w...

How to convert VB.net project to asp.net project?
I have a VB.net project, is it possible to convert it to asp.net. If it is please show me how. Thank you If the VB.NET and is a DLL, just create a new Web Application and reference the dll. Easy and cleanCheersAlMy BlogMapStats.NETPlease click on 'Mark as Answer' if this post answered your question! Sorry for not making it clear, my vb.net project is a window application. Thanks A windows application cannot be converted to a web applications without re-writing itCheersAlMy BlogMapStats.NETPlease click on 'Mark as Answer' if this post answered your question!...

Convert a VB.NET project to a ASP.NET project
1) I have a VB.NET project developed with Visual Studio 2005. Is there any way to convert it to a ASP.NET Web application? 2) On what Web servers and platforms can a ASP.NET application run ? 3) Can a Web ASP.NET application be browsed from any type of client browsers / Operating system? thanks in advance Panos 1) Yes, there's a way.2) any web server (if not MS Windows Server, www.monoproject.com)3) yes.Kay LeeMySpace.com - http://www.myspace.com/kragieInfrastructure GroupMySpace.com- Code to live, but Live to code. KraGiE:2) any web server (if not MS Windows Server, www.m...

Delphi and Delphi for .Net
It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. I would like to know is it true all .Net application is slower than Win32 native applicaiton or it is Delphi for .Net only. Your information is great appreciated, Inung On 2011-06-21 18:20:17 +0100, Inung Huang said: > It seems that Delphi for .Net is slower than Delphi Win32 native applicaiton. > I would like to know is it true all .Net application is slower than > Win32 native applicaiton or it is Delphi for .Net only. If you are only running the code in the application once then, yes, yo...

Is there a Delphi prism asp.net group ?
I finally was able to buy my copy of Prism Professional in India(a very daunting task) Is there a Delphi Prism asp.net group Venkatesh (my name does not show up correctly in the sender column) thomas hamburger wrote: > (my name does not show up correctly in the sender column) Change your name here: https://members.codegear.com/editaccount.aspx. Once you change that, your name will appear correctly. Jon Jonathan Benedicto wrote: > thomas hamburger wrote: >> (my name does not show up correctly in the sender column) > > Change your name here: https://membe...

Web resources about - Delphi Prism Script for .Net free project - embarcadero.delphiprism

Project - Wikipedia, the free encyclopedia
For the urban low-income housing buildings called projects, see public housing . For other uses, see Project (disambiguation) . The word project ...

The Project Shrink - Welcome To Shrinkonia.
... about the importance of the environment we work in and the stories we tell, we should have a Set Designer and a Storyteller on our projects. ...

Better Projects
I think this book by Tobias is beautifully written. There is real craftmanship in the prose here. The book is made up of independent self contained ...

Origin Energy locks in floor for oil prices to cut LNG project risk
Origin Energy protects its $24.7 billion liquefied natural gas project in Queensland from further falls in crude oil prices.

Hillary Clinton wants “Manhattan-like project” to break encryption
Enlarge / Hillary Clinton. (credit: Clinton campaign. ) Presidential candidate Hillary Clinton has called for a "Manhattan-like project" to ...

Weekend Reading: D-Squared Digest: One-Minute MBA: Avoiding Projects Pursued By Morons 101
**Daniel Davies**: [The D-Squared Digest One Minute MBA: Avoiding Projects Pursued By Morons 101](http://blog.danieldavies.com/2004_05_23_d- ...

Microsoft's answer to Google's Project Loon - Business Insider
Connecting the next one billion users to the internet is a challenge being taken up by multiple technology companies, including Microsoft.

460 MW Of Russian Solar Power Projects Pre-Approved
The Russian Electricity Market Council has pre-approved 460 MW of PV solar projects for this year. About 900 MW was awarded for the years 2014 ...

Ford, Google Reportedly Teaming Up For Driverless Car Project
Just a week after Ford announced it would be joining the auto pack and heading to California to test a driverless car next year, the company ...

Becoming certified in project management will upgrade any resume [Deals]
If you want to work in an organization of any size, becoming fluent in project management is one of the most marketable skills you can acquire, ...

Resources last updated: 12/27/2015 12:59:27 AM