- DGENDBS ;ALB/RMO/CJM,JAM - Database Server Utilities; [ 03/23/95 11:08 AM ]
- ;;5.3;Registration;**122,147,182,1040**;08/13/93;Build 15
- ;
- UPD(FILE,DGENDA,DATA,ERROR) ;File data into an existing record.
- ; Input:
- ; FILE - File or sub-file number
- ; DGENDA - New name for traditional DA array, with same meaning.
- ; Pass by reference.
- ; DATA - Data array to file (pass by reference)
- ; Format: DATA(<field #>)=<value>
- ;
- ; Output:
- ; Function Value - 0=error and 1=no error
- ; ERROR - optional error message - if needed, pass by reference
- ;
- ; Example: To update a record in subfile 2.0361 in record with ien=353,
- ; subrecord ien=68, with the field .01 value = 21:
- ; S DATA(.01)=21,DGENDA=68,DGENDA(1)=353 I $$UPD^DGENDBS(2.0361,.DGENDA,.DATA,.ERROR) W !,"DONE"
- ;
- ; DG*5,3*1040;jam; Add New of DTOUT to protect it from FILE^DIE which will kill this variable.
- N FDA,FIELD,IENS,ERRORS,DTOUT
- ;
- ;IENS - Internal Entry Number String defined by FM
- ;FDA - the FDA array as defined by FM
- ;
- I '$G(DGENDA) S ERROR="IEN OF RECORD TO BE UPDATED NOT SPECIFIED" Q 0
- S IENS=$$IENS^DILF(.DGENDA)
- S FIELD=0
- F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
- .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
- D FILE^DIE("K","FDA","ERRORS(1)")
- I +$G(DIERR) D
- .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
- E D
- .S ERROR=""
- ;
- I $S(+$G(DIERR):0,1:1) D CLEAN^DILF Q 1
- E D CLEAN^DILF Q 0
- ;
- ADD(FILE,DGENDA,DATA,ERROR,IEN) ;
- ;Description: Creates a new record and files the data.
- ; Input:
- ; FILE - File or sub-file number
- ; DGENDA - New name for traditional FileMan DA array with same
- ; meaning. Pass by reference. Only needed if adding to a
- ; subfile.
- ; DATA - Data array to file, pass by reference
- ; Format: DATA(<field #>)=<value>
- ; IEN - internal entry number to use (optional)
- ;
- ; Output:
- ; Function Value - If no error then it returns the ien of the created record, else returns NULL.
- ; DGENDA - returns the ien of the new record, NULL if none created. If needed, pass by reference.
- ; ERROR - optional error message - if needed, pass by reference
- ;
- ; Example: To add a record in subfile 2.0361 in the record with ien=353
- ; with the field .01 value = 21:
- ; S DATA(.01)=21,DGENDA(1)=353 I $$ADD^DGENDBS(2.0361,.DGENDA,.DATA) W !,"DONE"
- ;
- ; Example: If creating a record not in a subfile, would look like this:
- ; S DATA(.01)=21 I $$ADD^DGENDBS(867,,.DATA) W !,"DONE"
- ;
- N FDA,FIELD,IENA,IENS,ERRORS
- ;
- ;IENS - Internal Entry Number String defined by FM
- ;IENA - the Internal Entry Numebr Array defined by FM
- ;FDA - the FDA array defined by FM
- ;IEN - the ien of the new record
- ;
- S DGENDA="+1"
- S IENS=$$IENS^DILF(.DGENDA)
- S FIELD=0
- F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
- .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
- I $G(IEN) S IENA(1)=IEN
- D UPDATE^DIE("","FDA","IENA","ERRORS(1)")
- I +$G(DIERR) D
- .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
- .S IEN=""
- E D
- .S IEN=IENA(1)
- .S ERROR=""
- D CLEAN^DILF
- S DGENDA=IEN
- Q IEN
- ;
- TESTVAL(FILE,FIELD,VALUE) ;
- ;Description: returns 1 if VALUE is a valid value for FIELD in FILE
- ;
- Q:(('$G(FILE))!('$G(FIELD))) 0
- ;
- N DISPLAY,VALID,RESULT
- S VALID=1
- ;
- ;if there is no external value then it is not valid
- S DISPLAY=$$EXTERNAL^DILFD(FILE,FIELD,"F",VALUE)
- I (DISPLAY="") S VALID=0
- ;
- I VALID,$$GET1^DID(FILE,FIELD,"","TYPE")'["POINTER" D
- .D CHK^DIE(FILE,FIELD,,VALUE,.RESULT) I RESULT="^" S VALID=0 Q
- Q VALID
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGENDBS 3574 printed Jan 18, 2025@03:43:16 Page 2
- DGENDBS ;ALB/RMO/CJM,JAM - Database Server Utilities; [ 03/23/95 11:08 AM ]
- +1 ;;5.3;Registration;**122,147,182,1040**;08/13/93;Build 15
- +2 ;
- UPD(FILE,DGENDA,DATA,ERROR) ;File data into an existing record.
- +1 ; Input:
- +2 ; FILE - File or sub-file number
- +3 ; DGENDA - New name for traditional DA array, with same meaning.
- +4 ; Pass by reference.
- +5 ; DATA - Data array to file (pass by reference)
- +6 ; Format: DATA(<field #>)=<value>
- +7 ;
- +8 ; Output:
- +9 ; Function Value - 0=error and 1=no error
- +10 ; ERROR - optional error message - if needed, pass by reference
- +11 ;
- +12 ; Example: To update a record in subfile 2.0361 in record with ien=353,
- +13 ; subrecord ien=68, with the field .01 value = 21:
- +14 ; S DATA(.01)=21,DGENDA=68,DGENDA(1)=353 I $$UPD^DGENDBS(2.0361,.DGENDA,.DATA,.ERROR) W !,"DONE"
- +15 ;
- +16 ; DG*5,3*1040;jam; Add New of DTOUT to protect it from FILE^DIE which will kill this variable.
- +17 NEW FDA,FIELD,IENS,ERRORS,DTOUT
- +18 ;
- +19 ;IENS - Internal Entry Number String defined by FM
- +20 ;FDA - the FDA array as defined by FM
- +21 ;
- +22 IF '$GET(DGENDA)
- SET ERROR="IEN OF RECORD TO BE UPDATED NOT SPECIFIED"
- QUIT 0
- +23 SET IENS=$$IENS^DILF(.DGENDA)
- +24 SET FIELD=0
- +25 FOR
- SET FIELD=$ORDER(DATA(FIELD))
- if 'FIELD
- QUIT
- Begin DoDot:1
- +26 SET FDA(FILE,IENS,FIELD)=$GET(DATA(FIELD))
- End DoDot:1
- +27 DO FILE^DIE("K","FDA","ERRORS(1)")
- +28 IF +$GET(DIERR)
- Begin DoDot:1
- +29 SET ERROR=$GET(ERRORS(1,"DIERR",1,"TEXT",1))
- End DoDot:1
- +30 IF '$TEST
- Begin DoDot:1
- +31 SET ERROR=""
- End DoDot:1
- +32 ;
- +33 IF $SELECT(+$GET(DIERR):0,1:1)
- DO CLEAN^DILF
- QUIT 1
- +34 IF '$TEST
- DO CLEAN^DILF
- QUIT 0
- +35 ;
- ADD(FILE,DGENDA,DATA,ERROR,IEN) ;
- +1 ;Description: Creates a new record and files the data.
- +2 ; Input:
- +3 ; FILE - File or sub-file number
- +4 ; DGENDA - New name for traditional FileMan DA array with same
- +5 ; meaning. Pass by reference. Only needed if adding to a
- +6 ; subfile.
- +7 ; DATA - Data array to file, pass by reference
- +8 ; Format: DATA(<field #>)=<value>
- +9 ; IEN - internal entry number to use (optional)
- +10 ;
- +11 ; Output:
- +12 ; Function Value - If no error then it returns the ien of the created record, else returns NULL.
- +13 ; DGENDA - returns the ien of the new record, NULL if none created. If needed, pass by reference.
- +14 ; ERROR - optional error message - if needed, pass by reference
- +15 ;
- +16 ; Example: To add a record in subfile 2.0361 in the record with ien=353
- +17 ; with the field .01 value = 21:
- +18 ; S DATA(.01)=21,DGENDA(1)=353 I $$ADD^DGENDBS(2.0361,.DGENDA,.DATA) W !,"DONE"
- +19 ;
- +20 ; Example: If creating a record not in a subfile, would look like this:
- +21 ; S DATA(.01)=21 I $$ADD^DGENDBS(867,,.DATA) W !,"DONE"
- +22 ;
- +23 NEW FDA,FIELD,IENA,IENS,ERRORS
- +24 ;
- +25 ;IENS - Internal Entry Number String defined by FM
- +26 ;IENA - the Internal Entry Numebr Array defined by FM
- +27 ;FDA - the FDA array defined by FM
- +28 ;IEN - the ien of the new record
- +29 ;
- +30 SET DGENDA="+1"
- +31 SET IENS=$$IENS^DILF(.DGENDA)
- +32 SET FIELD=0
- +33 FOR
- SET FIELD=$ORDER(DATA(FIELD))
- if 'FIELD
- QUIT
- Begin DoDot:1
- +34 SET FDA(FILE,IENS,FIELD)=$GET(DATA(FIELD))
- End DoDot:1
- +35 IF $GET(IEN)
- SET IENA(1)=IEN
- +36 DO UPDATE^DIE("","FDA","IENA","ERRORS(1)")
- +37 IF +$GET(DIERR)
- Begin DoDot:1
- +38 SET ERROR=$GET(ERRORS(1,"DIERR",1,"TEXT",1))
- +39 SET IEN=""
- End DoDot:1
- +40 IF '$TEST
- Begin DoDot:1
- +41 SET IEN=IENA(1)
- +42 SET ERROR=""
- End DoDot:1
- +43 DO CLEAN^DILF
- +44 SET DGENDA=IEN
- +45 QUIT IEN
- +46 ;
- TESTVAL(FILE,FIELD,VALUE) ;
- +1 ;Description: returns 1 if VALUE is a valid value for FIELD in FILE
- +2 ;
- +3 if (('$GET(FILE))!('$GET(FIELD)))
- QUIT 0
- +4 ;
- +5 NEW DISPLAY,VALID,RESULT
- +6 SET VALID=1
- +7 ;
- +8 ;if there is no external value then it is not valid
- +9 SET DISPLAY=$$EXTERNAL^DILFD(FILE,FIELD,"F",VALUE)
- +10 IF (DISPLAY="")
- SET VALID=0
- +11 ;
- +12 IF VALID
- IF $$GET1^DID(FILE,FIELD,"","TYPE")'["POINTER"
- Begin DoDot:1
- +13 DO CHK^DIE(FILE,FIELD,,VALUE,.RESULT)
- IF RESULT="^"
- SET VALID=0
- QUIT
- End DoDot:1
- +14 QUIT VALID