XBHFMAN1 ; IHS/ADC/GTH - HELP FRAME MANUAL (2/2) ; [ 02/07/97 3:02 PM ]
;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
;
; ----- Print Title and Preface page.
;
;
S X=XBNS_"HFMN"
X ^%ZOSF("TEST")
E G MAIN
S XBNOHDR=1
NEW A,B
F A="TITLE","PREFACE" Q:$D(DIRUT) D ^DIWW,TOF F B=1:1 S X=$T(@A+B^@(XBNS_"UMAN")) Q:$L($P(X,";",1))>1 D PR($P(X,";",3)) Q:$D(DIRUT)
;
I $D(DIRUT) G HATOUT
D ^DIWW
;
MAIN ; ----- $ORDER thru the list of OPTIONS, and print them.
S (XBNAME,XBNOHDR)=0
F S XBNAME=$O(^TMP("XBHFMAN",$J,XBNAME)) Q:'XBNAME D MAKEHDRS,TOF Q:$D(DIRUT) D HDR(XBNAME),DESC(+^TMP("XBHFMAN",$J,XBNAME)),HF($P($G(^DIC(19,+^TMP("XBHFMAN",$J,XBNAME),0)),U,7)),^DIWW
I $D(DIRUT) G HATOUT
;
INDEX ; ----- Print the index.
S XBHDR="Index"
D TOF
I $D(DIRUT) G HATOUT
W !!!
S X="|NOWRAP||SETTAB(""C"")||TAB|INDEX"
D ^DIWP,^DIWW
W !!!
D CONT("INDEX^^"_XBPG)
S (XB,XBCONT)="",$P(XBCONT,".",81)=""
F S XB=$O(^TMP("XBHFMAN-INDEX",$J,XB)) Q:XB="" S X="" D Q:$D(DIRUT)
.F XBX=0:0 S XBX=$O(^TMP("XBHFMAN-INDEX",$J,XB,XBX)) S X=X_XBX_"," I '$O(^(XBX)) D Q
..S X=XB_"..."_$E(XBCONT,1,DIWR-DIWL-$L(XB)-3-$L(X))_$E(X,1,$L(X)-1)
..S XBSAVX=X
..F S X=$E(XBSAVX,1,DIWR-DIWL),XBSAVX=$E(XBSAVX,DIWR-DIWL+1,$L(XBSAVX)) Q:'$L(X) D TOF:$Y>XBBM Q:$D(DIRUT) D ^DIWP
..Q
.Q
I $D(DIRUT) G HATOUT
D ^DIWW,RTRN^XBHFMAN
I $D(DIRUT) G HATOUT
;
CONTENTS ; ----- Print the table of Contents.
S XBNOHDR=1
W @IOF,!!!!!
S X="|SETTAB(""C"")||TAB|CONTENTS"
D ^DIWP,^DIWW
W !!
S XB=0
F S XB=$O(^TMP("XBHFMAN-CONTENTS",$J,XB)) Q:'+XB S X=^(XB),X=$P(X,U)_" "_$P(X,U,2)_$E(XBCONT,1,DIWR-DIWL-$L(X)+1)_$P(X,U,3) D TOF:$Y>XBBM Q:$D(DIRUT) D ^DIWP
I $D(DIRUT) G HATOUT
D ^DIWW,RTRN^XBHFMAN
I $D(DIRUT) G HATOUT
END ;EP - Paginate, close, kill, quit.
W @IOF
HATOUT ;
D ^%ZISC
KILL ^TMP("XBHFMAN",$J),XB,XBBM,XBCHAP,XBCONT,XBODD,XBHDR,XBIEN,XBPARA,XBPG,XBROOT,XBTITL,XBTM,XBX,XBY,DIC,DIWF,DIWL,DIWR
Q
;
PR(X) ;EP - Process one line of text.
NEW A,B,I,N,Y
I X="|TOP|" D TOF Q
D INDX(X),^DIWP,TOF:$Y>XBBM
Q
;
INDX(X) ; ----- Parse/capitalize one line of text. Check for indexed words.
Q:'$D(XBPG)
NEW Y,Z
S X=$TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
S X=$TR(X,"~`!@#$%^&*()_-+=|\{[}]:;""""'<,>.?/"," ")
X XBSTRIP
F S %=$F(X," ") Q:'% S X=$E(X,1,%-2)_$E(X,%,$L(X))
F %=1:1 S Y=$P(X," ",%) Q:Y="" I $D(^TMP("XBHFMAN-I",$J,Y)) S ^TMP("XBHFMAN-INDEX",$J,Y,XBPG)=""
Q
;
HDR(XB) ; ----- Print a chapter heading.
S %=$P(^TMP("XBHFMAN",$J,XB),U,2),XB=%_U_$P($G(^DIC(19,+^TMP("XBHFMAN",$J,XB),0)),U,2)
F X="|SETTAB(""C"")||TAB|Chapter "_$P(XB,U),"|SETTAB(""C"")||TAB|"_$P(XB,U,2) D ^DIWP
W !!
D CONT($P(XB,U)_U_$P(XB,U,2)_U_XBPG)
Q
;
TOF ;EP ----- Move to bottom of page, print footer, paginate, print header.
I XBNOHDR D RTRN^XBHFMAN Q:$D(DIRUT) W @IOF Q
F Q:$Y>XBBM W !
I XBPG W !?(DIWL-1),XBDASH,!,?$S(XBODD:DIWR-$L(XBTITL),1:DIWL-1),XBTITL
D RTRN^XBHFMAN
I $D(DIRUT) Q
W @IOF
S XBPG=XBPG+1,XBODD=XBPG#2
F Q:$Y=(XBTM-2) W !
W ?$S(XBODD:DIWR-$L("Page "_XBPG),1:DIWL-1),"Page ",XBPG
I '(XBHDR="Index") W !?DIWL-1,$S(XBODD:XBHDRO,1:XBHDRE)
W !?(DIWL-1),XBDASH,!!
Q
;
MAKEHDRS ; ----- Make headers for odd and even pages.
S (XBHDRE,XBHDRO)=$P($G(^DIC(19,+^TMP("XBHFMAN",$J,XBNAME),0)),U,2)
S XBCHAP=$P(^TMP("XBHFMAN",$J,XBNAME),U,2)
F %=1:1 I '$P(XBCHAP,".",%) S XBCHAP=$P(XBCHAP,".",1,%-1) Q
S XBHDRO=XBHDRO_$J("",DIWR-DIWL-$L(XBHDRO)-$L("Chapter "_XBCHAP)+1)_"Chapter "_XBCHAP
S XBHDRE="Chapter "_XBCHAP_$J("",DIWR-DIWL-$L(XBHDRE)-$L("Chapter "_XBCHAP)+1)_XBHDRE
Q
;
CONT(X) ; ----- Add chapter number, title, and page number to list.
S XBCONT=XBCONT+1,^TMP("XBHFMAN-CONTENTS",$J,XBCONT)=X
Q
;
DESC(A) ; ----- Print descriptions of the OPTIONs as the first of the chapter.
NEW B,I,N,Y
I '$D(^DIC(19,A,1)) D PR("<NO DESCRIPTION>") Q
S B=0
F S B=$O(^DIC(19,A,1,B)) Q:'B D PR(^(B,0)) Q:$D(DIRUT)
Q
;
HF(A) ; ----- Print the HELP FRAME text.
I 'A D PR("<NO HELP FRAME>") Q
I '$D(^DIC(9.2,A,1)) D PR("<NO HELP FRAME TEXT>") Q
NEW B,I,N,Y
S B=0
F S B=$O(^DIC(9.2,A,1,B)) Q:'B D PR(^(B,0)) Q:$D(DIRUT)
; ----- Print any tied HELP FRAMEs.
I $O(^DIC(9.2,A,2,0)) S B=0 F S B=$O(^DIC(9.2,A,2,B)) Q:'B D HF($P($G(^(B,0)),U,2)) Q:$D(DIRUT)
Q
;
XBHFMAN1 ; IHS/ADC/GTH - HELP FRAME MANUAL (2/2) ; [ 02/07/97 3:02 PM ]
+1 ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
+2 ;
+3 ; ----- Print Title and Preface page.
+4 ;
+5 ;
+6 SET X=XBNS_"HFMN"
+7 XECUTE ^%ZOSF("TEST")
+8 IF '$TEST
GOTO MAIN
+9 SET XBNOHDR=1
+10 NEW A,B
+11 FOR A="TITLE","PREFACE"
IF $DATA(DIRUT)
QUIT
DO ^DIWW
DO TOF
FOR B=1:1
SET X=$TEXT(@A+B^@(XBNS_"UMAN"))
IF $LENGTH($PIECE(X,";",1))>1
QUIT
DO PR($PIECE(X,";",3))
IF $DATA(DIRUT)
QUIT
+12 ;
+13 IF $DATA(DIRUT)
GOTO HATOUT
+14 DO ^DIWW
+15 ;
MAIN ; ----- $ORDER thru the list of OPTIONS, and print them.
+1 SET (XBNAME,XBNOHDR)=0
+2 FOR
SET XBNAME=$ORDER(^TMP("XBHFMAN",$JOB,XBNAME))
IF 'XBNAME
QUIT
DO MAKEHDRS
DO TOF
IF $DATA(DIRUT)
QUIT
DO HDR(XBNAME)
DO DESC(+^TMP("XBHFMAN",$JOB,XBNAME))
DO HF($PIECE($GET(^DIC(19,+^TMP("XBHFMAN",$JOB,XBNAME),0)),U,7))
DO ^DIWW
+3 IF $DATA(DIRUT)
GOTO HATOUT
+4 ;
INDEX ; ----- Print the index.
+1 SET XBHDR="Index"
+2 DO TOF
+3 IF $DATA(DIRUT)
GOTO HATOUT
+4 WRITE !!!
+5 SET X="|NOWRAP||SETTAB(""C"")||TAB|INDEX"
+6 DO ^DIWP
DO ^DIWW
+7 WRITE !!!
+8 DO CONT("INDEX^^"_XBPG)
+9 SET (XB,XBCONT)=""
SET $PIECE(XBCONT,".",81)=""
+10 FOR
SET XB=$ORDER(^TMP("XBHFMAN-INDEX",$JOB,XB))
IF XB=""
QUIT
SET X=""
Begin DoDot:1
+11 FOR XBX=0:0
SET XBX=$ORDER(^TMP("XBHFMAN-INDEX",$JOB,XB,XBX))
SET X=X_XBX_","
IF '$ORDER(^(XBX))
Begin DoDot:2
+12 SET X=XB_"..."_$EXTRACT(XBCONT,1,DIWR-DIWL-$LENGTH(XB)-3-$LENGTH(X))_$EXTRACT(X,1,$LENGTH(X)-1)
+13 SET XBSAVX=X
+14 FOR
SET X=$EXTRACT(XBSAVX,1,DIWR-DIWL)
SET XBSAVX=$EXTRACT(XBSAVX,DIWR-DIWL+1,$LENGTH(XBSAVX))
IF '$LENGTH(X)
QUIT
IF $Y>XBBM
DO TOF
IF $DATA(DIRUT)
QUIT
DO ^DIWP
+15 QUIT
End DoDot:2
QUIT
+16 QUIT
End DoDot:1
IF $DATA(DIRUT)
QUIT
+17 IF $DATA(DIRUT)
GOTO HATOUT
+18 DO ^DIWW
DO RTRN^XBHFMAN
+19 IF $DATA(DIRUT)
GOTO HATOUT
+20 ;
CONTENTS ; ----- Print the table of Contents.
+1 SET XBNOHDR=1
+2 WRITE @IOF,!!!!!
+3 SET X="|SETTAB(""C"")||TAB|CONTENTS"
+4 DO ^DIWP
DO ^DIWW
+5 WRITE !!
+6 SET XB=0
+7 FOR
SET XB=$ORDER(^TMP("XBHFMAN-CONTENTS",$JOB,XB))
IF '+XB
QUIT
SET X=^(XB)
SET X=$PIECE(X,U)_" "_$PIECE(X,U,2)_$EXTRACT(XBCONT,1,DIWR-DIWL-$LENGTH(X)+1)_$PIECE(X,U,3)
IF $Y>XBBM
DO TOF
IF $DATA(DIRUT)
QUIT
DO ^DIWP
+8 IF $DATA(DIRUT)
GOTO HATOUT
+9 DO ^DIWW
DO RTRN^XBHFMAN
+10 IF $DATA(DIRUT)
GOTO HATOUT
END ;EP - Paginate, close, kill, quit.
+1 WRITE @IOF
HATOUT ;
+1 DO ^%ZISC
+2 KILL ^TMP("XBHFMAN",$JOB),XB,XBBM,XBCHAP,XBCONT,XBODD,XBHDR,XBIEN,XBPARA,XBPG,XBROOT,XBTITL,XBTM,XBX,XBY,DIC,DIWF,DIWL,DIWR
+3 QUIT
+4 ;
PR(X) ;EP - Process one line of text.
+1 NEW A,B,I,N,Y
+2 IF X="|TOP|"
DO TOF
QUIT
+3 DO INDX(X)
DO ^DIWP
IF $Y>XBBM
DO TOF
+4 QUIT
+5 ;
INDX(X) ; ----- Parse/capitalize one line of text. Check for indexed words.
+1 IF '$DATA(XBPG)
QUIT
+2 NEW Y,Z
+3 SET X=$TRANSLATE(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+4 SET X=$TRANSLATE(X,"~`!@#$%^&*()_-+=|\{[}]:;""""'<,>.?/"," ")
+5 XECUTE XBSTRIP
+6 FOR
SET %=$FIND(X," ")
IF '%
QUIT
SET X=$EXTRACT(X,1,%-2)_$EXTRACT(X,%,$LENGTH(X))
+7 FOR %=1:1
SET Y=$PIECE(X," ",%)
IF Y=""
QUIT
IF $DATA(^TMP("XBHFMAN-I",$JOB,Y))
SET ^TMP("XBHFMAN-INDEX",$JOB,Y,XBPG)=""
+8 QUIT
+9 ;
HDR(XB) ; ----- Print a chapter heading.
+1 SET %=$PIECE(^TMP("XBHFMAN",$JOB,XB),U,2)
SET XB=%_U_$PIECE($GET(^DIC(19,+^TMP("XBHFMAN",$JOB,XB),0)),U,2)
+2 FOR X="|SETTAB(""C"")||TAB|Chapter "_$PIECE(XB,U),"|SETTAB(""C"")||TAB|"_$PIECE(XB,U,2)
DO ^DIWP
+3 WRITE !!
+4 DO CONT($PIECE(XB,U)_U_$PIECE(XB,U,2)_U_XBPG)
+5 QUIT
+6 ;
TOF ;EP ----- Move to bottom of page, print footer, paginate, print header.
+1 IF XBNOHDR
DO RTRN^XBHFMAN
IF $DATA(DIRUT)
QUIT
WRITE @IOF
QUIT
+2 FOR
IF $Y>XBBM
QUIT
WRITE !
+3 IF XBPG
WRITE !?(DIWL-1),XBDASH,!,?$SELECT(XBODD:DIWR-$LENGTH(XBTITL),1:DIWL-1),XBTITL
+4 DO RTRN^XBHFMAN
+5 IF $DATA(DIRUT)
QUIT
+6 WRITE @IOF
+7 SET XBPG=XBPG+1
SET XBODD=XBPG#2
+8 FOR
IF $Y=(XBTM-2)
QUIT
WRITE !
+9 WRITE ?$SELECT(XBODD:DIWR-$LENGTH("Page "_XBPG),1:DIWL-1),"Page ",XBPG
+10 IF '(XBHDR="Index")
WRITE !?DIWL-1,$SELECT(XBODD:XBHDRO,1:XBHDRE)
+11 WRITE !?(DIWL-1),XBDASH,!!
+12 QUIT
+13 ;
MAKEHDRS ; ----- Make headers for odd and even pages.
+1 SET (XBHDRE,XBHDRO)=$PIECE($GET(^DIC(19,+^TMP("XBHFMAN",$JOB,XBNAME),0)),U,2)
+2 SET XBCHAP=$PIECE(^TMP("XBHFMAN",$JOB,XBNAME),U,2)
+3 FOR %=1:1
IF '$PIECE(XBCHAP,".",%)
SET XBCHAP=$PIECE(XBCHAP,".",1,%-1)
QUIT
+4 SET XBHDRO=XBHDRO_$JUSTIFY("",DIWR-DIWL-$LENGTH(XBHDRO)-$LENGTH("Chapter "_XBCHAP)+1)_"Chapter "_XBCHAP
+5 SET XBHDRE="Chapter "_XBCHAP_$JUSTIFY("",DIWR-DIWL-$LENGTH(XBHDRE)-$LENGTH("Chapter "_XBCHAP)+1)_XBHDRE
+6 QUIT
+7 ;
CONT(X) ; ----- Add chapter number, title, and page number to list.
+1 SET XBCONT=XBCONT+1
SET ^TMP("XBHFMAN-CONTENTS",$JOB,XBCONT)=X
+2 QUIT
+3 ;
DESC(A) ; ----- Print descriptions of the OPTIONs as the first of the chapter.
+1 NEW B,I,N,Y
+2 IF '$DATA(^DIC(19,A,1))
DO PR("<NO DESCRIPTION>")
QUIT
+3 SET B=0
+4 FOR
SET B=$ORDER(^DIC(19,A,1,B))
IF 'B
QUIT
DO PR(^(B,0))
IF $DATA(DIRUT)
QUIT
+5 QUIT
+6 ;
HF(A) ; ----- Print the HELP FRAME text.
+1 IF 'A
DO PR("<NO HELP FRAME>")
QUIT
+2 IF '$DATA(^DIC(9.2,A,1))
DO PR("<NO HELP FRAME TEXT>")
QUIT
+3 NEW B,I,N,Y
+4 SET B=0
+5 FOR
SET B=$ORDER(^DIC(9.2,A,1,B))
IF 'B
QUIT
DO PR(^(B,0))
IF $DATA(DIRUT)
QUIT
+6 ; ----- Print any tied HELP FRAMEs.
+7 IF $ORDER(^DIC(9.2,A,2,0))
SET B=0
FOR
SET B=$ORDER(^DIC(9.2,A,2,B))
IF 'B
QUIT
DO HF($PIECE($GET(^(B,0)),U,2))
IF $DATA(DIRUT)
QUIT
+8 QUIT
+9 ;