LOCAL NRL,NRA,L,A,UZ,lnUzPrec
STORE 0 TO L,A,UZ,lnUzPrec
NRL=VAL(M.NL)
NRA=VAL(M.AN)

SELE XMF
SCAN FOR !casat AND codop <> 12   && necasate si neconservate
	lnUzPrec = uzuraprec
	if empty(datapif)
		do mesaj with 'Trebuie introdusa data punerii in functiune','la '+allt(denumire)
		*return
	ENDIF
	L=MONTH(DATAPIF)
	A=YEAR(DATAPIF)
	UZ=IIF(NRA<A,0,12*(NRA-A)+NRL-L)   &&  12*(an crt - an pif) + luna crt - luna pif
	
	if UZ=0 and lnUzPrec#0
		UZ=1
	ENDIF
	
	REPL UZURA WITH UZ+lnUzPrec
ENDSCAN