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

DDW7.m

Go to the documentation of this file.
DDW7 ;SFISC/MKO-MARK TEXT ;2:30 PM  27 Jul 2000
 ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
 ;;Per VA Directive 6402, this routine should not be modified.
 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
 ;;Licensed under the terms of the Apache License, Version 2.0.
 ;
MARK ;Mark the text
 I $D(DDWMARK) D
 . D BOUND
 E  D
 . S DDWMARK=DDWA+DDWRW_U_DDWC_U_(DDWA+DDWRW)_U_$$MAX(DDWC,$L(DDWN))
 . D PAINT(DDWMARK,1),IND(1)
 Q
 ;
BOUND ;Mark ending boundary, highlight selected text
 N DDWI,DDWX,DDWY
 ;
 S DDWI=DDWA+DDWRW_U_DDWC
 S DDWX=$P(DDWMARK,U,1,2)
 S DDWY=$P(DDWMARK,U,3,4)
 ;
 I $$ISLESS(DDWI,DDWX) D
 . D PAINT(DDWX_U_DDWY)
 . D PAINT(DDWI_U_DDWX,1)
 . S DDWMARK=DDWI_U_DDWX
 E  D
 . I $$ISLESS(DDWI,DDWY) D
 .. D PAINT(DDWI_U_DDWY),PAINT(DDWI_U_DDWI,1)
 . E  D PAINT(DDWY_U_DDWI,1)
 . S DDWMARK=DDWX_U_DDWI
 D CUP(DDWRW,DDWC-DDWOFS)
 Q
 ;
UNMARK ;Unmark the text
 D:$D(DDWMARK) PAINT(DDWMARK),IND()
 K DDWMARK
 Q
 ;
PAINT(DDWMARK,DDWREV) ;Paint selected text
 N DDWI,DDWE1,DDWE2,DDWL1,DDWL2,DDWR1,DDWC1,DDWR2,DDWC2
 S DDWR1=$P(DDWMARK,U,1),DDWC1=$P(DDWMARK,U,2)
 S DDWR2=$P(DDWMARK,U,3),DDWC2=$P(DDWMARK,U,4)
 S DDWL1=$$M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