Previous Thread
Next Thread
Print Thread
MX_FILEHOOK - pre'rec (Old Previous data) #36888 21 Dec 23 10:34 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Morning,
I been trying to trace and explain some data changes for a customer in their over night procedures, unlike Jorge im not usually awake at 3am to watch and put traces in a dozen routines so I decided to try to be clever and use our hook subroutine (MX_FILEHOOK) and output to an ascii/log of new and old data when a certain data files record is changed, then I can get up in the morning and casually take a look at the log over the morning grog.

Fantastic I thought, works so well with one small SBX change that logs every program that updates the data file records, This works fine about 95% time but I have noticed a couple of programs that do not pass the pre'rec (old / before overwritten).

So after going around in circles for while and comparing programs that work (have pre-rec populated) and those that dont I think I came to the following conclusion:

and its very old code that works a bit like this where its reading a record, then header record 1 and then writing back the original record:

Code
	! Example - KWOMORD is the record number and FWOMORD is the channel
	!
	! Read record 
 	KWOMORD=25 : READ #FWOMORD,WOMORD   !  Record 25 is just a random example)
	! do some stuff.. 
	! Then temporary store record number in the middle of changing.
 	SAV'PTR=KWOMORD
	! Read file header record
 	KWOMORD=1
	READ #FWOMORD,WOMORD'HEADER  
 	WOMORD'REQ'NO=LST'WOMORD'REQ'NO USING "#ZZZZZ"
	! Write file header record
	WRITE #FWOMORD,WOMORD'HEADER
	! Set record pointer KWOMORD back to original record 
 	KWOMORD=SAV'PTR
	! Write back changes
 	WRITE #FWOMORD,WOMORD


I hope that makes sense?


Enabling hooks code is:
Code
   	      hookop = HOOKOP_ADD             ! add a new hook
	      !hookproc$  = "SBX:MFHOOK"      ! Hook is handled by MFHOOK.SBX
	      hookevents = HFE_POST_WRITE or HFE_POST_WRITEL  
	      hook'id    =  XX
	      hookflags = HFF_PROG or HFF_SBX or HFF_RECNO or HFF_TIME or HFF_DATE  &
	      or HFF_USER or HFF_DATA or HFF_DATA_WAS or HFF_DATA_CHG_ONLY
	      XCALL MIAMEX, MX_FILEHOOK,hookop,status,hookdatafile,hook'id, &
	          hookproc$,hookevents,hookflags


and I just use the pre and pre'rec in the calling MFHOOK.SBX thats execute on program writes etc.
Code
    xgetargs status,hookenv,rec,pre'rec


Im testing and seeing this under my 7.0.1752.0/64 (Not tried it on Customer yet who has 6.5.1643.0)

I guess I can kind see why it no longer knows the pre-rec unless the READ for the record precedes the WRITE?

Anyway, so far as the logs is just for me I think we can work around the data i need but good to have confirmation that my conclusion is in the right area...






Last edited by Steve - Caliq; 21 Dec 23 02:59 PM.
Re: MX_FILEHOOK - pre'rec (Old Previous data) [Re: Steve - Caliq] #36900 21 Dec 23 05:42 PM
Joined: Jun 2001
Posts: 3,376
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,376
Now you know it's better to stay awake whistle


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal

Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3