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

HLOPRSR1.m

Go to the documentation of this file.
  1. HLOPRSR1 ;ALB/CJM - Visual Parser 12 JUN 1997 10:00 am ;11/12/2008
  1. ;;1.6;HEALTH LEVEL SEVEN;**138,139**;Oct 13, 1995;Build 11
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ;
  1. ;Definitions:
  1. ;$$SCRNSIZE number of lines in the scrolling region
  1. ;@MSG@() array containing the message
  1. ;$$MSGSIZE number of lines in the message
  1. ;$$TOP msg line number appearing at the top of the scrolling region.
  1. ; It could be negative if the user scrolled up past the top of
  1. ; the msg.
  1. ;$$BOT msg line number of the line that appears at the bottom of the
  1. ; scrolling area. It could be bigger than $$MSGSIZE if the user
  1. ; scrolled down past the msg
  1. ;$$LINE the msg line being parsed
  1. ;$$X the character parsing position within the msg line
  1. ;$$Y the screen line of the current message line
  1. ;$$SEG current segment #
  1. ;$$FLD current field number
  1. ;$$REP current repitition number
  1. ;$$COMP current component #
  1. ;$$SUB current subcomponent #
  1. ;$$SEGSTART (<segment number>) msg line # that the segment starts on
  1. ;SEGTYPE - 3 character segment type of the current segment
  1. ;DELIM -field,component,subcomponent,repitition dlimiters
  1. ;FLD - field delimiter
  1. ;REP -repitition delimiter
  1. ;COMP - component delimiter
  1. ;SUB - subcomponent delimiter
  1. ;SEG - SEG(<seg#>)=line it starts on
  1. ;SEGLINE() - SEGLINE(<line number>)=segment it is in (1st line only)
  1. ;@DESCRIBE@() - list of text lines containing the description of current field
  1. ;
  1. PARSE(PARMS) ;
  1. N MSG,POS,SEG,INPUT,QUIT,IOBM,IOTM,HILITE,FLD,REP,ESC,COMP,SUB,DELIM,SEGTYPE,SEGLINE,OLDBM,OLDTM,DESCRIBE,VALUE,LASTPART,VERSION,VALMBCK,XGRT,OLD,REPEAT
  1. S OLDBM=$G(IOBM),OLDTM=$G(IOTM)
  1. S VALMBCK="R"
  1. Q:'$$SETUP^HLOPRSR3(.PARMS,.MSG,.POS,.SEG)
  1. S QUIT=0
  1. F S INPUT=$$READ^XGF(1,30) D Q:QUIT W IOCUON
  1. .D
  1. ..;remove what the user typed
  1. ..N CHAR,X,Y
  1. ..W IOCUOFF
  1. ..S CHAR=$$GETCHAR^HLOPRSR2
  1. ..I CHAR="" S CHAR=" "
  1. ..D IOXY($$Y,$$X)
  1. ..W $S($P(POS("CURRENT DELIMITER"),"^",2):IORVON,1:IOINHI)
  1. ..W IORVOFF,IOINORM
  1. ..W CHAR
  1. .;
  1. .I XGRT="UP" D UP^HLOPRSR2 Q
  1. .I (INPUT="U")!(INPUT="u") D UP^HLOPRSR2 Q
  1. .I XGRT="DOWN" D DOWN^HLOPRSR2 Q
  1. .I (INPUT="D")!(INPUT="d") D DOWN^HLOPRSR2 Q
  1. .I XGRT="LEFT" D LEFT^HLOPRSR2 Q
  1. .I (INPUT="L")!(INPUT="l") D LEFT^HLOPRSR2 Q
  1. .I XGRT="RIGHT" D RIGHT^HLOPRSR2 Q
  1. .I XGRT="TAB" D RIGHT^HLOPRSR2 Q
  1. .I (INPUT="R")!(INPUT="r") D RIGHT^HLOPRSR2 Q
  1. .I (INPUT="Q")!(INPUT="q") S QUIT=1
  1. .I (INPUT="?")!(INPUT="h")!(INPUT="h") D HELP^HLOPRSR3 Q
  1. .D IOXY($$Y,$$X) W IOCUON
  1. K @MSG
  1. I $L(DESCRIBE) K @DESCRIBE
  1. D CLEAN^XGF
  1. D ENS^%ZISS
  1. W IOEDALL
  1. S IOTM=OLDTM,IOBM=OLDBM W @IOSTBM
  1. Q
  1. ;
  1. WRITELN(LINE,Y) ;writes one line to the screen
  1. ;LINE- # of line in @MSG
  1. ;Y - screen line #
  1. D IOXY(Y,1)
  1. I $G(SEGLINE(LINE)) D
  1. .W IOINHI
  1. .W $E($G(@MSG@(LINE)),1,3)
  1. .W IOINORM
  1. .W $E($G(@MSG@(LINE)),4,80)
  1. E D
  1. .W $G(@MSG@(LINE))
  1. Q
  1. ;
  1. MSGSIZE() ;
  1. Q $O(@MSG@(9999999999),-1)
  1. SCRNSIZE() ;
  1. Q (IOBM-IOTM)+1
  1. TOP(INC) ;msg line at the top of the scrolling area
  1. I $G(INC) S POS("TOP")=POS("TOP")+INC
  1. Q POS("TOP")
  1. BOT() ;msg line at the bottom of the scrolling area
  1. Q ($$TOP+$$SCRNSIZE)-1
  1. LINE(TO,INC) ;msg line
  1. ;
  1. ;If TO and INC are null, $$LINE returns the current msg line
  1. ;If TO is valued, the current line is set to TO and that value returned
  1. ;Otherwise, if INC is valued the current line is incremented by that value and is returned
  1. D
  1. .I $L($G(TO)),$$X(1) S POS("LINE")=TO
  1. .I $G(INC),$$X(1) S POS("LINE")=POS("LINE")+INC
  1. Q +$G(POS("LINE"))
  1. ;
  1. X(TO,INC) ;current position within the line
  1. ;
  1. ;If TO and INC are null, $$X returns the current character position
  1. ;If TO is valued, the current position is set to TO and that value returned
  1. ;Otherwise, if INC is valued the current position is incremented by that value and is returned
  1. ;
  1. D
  1. .I $L($G(TO)) S POS("CHAR")=TO
  1. .I $G(INC) S POS("CHAR")=POS("CHAR")+INC
  1. ;
  1. I $G(POS("CHAR"))>$L($G(@MSG@($$LINE))) S POS("CHAR")=$L($G(@MSG@($$LINE)))
  1. I $G(POS("CHAR"))<1 S POS("CHAR")=1
  1. Q +$G(POS("CHAR"))
  1. Y(LINE) ;screen line of msg line = LINE
  1. ;LINE defaults to $$LINE
  1. I $D(LINE) Q (LINE-$$TOP)+1
  1. Q ($$LINE-$$TOP)+1
  1. SEG(INC) ;returns the current segement #
  1. ;if INC is passed in, the segment # is first incremented/decremented by INC, then the new value is returned
  1. ;returns the new current segment
  1. S POS("SEG")=$G(POS("SEG"))+$G(INC)
  1. Q POS("SEG")
  1. FLD(SET) ;returns the currrent field #
  1. ;Input:
  1. ; SET:
  1. ; if "+" increments the field #
  1. ; if "-" decrements the field #
  1. ; if SET>0 sets the field # to SET
  1. D:$D(SET)
  1. .I $E(SET)="+" S POS("FLD")=$G(POS("FLD"))+1 Q
  1. .I $E(SET)="-" S POS("FLD")=$G(POS("FLD"))-1 Q
  1. .S POS("FLD")=SET
  1. Q $G(POS("FLD"))
  1. REP(SET) ;returns the current repitition #
  1. ;Input:
  1. ; SET:
  1. ; if "+" increments the repitition #
  1. ; if "-" decrements the repitition #
  1. ; if >0 sets the repitition # to SET
  1. D:$D(SET)
  1. .I $E(SET)="+" S POS("REP")=$G(POS("REP"))+1 Q
  1. .I $E(SET)="-" S POS("REP")=POS("REP")-1 Q
  1. .S POS("REP")=SET
  1. I $D(SET) S:'($G(LASTPART($$FLD))>POS("REP")) LASTPART($$FLD)=POS("REP")
  1. Q +$G(POS("REP"))
  1. COMP(SET) ;returns the current component #
  1. ;Input:
  1. ; SET:
  1. ; if "+" increments the component #
  1. ; if "-" decrements the component #
  1. ; if >0 sets the component # to SET
  1. D:$D(SET)
  1. .I $E(SET)="+" S POS("COMP")=$G(POS("COMP"))+1 Q
  1. .I $E(SET)="-" S POS("COMP")=POS("COMP")-1 Q
  1. .S POS("COMP")=SET
  1. I $D(SET) S:'($G(LASTPART($$FLD,$$REP))>POS("COMP")) LASTPART($$FLD,$$REP)=POS("COMP")
  1. Q +$G(POS("COMP"))
  1. ;
  1. SUB(SET) ;returns the current sub-component #
  1. ;Input:
  1. ; SET:
  1. ; if "+" increments the subcomponent #
  1. ; if "-" decrements the subcomponent #
  1. ; if >0 sets the sub-component # to SET
  1. D:$D(SET)
  1. .I $E(SET)="+" S POS("SUB")=$G(POS("SUB"))+1 Q
  1. .I $E(SET)="-" S POS("SUB")=POS("SUB")-1 Q
  1. .S POS("SUB")=SET
  1. I $D(SET) S:'($G(LASTPART($$FLD,$$REP,$$COMP))>POS("SUB")) LASTPART($$FLD,$$REP,$$COMP)=POS("SUB")
  1. Q +$G(POS("SUB"))
  1. ;
  1. SEGSTART(SEGMENT) ;
  1. Q $G(SEG(SEGMENT))
  1. ;
  1. IOXY(Y,X) ; moves to screen position line=Y, col=X
  1. ;convert to (0,0) origin
  1. I $G(X),X=+X S X=X-1
  1. I $G(Y),Y=+Y S Y=Y-1
  1. ;
  1. D IOXY^XGF($G(Y),$G(X))
  1. Q