Ask Reuben

42r vs 42m

Should fglrun refer to a .42r or .42m file?

What is the difference between a .42r and .42m file?

When executing a Genero application, you can execute a fglrun program-name.42r or a fglrun module-name.42m.  The question gets asked, what file should be used?

The key is to understand the difference between a .42m and a .42r, and how you have coded and built your application.

A .42m (p-code module) is the output from compiling an individual .4gl with fglcomp.  If the .4gl contains a MAIN function, then you can execute fglrun module-name.42m and the MAIN will be treated as the starting point for the Genero application.  The runtime will only go outside the .42m if the .4gl contains an IMPORT FGL.  That is the only way the runtime can possibly know that there are PUBLIC functions outside the current .4gl, there is nothing else that provides that information

A .42r is the output from using fgllink / fgl2p to assemble  p-code modules into a Genero application.  If you examine a .42r using tools such as od, you will see that it is a list of function names and modules names, essentially a dictionary/index that says in what module will you find an individual function. When you go fglrun program.42r, the runtime looks in the .42r to identify in what .42m there is a MAIN.  In then executes that MAIN.  When there is a CALL, the runner looks in the current module for that function to execute, if it is not there it will then look in the .42r for the .42m containing that module and then load that module and execute the function. A .42r does not contain any executables and on its own it cannot do anything, it needs to be distributed with the .42m that were used to build it or any libraries (.42x) it references.

So if you link, you will be executing fglrun program-name.42r and need to deploy both .42m and .42r.  If you do not link but use IMPORT FGL, you will be executing fglrun module-name.42m and only need to deploy .42m, there is no .42r in the solution.