This task is to determine if there is only one instance of an application running. If the program discovers that an instance of it is already running, then it should display a message indicating that it is already running and exit.

PRAGMA INCLUDE <sys/file.h>
OPTION DEVICE O_NONBLOCK
 
OPEN ME$ FOR DEVICE AS me
 
IF flock(me, LOCK_EX | LOCK_NB) <> 0 THEN
    PRINT "I am already running, exiting..."
    END
ENDIF
 
PRINT "Running this program, doing things..."
SLEEP 5000
 
CLOSE DEVICE me