Skip to main content

Posts

Showing posts with the label Generating and running code RUNTIME.

Generating and running code RUNTIME.

How to create, compile and run code at RUNTIME. In some situations the need for making "generic" code arises. This is a little example that generates, compiles and runs code to delete the contents of table PBACustGroup. The code is made as a job, but transforming this code into a method on a class, and calling this method with parameters that allows it to identify the table, suddenly makes us able to delete several selected tables with very little code. It also allows for USER CONTROLLED actions, for example letting the user build a liste of tables he would like to delete, and then calling the code for each of these tables. static void TestGenericCode(Args _args) {     XppCompiler XppCompiler;     str code;     str tableName = "PBACustGroup"; // Here we define the name of the table ;     // A compile object is created     XppCompiler = new XppCompiler();     // Here th...