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

DIR0W.m

Go to the documentation of this file.
DIR0W ;SFISC/MKO-WORD FUNCTIONS FOR FIELD EDITOR ;09:45 AM  12 Dec 1994
 ;;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.
 ;
WRT N DIR0I
 Q:DIR0C>$L(DIR0A)
 S DIR0I=$$WRPOS(DIR0A)
 ;
 I DIR0C-DX+DIR0S+DIR0L>DIR0I S DX=DX+DIR0I-DIR0C,DIR0C=DIR0I Q
 S DIR0C=DIR0I,DX=DIR0S X IOXY
 I $L(DIR0A)-DIR0L<DIR0C D
 . W $E(DIR0A,$L(DIR0A)-DIR0L+1,$L(DIR0A))
 . S DX=DIR0S+DIR0C-$L(DIR0A)+DIR0L-1
 E  W $E(DIR0A,DIR0C,DIR0C+DIR0L-1)
 Q
 ;
WLT N DIR0D,DIR0I,DIR0T
 Q:DIR0C=1
 S DIR0T=$$PUNC(DIR0A)
 ;
 S DIR0I=DIR0C-1
 I $E(DIR0T,DIR0I)=" " F DIR0I=DIR0I-1:-1:0 Q:$E(DIR0T,DIR0I)'=" "
 I $E(DIR0T,DIR0I)="!" D
 . F DIR0I=DIR0I-1:-1:0 Q:$E(DIR0T,DIR0I)'="!"
 E  I DIR0I D
 . F DIR0I=DIR0I-1:-1:0 Q:" !"[$E(DIR0T,DIR0I)
 S DIR0I=DIR0I+1
 ;
 I DIR0C-DX+DIR0S'>DIR0I S DX=DX-DIR0C+DIR0I,DIR0C=DIR0I Q
 S DIR0C=DIR0I,DX=DIR0S X IOXY
 I DIR0L'<DIR0C W $E(DIR0A,1,DIR0L) S DX=DIR0S+DIR0C-1 Q
 S DX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