When developing one small project on Delphi using FastScript, we encountered one non-obvious feature.
I hope someone found the feature will be useful and save development time.
ZeosLib was used in the project, and the following structure was written to create an additional layer:
type TMyQuery = TZQuery;
That is, the TMyQuery type was declared as a synonym for TZQuery, and then objects of this type were created in the program.
Everything went well until we started attaching to the FastScript project to remove some of the functionality into blocks that could (and should) be changed without recompiling the project.
')
Inside the scripts implied the use of queries to the database.
Therefore, we, in accordance with the documentation, added our class to it when initializing the script engine:
TFunctions = class(TfsRTTIModule) private ... public constructor Create(AScript: TfsScript); override; end; constructor TFunctions.Create(AScript: TfsScript); begin inherited Create(AScript); with AScript do begin ... AddClass(TMyQuery ,'TDataSet'); ... end; end;
When trying to declare a variable of our type inside the script, we received the following message:
: 10:4: : 'TMyQuery'
At the same time, the other classes imported into the script worked very quietly. And on the line itself:
AddClass(TMyQuery ,'TDataSet');
There were no errors or warnings either at compile time or at run time.
As a result of a couple of hours of searching for a problem, it turned out that FastScript simply cannot correctly import classes, which are described as synonymous with another class.
After changing the type description to:
type TMyQuery = class(TZQuery);
(that is, TMyQuery is no longer a synonym, but a successor of TZQuery)
everything fell into place.
Software version: Delphi 2010, FastScript 4. In other versions and combinations it was not checked.