Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PXUALOCK

PXUALOCK.m

Go to the documentation of this file.
  1. PXUALOCK ;ISA/KWP - PCE LOCK/UNLOCK UTILITY;3/29/1999
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**67**;AUG 12, 1996
  1. ;+ LOCK(PXGLOBAL,PXWAIT,PXATT,PXMSG,PXBKG)
  1. ;+ Returns 1 success 0 failure
  1. ;+ PXGLOBAL -Global to be locked
  1. ;+ PXWAIT -seconds for wait, default of 0
  1. ;+ PXATT -Number of attempts to lock before failing
  1. ;+ 0 would mean until canceled,default
  1. ;+ PXMSG -a message to be printed above the wait message
  1. ;+ PXBKG -0 foreground, default
  1. ;+ 1 background, if background max 20 attempts
  1. LOCK(PXGLOBAL,PXWAIT,PXATT,PXMSG,PXBKG) ;
  1. I '$G(PXWAIT) S PXWAIT=0
  1. I '$G(PXATT) S PXATT=0
  1. I '$G(PXBKG) S PXBKG=0
  1. N PXTMP,PXSPACE,PXEXIT,PXRESVAL S (PXEXIT,PXRESVAL)=0
  1. F PXTMP=1:1:$S(PXATT:PXATT,PXBKG&('PXATT):20,1:9999999) D Q:PXEXIT
  1. .L +@PXGLOBAL:PXWAIT
  1. .I S (PXRESVAL,PXEXIT)=1 Q
  1. .I 'PXBKG D
  1. ..I 'PXBKG,PXTMP=1 W:$G(PXMSG)'="" !,PXMSG W !,"Waiting for file access, press ENTER to cancel..."
  1. ..R PXSPACE:0
  1. ..I S PXEXIT=1 Q
  1. ..W "."
  1. Q PXRESVAL
  1. ;+ UNLOCK (PXGLOBAL,PXMSG)
  1. ;+ PXGLOBAL -Global to unlock
  1. ;+ PXMSG -message to be printed when unlocked, if any
  1. UNLOCK(PXGLOBAL,PXMSG) ;
  1. L -@PXGLOBAL
  1. I $G(PXMSG)'="" W !,PXMSG
  1. Q