Questions tagged [dwscript]

DWScript is an object-oriented scripting engine for Delphi based on the Delphi language, with extensions borrowed from other Pascal languages (FreePascal, Prism, etc.).

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

Option to turn off short-circuit boolean evaluation

So I have a user-definable script that may look something like this: Result := (File.Size > 1000) OR (Image.Type = 'PNG'); My application requires that I know which objects were tested for, in this ...
Petey's user avatar
  • 49
0 votes
1 answer
24 views

Identifying which overloaded function in Eval

I am trying to create 2 overloaded functions for a class, something along the lines of: function Tag(Value: string): string; overload; function Tag(Group, Element: Integer): string; overload; In the ...
Petey's user avatar
  • 49
1 vote
1 answer
73 views

How to get Delphi side exception class from generic EDelphi exception in script

Calling a Delphi side function from a script that raises an exception raises a generic EDelphi exception on the script side. This hides the exception class of the actual Delphi side exception. I tried ...
LuWey's user avatar
  • 41
0 votes
1 answer
70 views

DWScript: Property getter/setter for object

The tdwsUnit declares a property of type TObject, as well as a getter and a setter. An instantiated object shall be stored in an "object store" on the Delphi side. The goal is to transport ...
LuWey's user avatar
  • 41
0 votes
1 answer
38 views

How to change the caption of a button, using DWScript

I want to interact with GUI elements, from within DWScript (created by Eric Grange). For example change the caption of a button from 'Click Me' to 'Clicked'; I think that within tdwsUnit the TButton ...
Rudolf's user avatar
  • 3
1 vote
1 answer
144 views

DWS insert variable values on debug

I'm facing a problem I can't find the workaround... I have a script which take some parameter data before execution. When I run it my code looks like: Exec := FProgram.CreateNewExecution; Exec....
Adrian De Armas's user avatar
1 vote
1 answer
181 views

How to initialize an object in DWScipt?

What is the equivalent of this JS code in DWScript please? I use the DWScript codegen. // JavaScript: DoIt({name:"Fred", size:{width:3,height:2}}); I tried anonymous record but it seems not ...
Toky Olivier Razanakotonarivo's user avatar
1 vote
1 answer
425 views

How to expose a dynamic array of records in DWScript?

I've declared a simple record type in a DWScript unit: TSampleRecord = record name: string; end; How can I expose such an array from the Delphi application to the script ? For example, the ...
jonjbar's user avatar
  • 3,946
0 votes
0 answers
215 views

How to access properties or methods of another class object within a class in DWScript?

I am actually using dwscript with delphi and got stuck with the follwing problem: I have defined two classes as follows TClassOne = class private FName : String; public property Name: ...
Radiesel's user avatar
  • 371
-1 votes
1 answer
184 views

Monitor current line number while running DWScript?

I'm using the latest DWScript which has a TdwsDebugger component with it. However I'm not necessarily looking to provide debugging tools to the user - just visually show the current line number. In ...
Jerry Dodge's user avatar
  • 26.9k
1 vote
2 answers
86 views

How to use dwsXPlatform.CollectFiles TCollectFileProgressEvent

As I am new to events in delphi I am struggling on how to use dwsXPlatform.TCollectFileProgressEvent in conjunction with dwsXPlatform.CollectFiles. In the DWScript repository there is no sample or ...
Fabio Vitale's user avatar
  • 2,257
2 votes
2 answers
138 views

Compiling DWScript units with circular references gives ECompileError "Unknown Name"

I have two DWScript unit files: unit unit1; | unit unit2; | interface | interface | procedure ...
Vlad's user avatar
  • 43
0 votes
0 answers
112 views

EdwsActivePrograms exception when closing the application

I'm getting the following EdwsActivePrograms exception when IdwsProgram and IdwsProgramExecution variables are defined globally: TDelphiWebScript instance "dws" still has 1 active IdwsProgram ...
Vlad's user avatar
  • 43
0 votes
2 answers
112 views

How registrate two class with circular references in DWScript?

I need to register TCollection and TCollectionItem classes, but because of the properties of {TCollection} property Items [Index: Integer]: TCollectionItem {TCollectionItem} property Collection: ...
Alexey Ignatenko's user avatar
0 votes
0 answers
140 views

How I can register function without parameter type in DWScript

I want register into script some stream method. For example function Read(Self: TStream; var Buffer; Count: Longint): Longint; But parametr "Buffer" does not have type(by dws). How can I register ...
Alexey Ignatenko's user avatar
0 votes
1 answer
269 views

May DWS calling functions from sample unit?

May DWS calling functions from sample unit? For example: FExecution.Info.Func['Test.ClickProc'].Call(AParams); (This is not working) FExecution - IdwsProgramExecution; Function declared in Script ...
Alexey Ignatenko's user avatar
1 vote
1 answer
307 views

Delphi Web Script: How to call global TForm object's property in script?

