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

DDSLIB.m

Go to the documentation of this file.
  1. DDSLIB ;SFISC/MKO-LIBRARY FUNCTIONS ;01:37 PM 6 Sep 1994
  1. ;;22.0;VA FileMan;;Mar 30, 1999
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. FIND(E,C,S) ;Find in expression E, starting from pos S, the char pos
  1. ;after the next occurrence of char C, ignoring those within quoted
  1. ;strings.
  1. N I,J,P
  1. S:'$D(S) S=1
  1. F D Q:$D(P)
  1. . S I=$F(E,C,S),J=$F(E,"""",S)
  1. . I 'I S P=I Q
  1. . I J,J<I S S=$$AFTQ(E,J-1) Q
  1. . S P=I
  1. Q P
  1. ;
  1. PIECE(E,C,N1,N2) ;Return the N1th to N2th C-piece of E
  1. ;ignoring those within quoted strings
  1. ;Start looking from pos 1
  1. N I,J,S,F
  1. S:'$D(N1) N1=1 Q:'N1
  1. S:'$D(N2) N2=N1 Q:N2<N1
  1. S S=1 F I=1:1:N1-1 S S=$$FIND(E,C,S) Q:'S
  1. Q:'S $S(N1=1:E,1:"")
  1. S F=S F I=1:1:N2-N1+1 S F=$$FIND(E,C,F) Q:'F
  1. Q:'F $E(E,S,999)
  1. Q $E(E,S,F-2)
  1. ;
  1. RPAR(E,S) ;Find in expression E, from char pos S (the position
  1. ;of the left paren) the char pos after the right paren,
  1. ;ignoring nested parens, or parens within quotes
  1. N I,L,P,R
  1. S P=1,I=S+1
  1. F D Q:'P
  1. . S R=$$FIND(E,")",I),L=$$FIND(E,"(",I)
  1. . I L,L<R S P=P+1,I=L Q
  1. . S P=P-1,I=R
  1. Q I
  1. ;
  1. AFTQ(E,I) ;Return character position after quoted string
  1. ;E = string, I=character position of first quote
  1. S:'$G(I) I=1
  1. F S I=$F(E,"""",I+1) Q:$E(E,I)'=""""
  1. S:'I I=$L(E)+1
  1. Q I
  1. ;
  1. QT(X) ;Return X quoted
  1. Q:$G(X)="" """"""
  1. S X(X)="",X=$Q(X(""))
  1. Q $E(X,3,$L(X)-1)
  1. ;
  1. UQT(X) ;Return quoted string X unquoted
  1. Q:$G(X)="" ""
  1. S @("X("_X_")=""""")
  1. Q $O(X(""))
  1. ;
  1. FIELD(DDP,FLD) ;Get field number
  1. N F,P
  1. I FLD="" D BLD^DIALOG(202,"field") Q ""
  1. S:$E(FLD)="""" FLD=$$UQT($E(FLD,1,$$AFTQ(FLD)-1))
  1. S F=FLD,P("FILE")=DDP
  1. I FLD'=+$P(FLD,"E") D Q:$G(DIERR) ""
  1. . S F=$O(^DD(DDP,"B",FLD,""))
  1. . I F="" S P(1)=FLD D BLD^DIALOG(501,.P)
  1. ;
  1. I $D(^DD(DDP,F,0))[0 S P(1)="#"_F D BLD^DIALOG(501,.P) Q ""
  1. Q F
  1. ;
  1. GETFLD(FD,BK,PG,DDS,DDSPG,DDSBK,DDSFLG) ;Return "DDO,bk#,pg#"
  1. ;DDSPG=current page, DDSBK=current block
  1. ; -- when block and page are optional
  1. ;PG is required only if block order is sent
  1. ;DDSFLG["F" means field must be form-only
  1. N F,B,P,N
  1. I FD?.N.1"."1.N1",".N.1"."1.N,BK="",PG="" Q FD
  1. S:$E($G(FD))="""" FD=$$UQT(FD)
  1. S:$E($G(BK))="""" BK=$$UQT(BK)
  1. S:$E($G(PG))="""" PG=$$UQT(PG)
  1. S P=+$G(DDSPG),B=+$G(DDSBK)
  1. D @$S($G(PG)]"":"PG",$G(BK)]"":"BK",1:"FD") Q:$G(DIERR) ""
  1. Q F_","_B_","_P
  1. ;
  1. PG ;Get internal page number
  1. I '$G(DDS) D BLD^DIALOG(3084) Q
  1. S N=PG=+$P(PG,"E")
  1. I N S P=$O(^DIST(.403,+DDS,40,"B",PG,""))
  1. E I PG?1"`".N.1"."1.N S P=+$P(PG,"`",2),N=2
  1. E S P=$O(^DIST(.403,+DDS,40,"C",$$UPCASE(PG),""))
  1. ;
  1. I $D(^DIST(.403,+DDS,40,+P,0))[0 D BLD^DIALOG(3023,$S(N=2:"#",N:"number ",1:"named ")_PG) Q
  1. ;
  1. I BK="" D Q:$G(DIERR)
  1. . S BK=$O(^DIST(.403,+DDS,40,P,40,"AC",""))
  1. . I BK="" D BLD^DIALOG(3055,$S(N:"number ",1:"named ")_PG)
  1. ;
  1. BK ;Get internal block number
  1. S N=BK=+$P(BK,"E")
  1. I N D Q:$G(DIERR)
  1. . I P S B=$O(^DIST(.403,+DDS,40,P,40,"AC",BK,"")) Q
  1. . D BLD^DIALOG(3085)
  1. E I BK?1"`".N.1"."1.N S B=+$P(BK,"`",2),N=2
  1. E D Q:$G(DIERR)
  1. . S B=$O(^DIST(.404,"B",BK,""))
  1. . I B="" D BLD^DIALOG(3051,BK) Q
  1. . S B=$O(^DIST(.403,+DDS,40,P,40,"B",B,""))
  1. ;
  1. I P,$D(^DIST(.403,+DDS,40,P,40,+B,0))[0 D Q
  1. . N P1
  1. . S P1(1)=$S(N=2:"#",N:"order ",1:"")_BK
  1. . S P1(2)="number "_$P(^DIST(.403,+DDS,40,P,0),U)_$S($G(^(1))]"":" ("_$P(^(1),U)_")",1:"")
  1. . D BLD^DIALOG(3053,.P1)
  1. ;
  1. I FD="" D Q:$G(DIERR)
  1. . S FD=$O(^DIST(.404,B,40,"B",""))
  1. . D:FD="" BLD^DIALOG(3071,$P(^DIST(.404,B,0),U))
  1. ;
  1. FD ;Get internal field number
  1. I 'B D BLD^DIALOG(3082) Q
  1. S N=FD=+$P(FD,"E")
  1. I N S F=$O(^DIST(.404,B,40,"B",FD,""))
  1. E I FD?1"`".N.1"."1.N S F=+$P(FD,"`",2),N=2
  1. E D Q:$G(DIERR)
  1. . N X
  1. . S FD=$$UPCASE(FD),X=$S($D(^DIST(.404,B,40,"D",FD)):"D",1:"C")
  1. . S F=$O(^DIST(.404,B,40,X,FD,""))
  1. ;
  1. I $D(^DIST(.404,B,40,+F,0))[0 D
  1. . N P
  1. . S P(1)=$S(N=2:"#",N:"order ",1:"with caption or unique name ")_FD
  1. . S P(2)=$P(^DIST(.404,B,0),U)
  1. . D BLD^DIALOG(3072,.P)
  1. ;
  1. I '$G(DIERR),$G(DDSFLG)["F","^2^4^"'[(U_$P($G(^DIST(.404,B,40,+F,0)),U,3)_U) D BLD^DIALOG(3081)
  1. Q
  1. ;
  1. UPCASE(X) ;
  1. ;Return X in uppercase
  1. Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")