I'm just mainly wondering if we're all using linear main now vs cycle main. Also added thought on it is isn't '*inlr=*on' a more convenient cleanup than making sure the main cycle closes/unlocks all resources before returning?
Announcement
Collapse
No announcement yet.
Shall we discuss Cycle main and Linear main?
Collapse
X
-
If by cycle main you mean logic cycle, then in my 14 years as an RPG dev I have never written a program that uses the logic cycle. Though I have maintained some older (1980's) programs that did.
During my first 8 years I worked at a company that did not embrace the modern, and had stuck with fixed format instead of free, F-spec IO instead of SQL, and subroutines instead of subprocedures. Which means there was no main procedure, so the program technically loaded with the logic cycle and needed *inlr, even though the cycle was not used for IO.
The company I work for now we use all-free and main procedures for all new programs.
- Likes 1
-
It's true that using cycle main with *INLR=*ON is an easy way to get RPG to close files and unlock data areas even if the Primary-File aspect of the cycle main isn't being used.
You can use CLOSE *ALL to close files and (and UNLOCK *DTAARA to unlock data areas) in a linear main, but you would have to open the files and lock the data areas again when the program is called again.
Code:dcl-f file1; dcl-proc mypgm; if not %open(file1); open file1; endif; ... do stuff ... if cleanup_now; close *all; endif; end-proc;
Code:dcl-f file1; ... do stuff ... if cleanup_now; *inlr = *on; endif;
Comment
Comment