I've registered TForm class and its 'caption' property, then I register a global variable: NewGlobal := DwsUnit.Variables.Add; NewGlobal.Name := 'MainForm'; NewGlobal.DataType := 'TForm'; NewGlobal....
Alexey Ignatenko's user avatar
3 votes
1 answer
404 views

Is it possible to create a Read–eval–print loop (REPL) using DWScript?

I am trying to create a Read–eval–print loop (REPL) with DWScript and I'm not sure this is possible. Based on the name, I assumed that RecompileInContext would work fine in that context but I am ...
jonjbar's user avatar
  • 3,946
7 votes
1 answer
347 views

How to check return value of DWScript FileCreate function?

Using DWScript, I don't see obvious way of checking the return value of the FileCreate function. Example (not working) script: function TestFileCreate : Boolean; var F : File; begin F := ...
fpiette's user avatar
  • 12k
1 vote
0 answers
128 views

DWScript: Possible bug in TdwsFileNotifier

In procedure TdwsFileNotifier.Execute, when ReadDirectoryChanges call fails, the thread is terminated by calling Terminate but the loop is not immediately exited. IMO there should be a break ...
fpiette's user avatar
  • 12k
1 vote
1 answer
466 views

DWScript: exposing and returning an object to script from Delphi function?

In my Delphi (2010) code I have a class TImageItem, which I have exposed to DWScript via: dwsUnit.ExposeRTTI(TypeInfo(TImageItem),[eoNoFreeOnCleanup, eoExposePublic]); In dwsUnit I have declared a ...
hukka's user avatar
  • 13
4 votes
1 answer
564 views

DWScript: passing a set-of-enumerated-type will pass an array of integer

From a DWScript script, I call a method of an object instance exposed by the Delphi side. The method takes, among others, an argument which is a set of some enumerated data type. This enumerated ...
fpiette's user avatar
  • 12k
0 votes
0 answers
211 views

Is DWScript fully thread safe?

Threaded script Execute and DWScript thread safe are not very clear about this situation: A script is run in the context of a worker thread. While a script function is executing, called by the worker ...
fpiette's user avatar
  • 12k
4 votes
1 answer
2k views

How to declare a method of a Delphi object called from a script having a procedure type argument

In have a Delphi application running a DWS script. The Delphi application exposes an object instance, let's call it "MyApplication", to the script. The exposed object has a method which has one ...
fpiette's user avatar
  • 12k
0 votes
1 answer
429 views

Using / injecting an interface instance implemented in Delphi in dwscript

I have an interface (in fact multiple interfaces) which I'd like to use this way: Make Units where the interfaces are declared available inside the dwscript script (if neccessary). Create the objects,...
Sebastian Jänicke's user avatar
1 vote
0 answers
123 views

DWScript set TFormStyle property on external TForm instance

I try to set some properties on a TForm instance that is "injected" into the script using TdwsRTTIConnector and the funcion: procedure TForm1.OnFunctionEval_ConnectForm(info: TProgramInfo); var c:...
jamesgza's user avatar
2 votes
1 answer
477 views

How to install the latest Subversion version of DWScript?

