Re: OpenQM trigger question -
08-13-2005
, 09:17 AM
Hello again pi3k,
Try the code below. Disclaimer: *NOT* thoroughly tested.
To answer your question, two things:
1. You forgot to pass the file handle.
2. From the file handle, much info is available through FILEINFO()
Some changes in the below code not relating to your question:
1. If creating a new item, no logging would occur. You may have planned
this.
2. I added LOWER() assuming that you wanted a record of changes, the
way it was, a dictionary item for instance would overwrite the
audit item's attributes.
3. I didn't address adding text for Delete, just the mode.
*** Begin test code:
SUBROUTINE WRITE.TRIGGER( MODE, ID, ITEM, ON.ERROR, FH)
$INCLUDE KEYS.H
**VARS FOR TESTING
* FILENAME = "CODES" ;*HOW DO YOU GET THIS?
* Try this:
FILENAME = FILEINFO(FH, FL$VOCNAME)
PATH = FILEINFO(FH, FL$PATH) ;* Make sure you pick up the DICT
**
OPEN "AUDITTRAIL" TO AUDIT.F ELSE ABORT "CANNOT OPEN AUDITFILE"
OPENPATH PATH TO FILE.F ELSE ABORT "CANNOT OPEN " : FILENAME
READ ENTRY FROM FILE.F, ID THEN ;* Modifying or Deleting existing
OLD.ITEM = LOWER(ENTRY) ;* Make it fit in one attribute
ELSE ;* Must be a new item
OLD.ITEM = "New Item Added"
END
NAME = FILENAME : "*" : ID : "*" : DATE() : "*" : TIME()
WRITEV "MODE: " : MODE TO AUDIT.F, NAME, 1
WRITEV "OLD ITEM: " : OLD.ITEM TO AUDIT.F, NAME, 2
WRITEV "NEW ITEM: " : LOWER(ITEM) TO AUDIT.F, NAME, 3
WRITEV @LOGNAME TO AUDIT.F, NAME, 4
END |