Execscript support, Runtime compilation or razor templates?

This forum is meant for questions about the Visual FoxPro Language support in X#.

b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Execscript support, Runtime compilation or razor templates?

Post by b2k »

I have a web application framework that uses a custom templating solution akin to VBScript to generate html.

Here is an example:

Code: Select all

<html>
<body>
<%
LOCAL ldToday
ldToday = DATE()
%>
Today is <<tdToday>>
</body>
</html>
This template is converted to a foxpro string containing:

Code: Select all

TEXT TO lchtml TEXTMERGE (flags as needed)
<html>
<body>
ENDTEXT
LOCAL ldDate
ldToday = DATE()
TEXT TO lcHtml ADDITIVE TEXTMERGE (flags as needed)
Today is <<ldDate>>
</body>
</html>
ENDTEXT
Then executed with EXECSCRIPT(lcScript, params as needed) with the results returned to the calling web server (usually aspx.net calling VFP as a multithreaded com dll)

Does XSharp support the EXECSCRIPT command? Or even better, can it serve as the language for razor templates (.xshtml)?
User avatar
robert
Posts: 4925
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Execscript support, Runtime compilation or razor templates?

Post by robert »

Brian,
Yes, we support ExecScript.
We have not looked at Razor Templates. I suspect that they are for C# only. I don't think they even support Visual Basic.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Re: Execscript support, Runtime compilation or razor templates?

Post by b2k »

I am getting this error message when trying to run ExecScript from a XSharp class library called from an ASP.Net razor template. Note that this works fine from an XSharp executable.
"The invoked member is not supported in a dynamic assembly."

Here is my Execscript call:
RETURN ExecScript("RETURN 'Hello World!'")

See attached zip file demonstrating the issue.
ExecScriptExamples.zip
(17.12 KiB) Downloaded 1046 times
User avatar
robert
Posts: 4925
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Execscript support, Runtime compilation or razor templates?

Post by robert »

Brian,
I am not in the office right now, so it is difficult to test and answer this.
I suspect that has to do with some startup code that is not running when you call ExecScript from a non X# appplication.
Normally this code is added to the main app and automatically running when the app is started,
This startup code sets the dialect in the runtime state and some other options, such as the current date/time format and codepage used for string comparisons.
I'll look into this early next week.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Re: Execscript support, Runtime compilation or razor templates?

Post by b2k »

I modified the example to be able to run the program as an application. It works as an app, and fails as a library. Note that I had to update System.Memory as well. See attached. In the revised sample, I removed the separate console app. Simply change the project type and startup project to test as a console versus library. A summary of the code changes below:

Added to ExecScriptWebDispatcher.prg:

Code: Select all

FUNCTION Start() AS VOID STRICT
        ? EXECSCRIPT("RETURN 'Hello World!'")
	    WAIT
        RETURN
END FUNCTION
Change Startup project to ExecScriptWeb with Output Type to Console Application and it works. Change it back to Class Library and Startup Project to WebRoot, and it fails as before.
ExecScriptExamples_revised.zip
(14.3 KiB) Downloaded 910 times
User avatar
robert
Posts: 4925
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Execscript support, Runtime compilation or razor templates?

Post by robert »

Brian,
I can confirm the problem with the latest public build 2.21.
However, this now works as expected with the latest subscriber build 2.23.

We plan to release a public build 2.23 later this month.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Re: Execscript support, Runtime compilation or razor templates?

Post by b2k »

Thanks so much for your help. I am eagerly awaiting the new release!
User avatar
wriedmann
Posts: 4036
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: Execscript support, Runtime compilation or razor templates?

Post by wriedmann »

Hi Brian,
if you are relying in some manner on XSharp, then I would strongly recommend support the work of the development team by a FoX subscription.
After all, also Robert and his group needs to eat and to pay their bills, and more money permits them to dedicate more time to the project and/or hire other people to do work on the project.
And FoX membership gives you also access to the newest X# version and a better support from the team and sometimes also some possibility to have some influence on the future developments.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
b2k
Posts: 20
Joined: Thu Oct 06, 2022 5:53 pm
Location: USA

Re: Execscript support, Runtime compilation or razor templates?

Post by b2k »

I would love to support the project, but my company won't do so until we have a successful pilot project. And it's not been going well so far.
mainhatten
Posts: 211
Joined: Wed Oct 09, 2019 6:51 pm

Re: Execscript support, Runtime compilation or razor templates?

Post by mainhatten »

Brian,
I have posted my take on missing "base vfp DNA" in other thread here in vfp forum.
Perhaps you should offer a prioritized list of features xSharp must support for your programs.

regards
thomas
Post Reply