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

KMPDU.m

Go to the documentation of this file.
  1. KMPDU ;OAK/RAK - CM Tools Utility ;2/17/04 09:47
  1. ;;3.0;KMPD;;Jan 22, 2009;Build 42
  1. ;
  1. GBLCHECK(GLOBAL) ;-- extrinsic function
  1. ;-----------------------------------------------------------------------
  1. ; GLOBAL.. Global name to be checked. Must be either:
  1. ; ^XTMP
  1. ; ^TMP
  1. ; ^UTILITY
  1. ;
  1. ; RESUTL: 0 - Does not pass.
  1. ; 1 - Passes.
  1. ;-----------------------------------------------------------------------
  1. Q:$G(GLOBAL)="" 0
  1. N GBL,I,RESULT
  1. S RESULT=0
  1. S GBL=GLOBAL
  1. ;-- remove '^'.
  1. S GBL=$E(GBL,2,$L(GBL))
  1. ;-- remove '('.
  1. S GBL=$P(GBL,"(")
  1. F I="XTMP","TMP","UTILITY" I GBL=I S RESULT=1 Q
  1. Q RESULT
  1. ;
  1. FMDTI(Y,X) ;-- date/time in internal fileMan format.
  1. ;----------------------------------------------------------------------
  1. ; X - User response ('T', '12/12/94', etc.)
  1. ;
  1. ; Return: Y(0)=InternalFilemanDate
  1. ; Y(1)=ExternalFilemanDate
  1. ;----------------------------------------------------------------------
  1. K Y
  1. I $G(X)']"" S Y(0)="^" Q
  1. N %DT,DATETIME
  1. S %DT="ST" D ^%DT
  1. S DATETIME=$S(Y>0:Y,1:"^")
  1. K Y
  1. ;-- fm internal format.
  1. S Y(0)=DATETIME
  1. ;-- external format.
  1. S Y(1)=$$FMTE^XLFDT(DATETIME)
  1. Q
  1. ;
  1. KILL(RESULT,VARIABLE) ;-- kill variables.
  1. ;-----------------------------------------------------------------------
  1. ; VARIABLE... local or global variable to be killed.
  1. ;
  1. ; This subroutine kills variables (local or global). It should be used
  1. ; mostly to kill global variables that have been set when components
  1. ; have been populated with long lists that were set into temporary
  1. ; globals. If VARIABLE is a global variable, it must be either ^TMP or
  1. ; ^UTILITY to be killed.
  1. ;-----------------------------------------------------------------------
  1. K RESULT S RESULT=""
  1. I $G(VARIABLE)="" S RESULT="[No variable to kill]" Q
  1. I $E(VARIABLE)="^" D Q:RESULT]""
  1. .I '$$GBLCHECK(VARIABLE) D
  1. ..S RESULT="[Can only kill globals ^XTMP, ^TMP or ^UTILITY]"
  1. K @VARIABLE
  1. S RESULT="<"_VARIABLE_" killed>"
  1. Q
  1. ;
  1. TIMEADD(KMPDTM,KMPDADD) ;-- extrinsic function - add time
  1. ;----------------------------------------------------------------------
  1. ; KMPDTM... Current time in dy hr:mn:sc format
  1. ; KMPDTM... Time to add to current time in dy hr:mn:sc format
  1. ;
  1. ; RETURN: total in dy hr:mn:sc format
  1. ;----------------------------------------------------------------------
  1. Q:$G(KMPDTM)="" ""
  1. Q:$G(KMPDADD)="" KMPDTM
  1. N DY,HR,MN,SC
  1. ; current time
  1. S DY(1)=+$P(KMPDTM," ")
  1. S HR(1)=+$P($P(KMPDTM," ",2),":")
  1. S MN(1)=+$P($P(KMPDTM," ",2),":",2)
  1. S SC(1)=+$P($P(KMPDTM," ",2),":",3)
  1. ; time to be added
  1. S DY(2)=+$P(KMPDADD," ")
  1. S HR(2)=+$P($P(KMPDADD," ",2),":")
  1. S MN(2)=+$P($P(KMPDADD," ",2),":",2)
  1. S SC(2)=+$P($P(KMPDADD," ",2),":",3)
  1. ; add seconds
  1. S SC(3)=SC(1)+SC(2)
  1. ; if greater than 59 seconds
  1. I SC(3)>59 S MN(3)=SC(3)\60,SC(3)=SC(3)-60
  1. ; add minutes
  1. S MN(3)=$G(MN(3))+MN(1)+MN(2)
  1. ; if greater than 59 minutes
  1. I MN(3)>59 S HR(3)=MN(3)\60,MN(3)=MN(3)-60
  1. ; add hours
  1. S HR(3)=$G(HR(3))+HR(1)+HR(2)
  1. ; if greater than 23 hours
  1. I HR(3)>23 S DY(3)=HR(3)\24,HR(3)=HR(3)-24
  1. ; days
  1. S DY(3)=$G(DY(3))+DY(1)+DY(2)
  1. ;
  1. Q DY(3)_" "_HR(3)_":"_MN(3)_":"_SC(3)