Changeset 555 for ccr/trunk/p


Ignore:
Timestamp:
Aug 27, 2009, 12:22:58 PM (15 years ago)
Author:
George Lilly
Message:

fixed undefined error found by FJ with $G

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CRNF.m

    r508 r555  
    7171 ;
    7272GETN(GRTN,GFILE,GREF,GNDX,GNN)  ; GET BY NAME ; RETURN A FIELD VALUE MAP
     73 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
     74 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
     75 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
     76 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
     77 ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
     78 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
     79 ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
     80 ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
     81 ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
     82 ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
     83 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
     84 ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
     85 ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
     86 ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
     87 ; GREF IS THE VALUE FOR THE INDEX
     88 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
     89 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
     90 ;
     91 ;
     92 N GIEN,GF
     93 S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
     94 I ('$D(GNDX))!($G(GNDX)="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
     95 E  D  ; WE ARE USING AN INDEX
     96 . ;N ZG
     97 . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
     98 . I ZG'="" D  ;
     99 . . I $QS(ZG,3)=GREF D  ; IS GREF IN INDEX?
     100 . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
     101 . . E  S GIEN="" ; NOT FOUND IN INDEX
     102 . E  S GIEN="" ;
     103 ;W "IEN: ",GIEN,!
     104 ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
     105 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
     106 E  S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
     107 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
     108 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
     109 K C0CTMP
     110 D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")
     111 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
     112 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
     113 S (C0CI,C0CJ)=""
     114 F  S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ=""  D  ; FOR ALL SUBFILES
     115 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
     116 . F  S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI=""  D  ; ARRAY OF FIELDS
     117 . . ;W C0CJ," ",C0CI,!
     118 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
     119 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;
     120 . . I C0CVALUE["C0CTMP" D  ; WP FIELD
     121 . . . N ZT,ZWP S ZWP=0 ;ITERATOR
     122 . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE
     123 . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE
     124 . . . F  S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP  D  ;
     125 . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
     126 . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
     127 . . . . S C0CVALUE=C0CVALUE_ZT ;
     128 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
     129 . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))
     130 I C0CNN D  ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
     131 . S C0CI=""
     132 . F  S C0CI=$O(@GRTN@(C0CI)) Q:C0CI=""  D  ; GO THROUGH THE WHOLE ARRAY
     133 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
     134 Q
     135 ;
     136GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
    73137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
    74138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
     
    134198 Q
    135199 ;
    136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
    137  ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
    138  ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
    139  ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
    140  ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
    141  ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
    142  ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
    143  ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
    144  ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
    145  ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
    146  ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
    147  ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
    148  ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
    149  ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
    150  ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
    151  ; GREF IS THE VALUE FOR THE INDEX
    152  ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
    153  ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
    154  ;
    155  ;
    156  N GIEN,GF
    157  S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
    158  I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
    159  E  D  ; WE ARE USING AN INDEX
    160  . ;N ZG
    161  . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
    162  . I ZG'="" D  ;
    163  . . I $QS(ZG,3)=GREF D  ; IS GREF IN INDEX?
    164  . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
    165  . . E  S GIEN="" ; NOT FOUND IN INDEX
    166  . E  S GIEN="" ;
    167  ;W "IEN: ",GIEN,!
    168  ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
    169  I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
    170  E  S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
    171  S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
    172  D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
    173  K C0CTMP
    174  D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")
    175  D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
    176  S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
    177  S (C0CI,C0CJ)=""
    178  F  S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ=""  D  ; FOR ALL SUBFILES
    179  . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
    180  . F  S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI=""  D  ; ARRAY OF FIELDS
    181  . . ;W C0CJ," ",C0CI,!
    182  . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
    183  . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;
    184  . . I C0CVALUE["C0CTMP" D  ; WP FIELD
    185  . . . N ZT,ZWP S ZWP=0 ;ITERATOR
    186  . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE
    187  . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE
    188  . . . F  S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP  D  ;
    189  . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
    190  . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
    191  . . . . S C0CVALUE=C0CVALUE_ZT ;
    192  . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
    193  . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))
    194  I C0CNN D  ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
    195  . S C0CI=""
    196  . F  S C0CI=$O(@GRTN@(C0CI)) Q:C0CI=""  D  ; GO THROUGH THE WHOLE ARRAY
    197  . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
    198  Q
    199  ;
    200200GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN)     ; RETURN FIELD MAP AND VALUES
    201201 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
Note: See TracChangeset for help on using the changeset viewer.