Recent

Author Topic: Looking for recommendation --> Script-Engine  (Read 2323 times)

Zvoni

  • Hero Member
  • *****
  • Posts: 3135
Looking for recommendation --> Script-Engine
« on: March 08, 2022, 11:29:03 am »
Hi Folks,

I'm currently doing preliminary research for a project of mine.

Laz/FPC: Laz2.2.0/FPC3.2.2-32Bit on Win10 64-Bit

Target (as of now): Win 32-Bit

I'm tasked to write a, let's call it, a "central" Report-Tool for the company i work for.
A local DB (SQLite) will be used as storage.

Now, as we all know, no two reports are similiar (and i'm not talking about those Excel-Reports).
So basically, the db will contain all necessary SQL to pull the data, but now my problem starts: How to display?

Of course, i could create/design a Form (with underlying code) for each report, and recompile the tool, but that's not really....errr.....efficient (?)

So i stumbled across this thread: https://forum.lazarus.freepascal.org/index.php?topic=51296.0
which is basically about how to read a *.lfm file
Nice, so i could use that to dynamically create a Form, place button there, an Edit over there, and a ListBox in the middle.

But: How to tell the Button to do something? It would need an OnClick-handler never mind code which to execute

Then my eye fell on the "PascalScript"-component.
Well, this certainly looks like that what i need.

Anyone get any experience? or how to?
Yes, i found the Wiki-page for it, but that's basically just an advert.
Another thing i found in the sources (in the readme):
Quote
This copy only provides the files required by the Lazarus IDE (edior macros).
with a link to https://github.com/remobjects/pascalscript/

But that looks like greek to me.

What i'm basically looking for resp. what i was thinking about aproaching it:
store the lfm in the database
store necessary (PascalScript?) code in the Database
The report is called
pull the lfm from the db
create the form acc. to lfm
pull the code (!) from db
Run

Thought? Ideas? Recommendations?

Sidenote: I've also seen Python4Laz, but i've never written a single line in Python (or JS for that matter, so that one is out, too), and i really don't have the time to bascially learn a new language
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

AlexTP

  • Hero Member
  • *****
  • Posts: 2615
    • UVviewsoft
Re: Looking for recommendation --> Script-Engine
« Reply #1 on: March 08, 2022, 11:47:39 am »
My text editor is scripted by Python. It can get any code from external files *.py, and run it via Python4Delphi engine in pascal. It has python in-memory 'module'; This module is API to python files.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: Looking for recommendation --> Script-Engine
« Reply #2 on: March 08, 2022, 12:16:44 pm »
There is also InstantFPC.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Looking for recommendation --> Script-Engine
« Reply #3 on: March 08, 2022, 02:15:35 pm »
Thinking about how I would approach this:

IIRC the jedi jvcl has some code to instantiate forms from d/lfms. 

All components in the lfm should have some unique .tag and assigned a general handler per component type.  That tag is the connect between the component handler and the script fragment.

Whatever you use to create the forms for the DB must take care of this (the tagging, the generic component handler name) etc.


hrayon

  • Full Member
  • ***
  • Posts: 118
Re: Looking for recommendation --> Script-Engine
« Reply #4 on: March 08, 2022, 03:15:22 pm »
Why reinvent the wheel?

https://www.fast-report.com/pt/product/fast-report-vcl/

It's lazarus compatible.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: Looking for recommendation --> Script-Engine
« Reply #5 on: March 08, 2022, 03:37:41 pm »
You might want to take a look at this:
https://sourceforge.net/projects/vfdesigner/
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Looking for recommendation --> Script-Engine
« Reply #6 on: March 09, 2022, 06:17:37 am »
As far as I remember there are two scripting engines that come preinstalled with lazarus. RemObjects Pascal script and an extendable math interpreter that comes with the FPC. any one will do what you need no one provides the visual part ready for you to use you will have to do it manually or buy components that can do this for you eg TMS Diagram components, I think they support lazarus and they are relatively inexpensive. 

 

TinyPortal © 2005-2018