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

XBCOUNT.m

Go to the documentation of this file.
  1. XBCOUNT ; IHS/ADC/GTH - COUNT ENTRIES IN FILEMAN FILE ; [ 02/07/97 3:02 PM ]
  1. ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
  1. ;
  1. ; This routine counts primary entries in a FileMan file and
  1. ; corrects the 0th node.
  1. ;
  1. START ;
  1. NEW ANS,CTR,FILE,GBL,L,NXT
  1. W !,"This program counts primary entries for a FileMan file.",!
  1. LOOP ;
  1. W !
  1. S DIC=1,DIC(0)="AE"
  1. D ^DIC
  1. G:Y<0 EOJ
  1. S FILE=+Y
  1. ENT ;
  1. I '$D(^DIC(FILE,0,"GL")) W !!,"DIC file entry invalid or does not exist!",! G LOOP
  1. S GBL=^DIC(FILE,0,"GL")
  1. I '$D(@($S($E(GBL,$L(GBL))="(":$E(GBL,1,$L(GBL)-1),1:$E(GBL,1,$L(GBL)-1)_")"))) W !!,"Bad global!!",! G LOOP
  1. S GBL=GBL_"NXT)"
  1. S (XBHI,NXT,CTR)=0
  1. F L=0:0 S NXT=$O(@(GBL)) Q:NXT'=+NXT S XBHI=NXT,CTR=CTR+1 W:'(CTR#50) "."
  1. W !!,"FileMan file ",FILE," contains ",CTR," entries. High DFN=",XBHI,!
  1. S NXT="",XBX=$O(@(GBL)),XBX=^(0),XBY=$P(XBX,U,4),XBX=$P(XBX,U,3)
  1. W !,"The 0th node says ",XBY,", ",XBX," respectively."
  1. I CTR'=XBY!(XBHI'=XBX) W !," Do you want me to fix it? (Y/N) Y//" R ANS:$G(DTIME,999) I "Y"[$E(ANS) S NXT=0,$P(@(GBL),U,3)=XBHI,$P(^(0),U,4)=CTR W " Done"
  1. G LOOP
  1. ;
  1. EOJ ;
  1. KILL ANS,XBHI,XBX,XBY,CTR,DIC,FILE,GBL,L,NXT
  1. Q
  1. ;