A DWS 2.1 preview 3 7z archive is available at googlecode Delphi Web Script page, you can also get the same code via SVN of course.
This versions fixes several reported and unreported issues, and adds support for type inference and Delphi Prism variable initialization syntax. Before you could write code like:
var myInteger : Integer = 1234; var myObj : TSomeObject = TSomeObject.Create;
where ‘=‘ was used as assignment operator (using the same syntax as for constant declaration or default parameter values), you can now write the above using ‘:=‘ as well
var myInteger : Integer := 1234; var myObj : TSomeObject := TSomeObject.Create;
and you additionally can make use of type inference and write just
var myInteger := 1234; var myObj = TSomeObject.Create;
Type inference is currently limited to the variable declaration, this will probably stay for code clarity (opinions?). The inferred type isn’t restricted at the moment, but that will probably change (so you can disallow to inferring to a Variant type f.i.).
I haven’t seen in your example programs anywhere how to externally call a function defined with in the script.
ie. MyScript.Execute(functionName,FunctionParameters,Result);
Does DWScript have this ?
This is wonderful, great job!!
can I expect a simple web example using DWS?! thank you!!
Yes, it’s possible, I’ve quickly imported the old first steps doc from DWS2
http://code.google.com/p/dwscript/wiki/FirstSteps
it should still be relevant and correct – if incomplete – typos excepted of course.
Surprising as it may seem, I haven’t been using DWScript for strictly web purposes with the htmlfilter, so I don’t any sample website handy, so all there is right now are the htmlfilter unit tets. There may be one or two samples in the old DWS2 repository, if someone care to bring it/them up to speed.
@Eric I was just curious… how would one user DWS on a web server… I mean best approach…
I tried to call the internal functions but kept getting
a nil pointer for Prog.Info. until Debugging through your code I figured it out.
The Prog.Info is nil if you call Prog.execute;
The example should be :
Var Prog : TdwsProgram;
prog:=DelphiWebScript.Compile(memo1.lines.text);
Prog.BeginProgram();
sTemp := prog.Info.Func[‘test’].Call([i,j]).ValueAsString;
Prog.EndProgram;
@Robert Noble
Thanks, I’ve made a quick mod to the wiki page, more details will go in a demo when I have time.