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

CIAUHFS.m

Go to the documentation of this file.
  1. CIAUHFS ;MSC/IND/DKM - Host IO Support ;04-May-2006 08:19;DKM
  1. ;;1.2;CIA UTILITIES;;Mar 20, 2007
  1. ;;Copyright 2000-2006, Medsphere Systems Corporation
  1. ;=================================================================
  1. ; Capture output to HFS and optionally redirect to global
  1. ; EXEC = Code to execute
  1. ; ROOT = Global root to receive output (or null to leave in HFS)
  1. ; RM = Right margin setting (defaults to 80)
  1. CAPTURE(EXEC,ROOT,RM) ;EP
  1. N UFN,HNDL,TMP,IOM,IOSL,IOST,IOF,IOT,IOS,$ET
  1. S $ET="",UFN=$$UFN^CIAU,TMP=$$DEFDIR^CIAUOS,HNDL="CIAUHFS",@$$TRAP^CIAUOS("ERR^CIAUHFS")
  1. S:$L($G(ROOT)) ROOT=$NA(@ROOT)
  1. D OPEN^%ZISH(HNDL,TMP,UFN,"W")
  1. D:'POP IOVAR(.RM),EXEC,HFSCLOSE(HNDL,UFN)
  1. Q:$Q TMP_UFN
  1. Q
  1. EXEC X EXEC
  1. Q
  1. ; Error trap
  1. ERR D @^%ZOSF("ERRTN"),HFSCLOSE(HNDL,UFN,1)
  1. Q:$Q ""
  1. Q
  1. ; Setup IO variables based on IO Device
  1. IOVAR(XIOM,XIO,XIOSL,XIOST,XIOF,XIOT) ;
  1. N X
  1. S ION=$G(XIO,"CIAU HFS DEVICE"),IOS=+$O(^%ZIS(1,"B",ION,0)),IOM=80,IOSL=62,IOST=$G(XIOST,"P-OTHER"),IOF=$G(XIOF,""""""),IOT=$G(XIOT,"HFS")
  1. S:$D(^%ZIS(1,IOS,0)) IOST(0)=+$G(^("SUBTYPE")),IOT=$G(^("TYPE"),IOT),IOST=$P($G(^%ZIS(2,IOST(0),0),IOST),U)
  1. S X=$O(^%ZIS(2,"B",IOST,0))
  1. S:X IOST(0)=X,X=$G(^%ZIS(2,X,1)),IOM=$P(X,U),IOF=$P(X,U,2),IOSL=$P(X,U,3)
  1. S:$G(XIOM) IOM=XIOM
  1. S:$G(XIOSL) IOSL=XIOSL
  1. U IO
  1. Q
  1. ; Move HFS data to global (if ROOT specified) and cleanup
  1. HFSCLOSE(HNDL,UFN,BAD) ;
  1. N DEL
  1. D GETDEV^%ZISUTL(HNDL)
  1. I IOT="HFS" D
  1. .D CLOSE^%ZISH(HNDL)
  1. E D RMDEV^%ZISUTL(HNDL)
  1. Q:'$L($G(ROOT))
  1. K @ROOT
  1. I '$G(BAD),$$FTG^%ZISH($$DEFDIR^CIAUOS,UFN,$NA(@ROOT@(1)),$QL(ROOT)+1) D STRIP
  1. S DEL(UFN)=""
  1. I $$DEL^%ZISH($$DEFDIR^CIAUOS,"DEL")
  1. Q
  1. ; Strip off control chars and remove leading/trailing blank lines
  1. STRIP N I,J,K,X
  1. S (I,J)=0
  1. F S I=$O(@ROOT@(I)) Q:'I S X=@ROOT@(I) D S @ROOT@(I)=X
  1. .I X[$C(8),$L(X,$C(8))=$L(X,$C(95)) S X=$TR(X,$C(7,8,12,95))
  1. .E S X=$TR(X,$C(7,8,12))
  1. .S:$L(X) J=I,K=$G(K,J)
  1. I $D(K) F S I=$O(@ROOT@(I)) Q:I=K K @ROOT@(I)
  1. F S J=$O(@ROOT@(J)) Q:'J K @ROOT@(J)
  1. Q