Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

9.9.2 Preventing Multi-execution of the application

The module level ExecuteInDuplicate property controls the behavior of a PowerCOBOL .exe file when a user attempts to launch it for execution a second time. There are three values available for this property. They are listed with their related results below:

Note that PowerCOBOL treats multiple execution of an application in the same path separately. Therefore, PowerCOBOL recognizes an application that resides in another folder as a different application even if they were built from the same project file. For example, the following are different applications:

The Execute in Duplicate property is effective when the FileType property of module is "0-Execute Module". Note that, the ExecuteInDuplicate property should be used to prevent multiple access to a file. In cases where the same data file may be accessed concurrently from multiple instances of the same application (or from different applications), you need to use record file and/or record locking. For example, to open a file for exclusive use and lock it from other currently running applications:

FILE-CONTROL

 SELECT LOCKFILE
 ASSIGN TO LF
 FILE STATUS IS LF-STATUS
 LOCK MODE IS EXCLUSIVE.

FILE

 FD  LOCKFILE GLOBAL.
 01  OAREA  PIC X.

WORKING-STORAGE

 01 LF-STATUS  PIC X(2) GLOBAL.

OPENED Event

 ENVIRONMENT	DIVISION.
 DATA	DIVISION.
 WORKING-STORAGE	SECTION.
 PROCEDURE	DIVISION.
 	OPEN OUTPUT LOCKFILE WITH LOCK
 	IF LS-STATUS NOT = "00" THEN
 	  INVOKE POW-SELF "DisplayMessage" USING "OPEN ERROR!"
 	  INVOKE POW-SELF "Deactivate"
 	END-IF.