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

OCXOCMPL.m

Go to the documentation of this file.
OCXOCMPL ;SLC/RJS,CLA - ORDER CHECK CODE COMPILER (Compile Complex Rule Element Expressions) ;10/29/98  12:37
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**32**;Dec 17,1997
 ;;  ;;ORDER CHECK EXPERT version 1.01 released OCT 29,1998
 ;
EN ;
 ;
 Q
 ;
GETC(OCXD0,OCXEXP,OCXDTYP,OCXCD) ;
 ;
 N OCXCHR,OCXCOD1,OCXCODE,OCXD2,OCXNULL,OCXOPC,OCXOPER,OCXOPN,OCXP,OCXPOS,OCXPTR1,OCXPTR2,OCXVNAM,OCXITEM
 ;
 F OCXPTR1=1:1:$L(OCXEXP) S OCXCHR=$E(OCXEXP,OCXPTR1) D
 .;
 .I (OCXCHR="|") D  Q
 ..F OCXPTR2=(OCXPTR1+1):1:$L(OCXEXP) Q:($E(OCXEXP,OCXPTR2)="|")
 ..S OCXITEM($O(OCXITEM(""),-1)+1)=$$STSPAC($E(OCXEXP,OCXPTR1+1,OCXPTR2-1)),OCXPTR1=OCXPTR2
 .;
 .I (OCXCHR="""") D  Q
 ..F OCXPTR2=(OCXPTR1+1):1:$L(OCXEXP) Q:($E(OCXEXP,OCXPTR2)="""")
 ..S OCXITEM($O(OCXITEM(""),-1)+1)=$$STSPAC($E(OCXEXP,OCXPTR1+1,OCXPTR2-1)),OCXPTR1=OCXPTR2
 .;
 .I (OCXCHR?1A) D  Q
 ..F OCXPTR2=(OCXPTR1+1):1:$L(OCXEXP) Q:($E(OCXEXP,OCXPTR2)="""")  Q:($E(OCXEXP,OCXPTR2)="|")
 ..S OCXITEM($O(OCXITEM(""),-1)+1)=$$STSPAC($E(OCXEXP,OCXPTR1,OCXPTR2-1)),OCXPTR1=OCXPTR2-1
 ;
 S OCXOPER=$$OPER(OCXITEM(2),OCXDTYP)
 I '(OCXOPER) D WARN^OCXOCMPV("Operator/Function ("_OCXDTYP_") '"_OCXITEM(2)_"' not defined...",3,OCXEL,$P($T(+1)," ",1)) Q ""
 S OCXOPN=$P($G(^OCXS(863.9,OCXOPER,0)),U,1)
 S OCXOPC=$$GETPARM^OCXOCMPE(39,OCXOPER,"OCXO GENERATE CODE FUNCTION")
 I '$L(OCXOPC) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' parameter not defined",3,OCXEL,$P($T(+1)," ",1)) Q ""
 S:'(OCXOPC=+OCXOPC) OCXOPC=$$GETIEN("^OCXS(863.7)",OCXOPC)
 I '$D(^OCXS(863.7,+OCXOPC,0)) D WARN^OCXOCMPV("'"_OCXOPN_"' Operator 'OCXO GENERATE CODE FUNCTION' Public Function not defined",3,OCXEL,$P($T(+1)," ",1)) Q ""
 S OCXP=$G(^OCXS(863.7,+OCXOPC,"EX")) I '$L(OCXP) D WARN^OCXOCMPV("Operator ("_(+OCXOPC)_") '"_$P($G(^OCXS(863.9,+OCXOPC,0)),U,1)_"' executable not defined",3,OCXEL,$P($T(+1)," ",1)) Q ""
 S OCXD2=0 F  S OCXD2=$O(^OCXS(863.7,+OCXOPC,"PAR",OCXD2)) Q:'OCXD2  D
 .N OCXPOS,OCXVNAM
 .S OCXPOS=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,"IN")) Q:'OCXPOS  Q:$D(OCXP(OCXPOS))
 .S OCXVNAM=+$G(^OCXS(863.7,+OCXOPC,"PAR",OCXD2,0)) Q:'OCXVNAM
 .S OCXVNAM=$P($G(^OCXS(863.8,+OCXVNAM,0)),U,2) Q:'$L(OCXVNAM)
 .S OCXP(+OCXPOS)=OCXVNAM,OCXP(OCXVNAM)=""
 ;
 S OCXNULL=$$GETPARM(39,OCXOPER,"OCXO NULL VALUE ALLOWED")
 I '$D(OCXP("PDFLD")) D WARN^OCXOCMPV("CMPE1 Primary Data field not defined",3,OCXD0,$P($T(+1)," ",1)) Q ""
 I $D(OCXP("PDFLD")) S OCXP("PDFLD")=OCXITEM(1)
 I '$L(OCXP("PDFLD")) D WARN^OCXOCMPV("CMPE2 Primary Data field not defined",3,OCXD0,$P($T(+1)," ",1)) Q ""
 ;
 I $D(OCXP("CVAL")) D  I '$L(OCXP("CVAL")) D WARN^OCXOCMPV("Comparison Value/Field not defined",3,OCXD0,$P($T(+1)," ",1)) Q ""
 .S OCXP("CVAL")=OCXITEM(3)
 .I '$L(OCXP("CVAL")) S OCXP("CVAL")=$$GV^OCXOCMPE(OCXD0,OCXD1,"DFLD2",OCXOPDT,OCXNULL)
 ;
 I $D(OCXP("CLVAL")) D  I '$L(OCXP("CLVAL")) D WARN^OCXOCMPV("Comparison Value/Field minimum value not defined",3,OCXD0,$P($T(+1)," ",1)) Q ""
 .S OCXP("CLVAL")=OCXITEM(3)
 .I '$L(OCXP("CLVAL")) S OCXP("CLVAL")=$$GV^OCXOCMPE(OCXD0,OCXD1,"DFLD2",OCXOPDT,OCXNULL)
 ;
 I $D(OCXP("CHVAL")) D  I '$L(OCXP("CHVAL")) D WARN^OCXOCMPV("Comparison Value/Field maximum value not defined",3,OCXD0,$P($T(+1)," ",1)) Q ""
 .S OCXP("CHVAL")=OCXITEM(5)
 .I '$L(OCXP("CHVAL")) S OCXP("CHVAL")=$$GV^OCXOCMPE(OCXD0,OCXD1,"DFLD3",OCXOPDT,OCXNULL)
 ;
 S OCXCOD1="S OCXCODE=$$"_OCXP
 I $O(OCXP(0)) S OCXCOD1=OCXCOD1_"(",OCXD2=0 F  S OCXD2=$O(OCXP(OCXD2)) Q:'OCXD2  D
 .I ($E(OCXP(OCXP(OCXD2)),1)="""") S OCXCOD1=OCXCOD1_""""""_OCXP(OCXP(OCXD2))_""""""
 .E  S OCXCOD1=OCXCOD1_""""_OCXP(OCXP(OCXD2))_""""
 .I $O(OCXP(OCXD2)) S OCXCOD1=OCXCOD1_","
 .E  S OCXCOD1=OCXCOD1_")"
 X OCXCOD1
 I '$L(OCXCODE) D WARN^OCXOCMPV("Execute code missing for '"_OCXCOD1_"'",2,OCXD0,$P($T(+1)," ",1)) Q ""
 S OCXCD="I "_OCXCODE_" D @@@@" Q OCXWARN
 ;
GETIEN(FILE,KEY) ;
 ;
 N IEN1,IEN2,LEN,SHORT
 F LEN=$L(KEY):-1:0 I LEN Q:$D(@FILE@("B",$E(KEY,1,LEN)))
 Q:'LEN 0 S SHORT=$E(KEY,1,LEN)
 S IEN1=0 F  S IEN1=$O(@FILE@("B",SHORT,IEN1)) Q:'IEN1  Q:($P($G(@FILE@(IEN1,0)),U,1)=KEY)
 S IEN2=IEN1 F  S IEN2=$O(@FILE@("B",SHORT,IEN2)) Q:'IEN2  Q:($P($G(@FILE@(IEN2,0)),U,1)=KEY)
 I IEN1,IEN2 Q -1
 Q IEN1
 ;
OPER(OPER,DTYP) ;
 ;
 N DTYPN,OPERN
 S DTYPN=$O(^OCXS(864.1,"B",DTYP,0)) Q:'DTYPN 0
 S OPERN=0 F  S OPERN=$O(^OCXS(863.9,"B",OPER,OPERN)) Q:'OPERN  Q:($P($G(^OCXS(863.9,+OPERN,0)),U,2)=DTYPN)
 Q:OPERN OPERN
 S OPERN=0 F  S OPERN=$O(^OCXS(863.9,"SYN",OPER,OPERN)) Q:'OPERN  Q:($P($G(^OCXS(863.9,+OPERN,0)),U,2)=DTYPN)
 Q OPERN
 ;
GETPARM(FILE,INST,PARM) ;
 Q:'$L(FILE) "" Q:'$L(INST) "" Q:'$L(PARM) ""
 N OCXP,OCXP1,OCXI,OCXGL
 S OCXGL="^OCXS" S:(FILE=1) OCXGL="^OCXD" S:(FILE=7) OCXGL="^OCXD" S:(FILE=10) OCXGL="^OCXD" S FILE=FILE/10+860
 Q:'$D(@OCXGL@(+FILE,0)) ""
 I (PARM=+PARM),$D(^OCXS(863.8,PARM,0)) S OCXP=PARM
 E  S OCXP=$O(^OCXS(863.8,"B",PARM,0))
 Q:'OCXP ""
 I (INST=+INST),$D(@OCXGL@(FILE,INST,0)) S OCXI=INST
 E  S OCXI=$O(@OCXGL@(FILE,"B",INST,0))
 Q:'OCXI ""
 S OCXP1=$O(@OCXGL@(FILE,OCXI,"PAR","B",OCXP,0)) S:'OCXP1 OCXP1=$O(@OCXGL@(FILE,OCXI,"PAR","B",PARM,0))
 Q:'$L(OCXP1) ""
 Q $G(@OCXGL@(FILE,OCXI,"PAR",OCXP1,"VAL"))
STSPAC(S) ;
 ;
 N X
 ;
 F X=1:1:$L(S) Q:'($E(S,X)=" ")
 S S=$E(S,X,$L(S))
 ;
 F X=$L(S):-1:1 Q:'($E(S,X)=" ")
 S S=$E(S,1,X)
 ;
 Q S
 ;