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

VALM40.m

Go to the documentation of this file.
VALM40 ;ALB/MJK - Screen Malipulation Utilities (cont.) ;11:25 PM  11 Dec 1992 [ 07/24/98  9:29 AM ]
 ;;1;List Manager;**1002**;Aug 13, 1993
 ;IHS/ANMC/LJF 5/6/97 IHS PATCH #1002
 ;  -- changed "find next" prompt to "stop here"
 ;
FIND ; -- find text in list
 N START,BEG,VALMOUT,VALMHIT
 S DIR(0)="F^2:50",DIR("A")="Search for" S:$D(VALMFIND) DIR("B")=VALMFIND
 S DIR("?")="Enter from two to fifty characters."
 D ^DIR K DIR I "^"[Y G FINDQ
 S VALMFIND=Y,(BEG,START)=VALMBG,FINISH=VALMCNT
 F  D SEARCH(START,FINISH) D  D:VALMHIT SELECT^VALM10(VALMHIT,0) Q:$D(VALMOUT)
 .I 'VALMHIT,BEG=1 D PAUSE^VALM1 S VALMOUT="" Q
 .I VALMHIT,BEG=1,VALMHIT=VALMCNT D PAUSE^VALM1 S VALMOUT="" Q
 .I 'VALMHIT!(VALMHIT=VALMCNT),BEG'=1,$$BEG S FINISH=BEG-1,(BEG,START)=1 Q
 .I 'VALMHIT!(VALMHIT=VALMCNT),BEG'=1 S VALMOUT="" Q
 .;W ! S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Find Next '"_VALMFIND_"'" D ^DIR K DIR ;IHS PATCH #1002
 .;I Y S START=VALMHIT+1 Q ;IHS PATCH #1002
 .W ! S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Stop Here" D ^DIR K DIR ;IHS PATCH #1002
 .I 'Y S START=VALMHIT+1 Q  ;IHS PATCH #1002
 .S VALMOUT=""
FINDQ D FINISH^VALM4 Q
 ;
BEG() ; -- ask if ok to start from top
 W !!,"<<< End of list >>>"
 S DIR(0)="Y",DIR("A")="Do you want to start at the beginning of the list",DIR("B")="Yes"
 D ^DIR K DIR
 Q Y
 ;
 ; input:  START := line to start search on
 ;        FINISH := line to end search on
 ;
 N Y,X,L,CNT
 S VALMHIT="",CNT=0
 S VALMBCK="" D:VALMCC RESET^VALM4 W !,"...searching for '"_VALMFIND_"'"
 F I=START:1:FINISH S CNT=CNT+1 W:'(CNT#100) "." I $$UPPER^VALM1(@VALMAR@(I,0))[$$UPPER^VALM1(VALMFIND) S VALMHIT=I Q
 I 'VALMHIT W *7,!!,"Text not found." G SEARCHQ
 I VALMCC D
 .I VALMHIT<VALMBG!(VALMHIT>VALMLST) S VALMBG=VALMHIT D LST^VALM4,PAINT^VALM4
 .D UPD(VALMHIT,VALMFIND)
 D PGUPD^VALM4
 I 'VALMCC S VALMBG=VALMHIT D REFRESH^VALM
SEARCHQ Q
 ;
UPD(LINE,TEXT) ; -- set/unset video attribute on text
 ;  input:    LINE := number of line
 ;            TEXT := chars to set attribute on
 ;
 N LEN,POS,FIRST
 D SELECT^VALM10(.LINE,1)
 I 'VALMCC G UPDQ
 S Y=@VALMAR@(LINE,0),LEN=$L(TEXT),POS=0,FIRST=""
 F  S POS=$F($$UPPER^VALM1(Y),$$UPPER^VALM1(TEXT),POS) Q:'POS  D
 .S:'FIRST FIRST=POS-LEN
 .D CNTRL^VALM10(.LINE,POS-LEN,.LEN,.IORVON,IORVOFF_IOINHI)
 I FIRST D
 .I FIRST'>VALM("FIXED") Q
 .I FIRST<VALMLFT D LEFT("^^^="_(VALMLFT-FIRST)) Q
 .I FIRST'>((VALMWD-VALM("FIXED"))+VALMLFT) Q
 .D RIGHT("^^^="_(FIRST-VALMLFT))
 D WRITE^VALM10(.LINE)
UPDQ Q
 ;
UP ; -- display last screen (UP)
 D START^VALM4
 N Y S Y=VALMBG-1 I Y<1 W *7 G UPQ
 S VALMBG=Y D LST^VALM4
 I VALMCC S DY=VALM("TM")-1 D SCROLL^VALM4,IOIL^VALM4(0,.DY),WRITE^VALM4(VALMBG,0,1,.DY),PLUS^VALM4,RESET^VALM4
 D PGUPD^VALM4
UPQ D FINISH^VALM4 Q
 ;
DOWN ; -- display next line (DN)
 D START^VALM4
 N Y S Y=VALMLST+1 I Y>VALMCNT W *7 G DOWNQ
 S VALMBG=VALMBG+1,VALMLST=Y
 I VALMCC S DY=VALM("BM")-1 D SCROLL^VALM4,IOXY^VALM4(0,.DY),WRITE^VALM4(VALMLST,1,1,.DY),PLUS^VALM4,RESET^VALM4
 D PGUPD^VALM4
DOWNQ D FINISH^VALM4 Q
 ;
 D START^VALM4
 N MOVE,RM
 S MOVE=$P($P(VALMNOD,U,4),"=",3),RM=VALM("RM")-VALMWD+VALM("FIXED")
 I VALMLFT=RM W *7 G RIGHTQ
 I MOVE?1">".E D
 .S VALMLFT=RM
 E  D
 .S MOVE=$S(MOVE:+MOVE,1:VALMWD-VALM("FIXED"))
 .I (VALMLFT+MOVE)>RM S VALMLFT=RM Q
 .S VALMLFT=VALMLFT+MOVE
 I VALMCC S:VALMWD'<$L($G(VALMHDR(VALM("TM")-3))) VALMBCK="P" D REFRESH^VALM
RIGHTQ D FINISH^VALM4 Q
 ;
LEFT(VALMNOD) ; -- move veiw to left
 D START^VALM4
 N MOVE,LM
 S MOVE=$P($P(VALMNOD,U,4),"=",3),LM=VALM("FIXED")+1
 I VALMLFT=LM W *7 G LEFTQ
 I MOVE?1"<".E D
 .S VALMLFT=LM
 E  D
 .S MOVE=$S(MOVE:+MOVE,1:VALMWD-VALM("FIXED"))
 .S:(VALMLFT-MOVE)<LM MOVE=VALMLFT-VALM("FIXED")-1
 .S VALMLFT=VALMLFT-MOVE
 I VALMCC S:VALMWD'<$L($G(VALMHDR(VALM("TM")-3))) VALMBCK="P" D REFRESH^VALM
LEFTQ D FINISH^VALM4 Q
 ;
GOTO ; -- go to page #
 N Y,DIR,PAGE,LINE
 S PAGE=$$PAGE^VALM4(VALMCNT,VALM("LINES"))
 I PAGE=1 S VALMSG="This list only contains 1 page." G GOTOQ
 S Y=+$P($P(XQORNOD(0),U,4),"=",3)
 I Y D  I $G(VALMSG)]"" G GOTOQ
 .I Y>PAGE S VALMSG="Too large. Page #"_Y_" does not exist." Q
 .I Y<1 S VALMSG="Negative page numbers do not exist." Q
 .S PAGE=Y
 I 'Y D
 .S DIR(0)="NA^1:"_PAGE,DIR("A")="Go to Page (1-"_PAGE_"): "
 .W ! D ^DIR K DIR S PAGE=+Y
 I PAGE D
 .S LINE=((PAGE-1)*VALM("LINES"))+1
 .I LINE=VALMBG S VALMSG="Your selection is the current screen." Q
 .I LINE'=VALMBG S VALMBG=LINE D:VALMCC LST^VALM4,PAINT^VALM4 D PGUPD^VALM4
GOTOQ I $G(VALMSG)]"" S VALMSG=$C(7)_VALMSG
 D FINISH^VALM4
 Q