The most recent preview of DWScript is from October two years ago, and since the project is active and I want to use it in XE7, I thought I would check out the latest source (r2653 at the time of ...
David's user avatar
  • 13.4k
7 votes
1 answer
451 views

DWScript: Getting from IScriptObj to IInfo or TProgramInfo

Given a IScriptObj reference how does one get to a corresponding IInfo or TProgramInfo? I have a script object that wraps a Delphi object. In order to manage the life time of the script object the ...
AndersMelander's user avatar
1 vote
1 answer
523 views

How to install DWScript

I am trying to install DWScript into Delphi XE4: (I did copy the package files into a DelphiXE4 folder and change the package suffix property to XE4...) In the packages folder there are 3 files: ...
RaelB's user avatar
  • 3,361
0 votes
3 answers
1k views

Why multithreaded memory allocate/deallocate intensive application does not scale with number of threads?

Notice: Original post title Why multithreaded JSON parser from DWScript does not scale with number of threads? was changed because this problem is not related to processing JSON data with ...
YpsArthur's user avatar
2 votes
0 answers
267 views

Pass Object from magic function

I need to use TStringList in dwscript. In compiled delphi code I use both sl := TStringList.Create; and sl := genSL; where genSL creates and poulates the TStringList. I would like to use this ...
Folkert Hasenlust's user avatar
5 votes
3 answers
385 views

DWScript setter for a property which is a Record

my issue is pretty simple. I have a dwsUnit which have this code: type TPointCoord = record X: Float; Y: Float; Z: Float; end; type TMyClass = class private fPosition: ...
user3931540's user avatar
0 votes
1 answer
233 views

DWScript, Monkey Patching: Add method or property at runtime

At the moment I wrote a ORM mapping for DWScript + SQLite. I have successfully implemented mapping for normal properties (like string or integer), but now I want to add Foreign Keys and Many To Many ...
DragonFlyOfGold's user avatar
1 vote
1 answer
150 views

Use Script RTTI in DWSWebServer

At the moment I'm playing a little bit with the DWSWebServer. I really like the idea of coding dynamic websites with a pascal style language. Now I would like to implement a simple ORM using the ...
DragonFlyOfGold's user avatar
0 votes
1 answer
342 views

DWScript Write/Read a simple text file

I would like to write/read a simple text file using dwscript. My code is here below... but I am non able to get it run, please someone might help...: (I am using the Simple.exe in the Demos folder of ...
giarussi's user avatar
3 votes
1 answer
422 views

DWScript: How to read a meta class parameter from Delphi side

I'm having trouble using meta classes in DWScript. We are using scripting to enable VARs and end users to customize our application. Our application data basically consist of a lot of small objects ...
AndersMelander's user avatar
0 votes
1 answer
300 views

Why don't method calls work when I call DWScript's ExposeClassToUnit?

When exposing a host class and calling a procedure from it I get this exception: First chance exception at $7513C41F. Exception class ECompileError with message 'There is no accessible member with ...
user avatar
3 votes
2 answers
696 views

Call a procedure of a class from DWScript

How can I call a procedure from a class that is created in main Form. Can it be done like this pseudo code shows? type TDemo = class procedure test; constructor Create; destructor ...
user avatar
2 votes
1 answer
474 views

Is DWScript compatible to create Delphi XE5 code for Android and IOs?

Can I use DWScript classes in a Delphi XE5 program to run under Android and/or IOs and make the scripting works?
Eduardo Elias's user avatar
1 vote
1 answer
658 views

How to get rid of JSON unicode literals in Delphi/dwsJSON?

I have a piece of JSON in UTF-8 that looks like this in Google Chrome (without the new lines): {"_links": {"self": {"href": "http://bla:8888/1/2/3/2257487e4a750cab"}, "it\u0119m": [{"href": "http://...
Thijs van Dien's user avatar
2 votes
1 answer
724 views

What does "{$F 'filename'}" mean exactly?

In DWScript documentation we can see "{$F 'filename'}", but I don't understand what it means. Is it possible to describe It?
Shaahin Ashayeri's user avatar
1 vote
0 answers
210 views

Adding strongly typed RttiVariant from Delphi to expose to DWS script

I'd like to get some compile time checking on my scripts so exposing my global variables as just RTTIVariant is not desirable. I'm exposing the Screen object to script using the following code. ...
Tom Robertson's user avatar
2 votes
1 answer
243 views

Calling script functions from a modal dialog gives "Object not instantiated"

From the following script code, I call the Run procedure from Delphi which calls the showmodal procedure which is also in Delphi. The global variable sl is not instantiated when calling Button1Click() ...
Tom Robertson's user avatar
0 votes
0 answers
185 views

DWScript, retrieving a property symbol for a global variable

I'm overriding TRTTIEnvironment and am implementing function FindUnknownName(). I'd like to return a Symbol that is already exposed to the program by ExposeInstanceToUnit(). In some of my scripts the ...
Tom Robertson's user avatar
1 vote
1 answer
153 views

DWScript: TdwsGuardianThread.Finalize freeze when inside a DLL

When dwsExprs is added to a DLL, his finalization section freeze. Actaully TdwsGuardianThread.Finalize is frozen on the line guardian.WaitFor. To demonstrate the issue, I made a sample DLL, which is ...
fpiette's user avatar
  • 12k
1 vote
1 answer
188 views

DWScript: Issue updating to current development version

This weekend, I updated my code base from DWScript SVN. I used Preview 2.7 and now I'm using up-to-date trunk version. I recompile my application and now the OnAfterInitUnitTable is no more ...
fpiette's user avatar
  • 12k
0 votes
0 answers
460 views

Calling query.locate in dwscript

Is it possible to call a procedure that has a parameter of type set in dwscript? I am exposing TDataSet and TADOQuery using ExposeClassToUnit. var ScriptUnit : TdwsUnit; ScriptUnit.ExposeClassToUnit(...
Tom Robertson's user avatar
1 vote
1 answer
129 views

dwsscript Invalid Operands

I'm getting a compilation error "Invalid Operands" when compiling my dws script with RTTIVariable types. Is it possible for the following to work? Declare variable which is a form. gVar := ...
Tom Robertson's user avatar
1 vote
0 answers
260 views

Injecting interface implementation into script

How one is supposed to "inject interface implementation" into script? Say I define an interface type in TdwsUnit, like IFoo = interface procedure Bar; end; now how can I implement an function ...
ain's user avatar
  • 22.5k
3 votes
1 answer
174 views

How to find variable calling TdwsGlobal.onReadVar/OnWriteVar event

I am dynamically creating variables within a DWSUnit as follows: v := dwsUnit.Variables.Add('c', 'float'); // etc v.OnWriteVar := writeVar; v.OnReadVar := readVar; All variables point to the same ...
Ashley West's user avatar