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

ENARGR.m

Go to the documentation of this file.
  1. ENARGR ;(WIRMFO)/JED,SAB-RECALL ARCHIVED DATA ;2.14.97
  1. ;;7.0;ENGINEERING;**40**;Aug 17, 1993
  1. Q
  1. R ; Recall Global from archive media
  1. ; called from ENAR1
  1. ; input
  1. ; ENGBL - global subscript in ^ENAR to be recalled (e.g. 6919.1)
  1. ; ENRT - number associated with type of archive (e.g. 1 for W.O.)
  1. ; ENERR - error message text (should be 0 for no error)
  1. ; output
  1. ; ENDA - ien of ENG ARCHIVE LOG entry
  1. ; ENERR - error message text or 0 when no error
  1. ;
  1. S ENFN=$S(ENRT=1:"WO ARCHIVE",ENRT=2:"2162 ACCIDENT ARCHIVE",ENRT=3:"EQUIPMENT INV. ARCHIVE",ENRT=4:"PROJECT ARCHIVE",ENRT=5:"CONTROL POINT ARCHIVE")
  1. ; select and open archive media
  1. S ENHFSM="R",ENHFSIO="" D ARDEV^ENARGO I ENERR'=0 G OUT
  1. I IOT="MT" D MTSETUP^ENARGO I ENERR'=0 G CLOUT
  1. I IOT="MT" D MTCHECK^ENARGO I ENERR'=0 G CLOUT
  1. ; get header info from archive media
  1. U IO R ENHD(1):15,ENHD(2):15,ENHD(3):15,ENHD(4):15
  1. D CLOSE^ENARGO
  1. I ENHD(3)'=("^ENAR("_ENGBL_",-1)") D G OUT
  1. . W $C(7),!!,"Expected: ","^ENAR("_ENGBL_",-1)"
  1. . W !,"Found: ",ENHD(3)
  1. . W !,"Sorry, this media is unacceptable!"
  1. . W !,"Press <RETURN> to continue" R ENR:DTIME
  1. . S ENERR="BOGUS MEDIA"
  1. ; confirm
  1. S ENDA=+$P(ENHD(4),",",4) D ID^ENAR2 I ENERR'=0 G OUT
  1. W !!!!,"Media written on: ",ENHD(1),!,"with header: ",ENHD(2),!
  1. S DIR(0)="Y",DIR("A")="Is this the media you want",DIR("B")="YES"
  1. D ^DIR K DIR I 'Y S ENERR="RECALL RECORDS ABORT" G OUT
  1. ; ask type of recall
  1. S DIR(0)="SB^A:ALL RECORDS;O:ONE RECORD"
  1. S DIR("A")="Select type of recall to perform",DIR("B")="ALL"
  1. S DIR("?",1)="ALL RECORDS - Recall all records from archive media."
  1. S DIR("?",2)="ONE RECORD - Search entire archive for a specific record"
  1. S DIR("?",3)=" and recall it if found."
  1. S DIR("?",4)=" "
  1. S DIR("?")="Enter ALL or ONE"
  1. D ^DIR K DIR I $D(DIRUT) S ENERR="RECALL TYPE NOT SPECIFIED" G OUT
  1. S ENRCLT=Y
  1. ;
  1. ; select and open archive media
  1. W !,"Please wait while I reopen the archive device."
  1. S IOP=ENION,ENHFSM="R" D ARDEV^ENARGO I ENERR'=0 G OUT
  1. I IOT="MT" D MTCHECK^ENARGO I ENERR'=0 G CLOUT
  1. U IO R ENX:15,ENX(1):15 U IO(0) ; skip first 2 header lines
  1. I ENRCLT="A" D RALL I ENERR'=0 G CLOUT
  1. I ENRCLT="O" D RONE I ENERR'=0 G CLOUT
  1. D CLOSE^ENARGO
  1. W !,"Elapsed time: ",$J($P($H,",",2)-ENSTART/60,6,2)," minutes."
  1. ;
  1. RINIT ; initialize data dictionary
  1. ; save variables
  1. F ENX="ENDA","ENERR","ENGBL","ENRT" S ^TMP("ENAR",$J,ENX)=@ENX
  1. ; perform init
  1. I $D(^ENAR(ENGBL,-1,"INIT")) X ^("INIT")
  1. ; restore variables
  1. F ENX="ENDA","ENERR","ENGBL","ENRT" S @ENX=^TMP("ENAR",$J,ENX)
  1. K ^TMP("ENAR",$J)
  1. ; check result
  1. I $D(DIFQ) D G:ENERR'=0 OUT G RINIT
  1. . W $C(7),!,"But your file is not initialized properly",!
  1. . S DIR(0)="Y",DIR("A")="Do you want to re-try",DIR("B")="YES"
  1. . S DIR("?",1)="If you answer no the "_ENFN_" file will be cleaned out"
  1. . S DIR("?",2)=" "
  1. . S DIR("?")="Enter Y or N"
  1. . D ^DIR K DIR I 'Y D GS^ENAR1,D2^ENAR1 S ENERR="ARCHIVE RECALL ABORT"
  1. ;
  1. K ^ENAR(ENGBL,-1)
  1. W !!,"O.K. Archive file is ready"
  1. G OUT
  1. ;
  1. RALL ; recall all records
  1. W !,"Now fetching global"
  1. U IO
  1. S ENJ=0,ENSTART=$P($H,",",2)
  1. F R ENX:15,ENX(1):15 Q:ENX="**EOF**"!'$T D:ENX'["LOCK"
  1. . S @ENX=ENX(1),ENJ=ENJ+1
  1. . I '(ENJ#50) U IO(0) W "." U IO
  1. U IO(0)
  1. I ENX="**EOF**" W !!,"The global is now on the system disk"
  1. E S ENERR="COULD NOT RECALL ALL RECORDS"
  1. Q
  1. ;
  1. RONE ; recall one record
  1. W !,"Enter the exact "_ENFN_" record name. Remember to include"
  1. W !,"your station number as a pre-fix! (e.g. 688-B970121-001)",!
  1. S DIR(0)="F",DIR("A")="Exact "_ENFN_" record name"
  1. D ^DIR K DIR I $D(DIRUT) S ENERR="SINGLE RECORD UNSPECIFIED" Q
  1. S ENR=Y
  1. ;
  1. ; read media and recall data dictionary nodes, stop if record located
  1. S ENSTART=$P($H,",",2)
  1. U IO
  1. S ENJ=0
  1. F R ENX:15,ENX(1):15 Q:$P(ENX(1),U,1)=ENR!(ENX="**EOF**")!'$T D
  1. . S:$P(ENX,",",2)="-1" @ENX=ENX(1) ; only store data dictionary stuff
  1. . S ENJ=ENJ+1
  1. . I '(ENJ#50) U IO(0) W "." U IO
  1. U IO(0)
  1. ;
  1. I $P(ENX(1),U,1)'=ENR D Q:ENERR'=0 G RONE
  1. . ; recall didn't stop at desired record
  1. . K ^ENAR(ENGBL,-1)
  1. . W !,"Sorry, that record doesn't appear to be on this archive."
  1. . S DIR(0)="Y",DIR("A")="Try another record",DIR("B")="NO"
  1. . D ^DIR K DIR I 'Y S ENERR="DIDN'T FIND SINGLE RECORD" Q
  1. . ; rewind (or close and reopen) device for retry
  1. . W !,"Please wait while I rewind (or reopen) the archive device."
  1. . S Y=$S("^MT^HFS^SDP^"[(U_IOT_U):$$REWIND^%ZIS(IO,IOT,IOPAR),1:0)
  1. . I 'Y D CLOSE^ENARGO S IOP=ENION,ENHFSM="R" D ARDEV^ENARGO Q:ENERR'=0
  1. . I IOT="MT" D MTCHECK^ENARGO Q:ENERR'=0
  1. . U IO R ENX:15,ENX(1):15 ; skip first 2 header lines
  1. . U IO(0)
  1. ;
  1. ; recall stopped at desired record
  1. W !!,"Found record ",$P(ENX(1),U,1),!
  1. S ENJ=$P(ENX,",",2)
  1. ; save data
  1. S @ENX=ENX(1)
  1. S ^ENAR(ENGBL,0)=ENFN_U_ENGBL_U_ENJ_"^1"
  1. S ^ENAR(ENGBL,"B",$P(ENX(1),U,1),ENJ)=""
  1. ; retrieve remaining nodes of record
  1. U IO
  1. F R ENX:15,ENX(1):15 Q:$P(ENX,",",2)'=ENJ!(ENX="**EOF**")!'$T D
  1. . S @ENX=ENX(1)
  1. Q
  1. ;
  1. CLOUT ; Close Archive Media and Exit
  1. D CLOSE^ENARGO
  1. OUT ; Exit
  1. K ENA,ENBOT,ENEOT,ENFN,ENHD,ENHFSIO,ENHFSM,ENION,ENJ,ENMTERR
  1. K ENONLINE,ENR,ENRCLT,ENREW,ENSTART,ENWPROT,ENX
  1. K DIROUT,DIRUT,DTOUT,DUOUT,I,X,Y
  1. Q
  1. ;
  1. ;ENARGR