PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → fTrackDirectory - 5 files
fTrackDirectory - 5 files
Iniciado por guest, 07,abr. 2015 14:16 - 1 respuesta
Publicado el 07,abril 2015 - 14:16
Hey,

I'm tracking a folder with fTrackDirectory with 2 sub dirs.
As expected when I add a file in one of the folders a procedure will run.
The odd thing is, when I add 5 files or more my service stops working.
I don't get any errors and the procedure is only run once.

The remarks on this function tells that only 5 directories can be tracked.
But I'm talking about files, not dirs so is the documentation wrong or am I doing something wrong?

fTrackDirectory(gsTrackFolder,handleNewFile,ftCreateFile+ftRename,True)
PROCEDURE handleNewFile(LOCAL sFileDir is string, LOCAL sFileName is string, nAction is int, sFormerFileName is string) LOCAL nNewSubscript is int = ArrayCount(garrFileList)+1 // Manual rename for retry, should be noticed IF nAction = ftRename THEN IF sFormerFileName = sFileName THEN ServiceWriteEventLog("Retry handle file, name change with no change.",elInformation) ELSE ServiceWriteEventLog("Retry handle file, name changed old name: "+sFormerFileName+" new name: "+sFileName,elInformation) END END // Finding the type and create the right class SWITCH Lower(ExtractString(sFileName,1,"\",FromBeginning)) CASE "ags" ArrayAdd(garrFileList, new AgsMessage(sFileDir+["\"]+sFileName, nNewSubscript)) ArrayDelete(garrFileList,nNewSubscript) CASE "sagitta" ArrayAdd(garrFileList, new SagittaMessage(sFileDir+["\"]+sFileName, nNewSubscript)) ArrayDelete(garrFileList,nNewSubscript) CASE "emcs" ArrayAdd(garrFileList, new EmcsMessage(sFileDir+["\"]+sFileName, nNewSubscript)) ArrayDelete(garrFileList,nNewSubscript) OTHER CASE ServiceWriteEventLog("Unknown file, can't parse... Moving file to safe location..."+RC+Lower(ExtractString(sFileDir,1,"\",FromEnd)) + " - " + sFileName, elWarning) fMoveFile(sFileDir+["\"]+sFileName, gsSaveLocation+["\"]+sFileName) END
Please don't mind the arraycount stuff, I know it's `wrong` but it isn't the problem for sure.

Thanks in advance,
David
Publicado el 07,abril 2015 - 15:02
Hi David

Maybe yo have a speed problem... If you create 5 files very rapidly, your process is going to be called 5 times as fast as the files are created...

If you did not code your process to accept that, then you may just be crashing because of it...

So, what I would do in a case like this one is:
- in the procedure called by ftrack... I would ADD the file information in an array
- in a process called in a loop/timer, I would process the content of the array

To test if my hypothesis is correct, comment out ALL the code in the procedure called when a file is tracked ans just trace its information in a file... if you have all of them, then you may want to reorganize things

Best regards