Search code examples
delphipascalscript

PascalScript: how to correctly interpret Unit Importer output?


I'm giving a try to PascalScript, due to its features which could be very interesting in one of the programs I am developing.

Then, after following the awesome Lawrence Barsanti's introduction to PascalScript here, I came to have a look at the RemObjects Unit Importer.

Question is: I understood Lawrence's tutorial is focused on how to use PS without Unit Importer, but since I have rich and sometimes complex forms to work with, having a tool that already does the unit contents mapping could be a bliss.

Just, I can't figure out how to use Unit Importer output: is it a unit file to import into the project? What do I need to do to correctly use it?

Thanks.


Solution

  • The unit importer parses the interface section of a unit and generates an import unit for use by Pascal Script. It makes the Delphi code from the imported unit accessible to the Pascal Script interpreter. Include both units (the original and the generated one) in your project.

    Instead of manually typing all the AddDelphiFunction calls to add your functions to Pascal Script, the importer generates code to call those functions for you. If you have USEIMPORTER defined in your project, then the import unit will automatically register the imported types, functions, and constants with the interpreter. Otherwise, you'll have to call the SIRegister_X function yourself when you have your own interpreter class ready.