Determine if only one instance is running: Difference between revisions

No edit summary
Line 686:
note "Got lock!";
unlink $lockpid;</lang>
 
=={{header|Phix}}==
The following is included in the distro as demo\rosetta\Single_instance.exw
<lang Phix>include pGUI.e
 
function copydata_cb(Ihandle /*ih*/, atom v, integer size)
printf(1,"COPYDATA(%s, %d)\n",{peek_string(v), size});
return IUP_DEFAULT;
end function
 
function esc_close(Ihandle /*ih*/, atom c)
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
end function
 
IupOpen("../pGUI/")
IupSetGlobal("SINGLEINSTANCE", "Single") -- (must [partially] match the main window title)
if IupGetGlobal("SINGLEINSTANCE")!="" then
Ihandle dlg = IupDialog(IupVbox({IupLabel("hello")},"MARGIN=200x200"))
IupSetAttribute(dlg,"TITLE","Single Instance")
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
IupSetCallback(dlg, "COPYDATA_CB", Icallback("copydata_cb"));
IupShow(dlg)
IupMainLoop()
end if
IupClose()</lang>
 
=={{header|PicoLisp}}==
7,794

edits