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

ZTFNTM.m

Go to the documentation of this file.
  1. %ZTF ; JSH,GFT,ESS,Hrubovcak ; 14 Jan 98 07:52; Function Library for MSM/Windows NT
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;CHCS TLS_4603; GEN 1; 21-MAY-1999
  1. ;COPYRIGHT 1998 SAIC
  1. ;This version is for MICRONETICS MUMPS.
  1. N %,N,R,L,T
  1. W !,"Available functions in library ^"_$T(+0)
  1. S N=0 F %=2:1 S R=$T(+%) Q:R="" D
  1. .S L=$P(R," "),T=$E(R,$F(R," "),999)
  1. .I L]"",$E(T)=";" W !!,$P(L,"("),?10,"(",$P(L,"(",2,99) S N=1
  1. .I N,$E(T)=";" W !,?5,T Q
  1. Q
  1. ABS(X) ;Returns the absolute value of X.
  1. Q $S(X<0:-X,1:X)
  1. ;
  1. ACTIVE(XJB,XNOD) ;Return true if job number active, false if inactive (logged off)
  1. ; Input: XJB = $J for the process to check
  1. ; XNOD = Node name of the job to check
  1. ;
  1. N XACT,XALLNODS,XCNT,XCURNOD,XRES,XUCI,XVOL
  1. ; If no node name is passed check only the current node
  1. S XNOD=$G(XNOD) Q:'$L(XNOD) $$ACTIVE^%ACTJOB(XJB)
  1. S XCURNOD=$$NODENAME^%ZTF ; get the name of the current node
  1. ; If XNOD is the same as the current node, do not need to job remotely
  1. Q:XCURNOD=XNOD $$ACTIVE^%ACTJOB(XJB)
  1. K ^%ZTSCH("ACTIVE",XJB,0) ; this node is being used to pass the result
  1. ; grab all node names, and production UCI,VOL
  1. S XALLNODS=$$NODES^%ZTOS,XUCI=$G(^%ZOSF("PROD")),XVOL=$P(XUCI,",",2)
  1. S XUCI=$P(XUCI,",")
  1. ; If the node to job to is not a valid node quit false
  1. Q:'$F(XALLNODS,XNOD)!('$L(XUCI))!('$L(XVOL)) ""
  1. ; job the check to prevent the DDP hang if remote node is not up
  1. J ACTIVJ^%ZTF(XJB,XUCI,XVOL,XNOD)
  1. ; now wait for the remote job to finish and pass the result back
  1. S XCNT=0 F D Q:XRES!(XCNT>10)
  1. .L +^%ZTSCH("ACTIVE",XJB,0)
  1. .S XRES=$D(^%ZTSCH("ACTIVE",XJB,0))
  1. .L -^%ZTSCH("ACTIVE",XJB,0)
  1. .S XCNT=XCNT+1 H 1
  1. ; get the result, cleanup and return the result
  1. S XACT=$G(^%ZTSCH("ACTIVE",XJB,0)) K ^%ZTSCH("ACTIVE",XJB,0)
  1. Q XACT
  1. ;
  1. ACTIVJ(XJB,XUCI,XVOL,XNOD) ; Start ACTIV^%ZTF on a remote node
  1. ;
  1. ; Input: XJB = $J for the process to check
  1. ; XUCI = UCI name of the Production UCI
  1. ; XVOL = Volume name of the Production UCI
  1. ; XNOD = Node name of the job to check
  1. ;
  1. ; job the check on the remote node XNOD
  1. N X
  1. S X="ACTERR^%ZTF",@^%ZOSF("TRAP")
  1. X "J ACTIV^%ZTF(XJB)|XUCI,XVOL,XNOD|::10" ;***
  1. Q
  1. ACTIV(XJB) ;Return true if job number active, false if inactive (logged off)
  1. ; pass the result to the remote process in the ^%ZTSCH("ACTIVE" global
  1. ; Input: XJB = $J for the process to check
  1. ;
  1. S ^%ZTSCH("ACTIVE",XJB,0)=$$ACTIVE^%ACTJOB(XJB)
  1. Q
  1. ACTERR ; Trap error if not able to job on remote node
  1. ; assume job being not active
  1. S ^%ZTSCH("ACTIVE",XJB,0)=0
  1. D ET^%ZTF
  1. Q
  1. ;
  1. BREAK(X) ;Enable/Disable Control-C. 1 = Enable, 0 = Disable ;***
  1. X "B $S(X:1,1:0)" Q X
  1. CRC(X,Y) ;
  1. N % X "S %=$ZCRC(X,6,+$G(Y))" Q % ;****** MSM VERSION 4.1
  1. DIR(X) ; return proper directory
  1. ; input: 0 = common user directory (default)
  1. ; 1 = application exe directory
  1. S X=+$G(X),X=$S('X:$G(^%ZOSF("DIR_USER")),X=1:$G(^%ZOSF("DIR_APPL")),1:"")
  1. Q (X_$S($L(X)&($E(X,$L(X))'="\"):"\",1:""))
  1. DIRCHK(X) ; validate directory - return 1 if it exists, else 0
  1. Q '$$TERMINAL^%HOSTCMD("cd "_X_">nul")
  1. DIRE ; external call to DIR function in DVX, this tag is a placeholder
  1. Q
  1. DNCASE(X) ;
  1. Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
  1. DUP(X,N) ;
  1. N % S $P(%,X,N+$L(X)-1/$L(X))=X Q $E(%,1,N)
  1. EDIT(S,N) ;Edit a string based on the value of N
  1. N % I N\256#2 D Q S
  1. .F %=1:2:$L(S,"""") D I %+1=$L(S,"""") S %=%+1 D
  1. ..S $P(S,"""",%)=$$EDIT($P(S,"""",%),N-256)
  1. I N\2#2 S S=$TR(S,$C(9,32))
  1. I N\4#2 S S=$TR(S,$C(0,10,12,13,127))
  1. I N\8#2 F Q:$C(9,32)'[$E(S) Q:S="" S S=$E(S,2,999)
  1. I N\16#2 S S=$TR(S,$C(9)," ") F %=0:0 S %=$F(S," ",%) Q:'% I $E(S,%)=" " S S=$E(S,1,%-1)_$E(S,%+1,999),%=%-1
  1. I N\32#2 S S=$$UPCASE(S)
  1. I N\64#2 S S=$TR(S,"[]","()")
  1. I N\128#2 F %=$L(S):-1:1 Q:$C(9,32)'[$E(S,%) S S=$E(S,1,%-1)
  1. I N#2 F %=1:1:$L(S) S S=$E(S,1,%-1)_$C($A(S,%)#128)_$E(S,%+1,999)
  1. Q S
  1. EOFF(X) ;Turn off echo on device X
  1. X "S:$G(X)="""" X=$I U X:(::::1)" Q "" ;***
  1. EON(X) ;Turn on echo on device X
  1. X "S:$G(X)="""" X=$I U X:(:::::1)" Q "" ;***
  1. ESCAPE(X) ;Enable or disable escape sequence processing
  1. S X=+$G(X) X "U:X $I:(::::8388608) U:'X $I:(:::::8388608)" Q "" ;***
  1. ET ; log error in error trap
  1. G INT^%ZET
  1. ETYPE(X) ;check for certain error conditions
  1. ; input: X = "C" checks for ^C error
  1. ; = "A" checks for memory allocation error
  1. ; output: TRUE if specified error accured, FALSE otherwise
  1. N % S X=$G(X),%=0
  1. I X="C",$ZE["INRPT" S %=1
  1. I X="A",$ZE["PGMOV" S %=1
  1. Q %
  1. FDEL(NAME) ;delete spool file from current directory
  1. N X
  1. S:$L(NAME) X=$$JOBWAIT^%HOSTCMD("delete "_NAME) ; Delete file
  1. Q
  1. FOLLOWS(X,Y) ;Returns truth value 'X follows Y', whether string or numeric
  1. Q $S(+X=X&(+Y=Y):X>Y,1:X]Y)
  1. MAX(X,Y) ;Returns the maximum of X and Y, or of all values in array .X
  1. I $D(Y) Q $S(X>Y:X,1:Y)
  1. N %,%0 S %="X",%0=$G(X) F S %=$Q(@%) Q:%="" I @%>%0 S %0=@%
  1. Q %0
  1. MIN(X,Y) ;Returns the minimum of X and Y, or of all values in array .X
  1. I $D(Y) Q $S(X<Y:X,1:Y)
  1. N %,%0 S %="X",%0=$G(X) F S %=$Q(@%) Q:%="" I @%<%0 S %0=@%
  1. Q %0
  1. NODENAME(E) ;Returns the current node name
  1. Q $$DDPNODES^%MSMOPS(0) ;***
  1. OS() ;Return the current M Version
  1. Q $ZV
  1. ;
  1. POWER(B,E) ;Returns B raised to E
  1. Q B**E ;MDC type A extention
  1. ;
  1. PRG() ;Return 1 if in program mode, 0 if not.
  1. Q $$PRG^%SAICOPS()
  1. ;
  1. PRIINQ(J) ;Return base priority of job X
  1. Q $$PRIINQ^%SAICOPS(J) ;Q $V(20,$J,2)
  1. ;
  1. READ(FLAG,LEN,PROMPT,DEFAULT,TERM,FUNC,X,Y) ; general reader utility
  1. G READ^%ZTF1
  1. RMARGIN(X,I) ;Set the right margin of device I to X, return current setting.
  1. S X=+$G(X),I=$G(I,$I)
  1. Q $$RMARGIN^%SAICOPS(X,I)
  1. ROUSIZE(X) ;Returns the size of a routine X's executable code
  1. Q $$ROUSIZE^%SAICOPS(X)
  1. ROUTEST(X) ;Returns true if routine X exists in current UCI
  1. Q:'$L($G(X)) 0 Q ''$D(^$R(X))
  1. SETPRI(X,J) ;Set job J (defaults to our job) to priority X ;***
  1. Q:'$G(X) "" D:X>4 HIGH^%HL D:X<5 LOW^%HL
  1. Q ""
  1. SETPRIN(JOB) ;Resets the $Principal to the bit-bucket
  1. D SETPRIN^%SAICOPS(JOB,46)
  1. Q
  1. SETXY(X,Y,C) ;Set $X=X, $Y=Y. Unless C is present and true, move cursor.
  1. I '$G(C) I (X<0)!(X>80)!(Y<0)!(Y>24) Q "" ;sir 7661
  1. W:'$G(C) /CUP(Y+1,X+1) S $X=X,$Y=Y Q ""
  1. SQRT(X) ;Return the square-root of X. Returns zero for an illegal X.
  1. N %X,%RES S %X=X D ^%SQRT
  1. Q %RES
  1. TYPAHEAD(X) ;Enable or disable type-ahead on the current device. ;***
  1. ;X=1 Enable, X=0 Disable
  1. X "U:X=1 $I:(::::67108864:33554432) U:X=0 $I:(::::33554432:67108864)"
  1. Q ""
  1. UCI(X) ;Returns UCI, Volume if X is true
  1. Q $P($ZU(0),",",1,1+$G(X)) ;***
  1. UCICHECK(W) ;Returns true if the specified UCI [,volume set] is valid ;***
  1. S $ZT="UCICHK1" N V
  1. S:W?1.2N!(W?1.2N1","1.2N) W=$ZU(+W,$S(W[",":$P(W,",",2),1:$P($ZU(0),",",2)))
  1. I W'?3U,W'?3U1","3U Q 0
  1. S V=$S(W[",":$P(W,",",2),1:$P($ZU(0),",",2)),V=$ZU($P(W,","),V)
  1. Q ''V
  1. UCICHK1 Q 0
  1. ;
  1. UPCASE(X) ;Convert all lowercase letters in X to uppercase
  1. Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  1. ;
  1. XORB(X) ;Return the exclusive-or of all the bytes in X. (Returned as a number, not a single byte.)
  1. N % X "S %=$ZCRC(X,0)" Q %
  1. YN(YN,S) ;Return True for yes, false for no. YN=1 for yes default, 0=no
  1. ;If '^' is entered, it will be returned as the result.
  1. ;If the read times-out DTOUT will be set to 1.
  1. ;S is a flag used by the window processor
  1. N %,%X S S=$G(S) I S N BS S $P(BS,$C(8),80)=$C(8)
  1. YN1 W "? "_$S(YN:"Yes",1:"No")_"// " S %X=$X
  1. R %#5:$S($D(DTIME):DTIME,1:300) S:%="" %=$E("YN",'YN+1) E S DTOUT=1 Q 0
  1. S %=$E(%),%=$S("Yy"[%:1,"Nn"[%:0,%="^":%,1:"?")
  1. I %="?" D G YN1
  1. .W:'S ! W " Answer 'Y', 'N', or '^' to quit" Q:'S
  1. .W $E(BS,1,$X-%X+7+YN)
  1. W:%?1N $E($C(8,8,8,8,8),1,$X-%X)_$P("No ^Yes ","^",%+1)
  1. Q %
  1. ZE(C) ;Return the last error code
  1. ; If C is TRUE, add on explanation
  1. N EC S EC="" I $G(C) S EC=$TR($P($ZE,":",4,5),":") S:EC EC=$P($T(@EC^%ERRCODE),";",2)
  1. Q $ZE_EC
  1. ZH() ; return DSM $ZH or OS equivilent
  1. N H S H=$H,H=$E(H,3,5)*86400+$P(H,",",2)
  1. Q $TR($$ZH^%SAICOPS,"^",",")_","_H
  1. ERR Q $ZE ;ERROR RETURN
  1. ERRNL Q "" ;RETURN NULL STRING ON ERROR
  1. ERR0 Q 0 ;RETURN 0 ON ERROR
  1. Q