*!* Local oLog As oLog Of iLog.prg *!* oLog = Newobject("oLog") *!* lnTime = Datetime() *!* oLog.icLog = "C:\log_prueba.txt" *!* oLog.agregar("Inicio del log","*Inicio*") *!* lnCont = 0 *!* For lnCiclo = 1 To 10000 *!* If lnCont >= 7 *!* If Mod(lnCiclo,3)!=0 *!* oLog.agregar("Ocurrió un error interno #"+Transform(lnCiclo),"Error") *!* lnCont = 0 *!* Else *!* oLog.agregar("Evento Procesado" +[# ]+Alltrim(Transform(lnCiclo)),"Proceso") *!* Endif *!* Else *!* oLog.agregar("Nuevo evento" +[# ]+Alltrim(Transform(lnCiclo)),"Evento") *!* Endif *!* lnCont = lnCont + 1 *!* Wait Window trans((lnCiclo/10000) * 100,[###])+[%] Nowait *!* Endfor *!* oLog.agregar("Final del log","*Fin*",.T.) *!* Messagebox([Tiempo utilizado para registrar 10,000 eventos: ]+ Transform(Datetime()-lnTime) + [ segs.]) Define Class oLog As Custom icLog = [_]+Sys(2015)+[_Log.txt] oData = Null Procedure Init #If .F. Local This As oLog Of iLog.prg #Endif Endproc Procedure icLog_Assign(luNewVal) If !(m.luNewVal==This.icLog) This.oData = Newobject([Collection]) Endif This.icLog = luNewVal Endproc Procedure agregar(cCadena As String,cTipo As String, lFinal As Boolean) As Boolean oDatos = Newobject([empty]) AddProperty(oDatos,[cInfo],Chrtran(cCadena,[|],Chr(13)+Chr(10)+Chr(9))) AddProperty(oDatos,[cTipo],cTipo) AddProperty(oDatos,[cHora],Datetime()) This.oData.Add(oDatos) If lFinal Return This.GenerarLog() Endif Endproc Procedure GenerarLog() lnSelect = Select() Use In Select([Conteo]) Create Cursor Conteo (qTipo c(230),Cantidad i) Select Conteo Index On Alltrim(Upper(qTipo)) Tag cdxTipo Set Order To cdxTipo In Conteo Set Textmerge On To (This.icLog) Noshow For Each loCol In This.oData If !Seek(Alltrim(Upper(loCol.cTipo)),[Conteo],[cdxtipo]) Insert Into Conteo Values(loCol.cTipo,1) Else Update Conteo Set Cantidad = Cantidad +1 Where Alltrim(Upper(qTipo))==Alltrim(Upper(loCol.cTipo)) Endif \<>| <>: <> Endfor Set Textmerge To Select Conteo lcTit =[*Eventos registrados *] lcCad= Chr(13)+Chr(10) Scan For !([*] $ qTipo) lcCad =lcCad+Alltrim(Conteo.qTipo)+[: ]+Alltrim(Transform(Conteo.Cantidad))+Chr(13)+Chr(10) Endscan Strtofile(lcTit+lcCad+Filetostr(This.icLog),This.icLog,0) If Used(lnSelect) Select(lnSelect) Endif Endproc Enddefine