Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
running a script in a function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
fsw = System.IO.FileSystemWatcher();
fsw.Path = 'C:\Users\wolfgang';
fsw.Filter = 'test.csv';
fsw.EnableRaisingEvents = true;
listenerhandle = addlistener(fsw, 'Changed', @(~,~)testing1234(q,a));
%signature of importfcn is function importfcn(sender, eventargs)
%add a small delay in importfcn before reading the file as the event is raised
%to make sure that file modification is complete
I have saved the above code as the function systemwatch.
When I type in systemwatch manually in the command window then it gets executed without trouble. However, when I run this script systemwatch in another function then it does not get executed somehow. Can anyone explain this and tell me how to fix this please??
function if
if rowsOfMaxes<3 || rowsOfmin<3
systemwatch;
end
end
Basically, before i start the function, there is already an active listenerhandle and systemwatch running. The function has a condition and if the condition is met then I want certain parameters of the listenerhandle or systemwatch file to change.
I want this line
listenerhandle = addlistener(fsw, 'Changed', @(~,~)testing123(q,a));
to change to this
listenerhandle = addlistener(fsw, 'Changed', @(~,~)testing1234(q,a));
and I want this line
fsw.Filter = 'coke.csv';
to change to this
fsw.Filter = 'test.csv';
thanks
0 comentarios
Respuestas (1)
Guillaume
el 22 de En. de 2015
I would create the listener before enabling the FileSystemWatcher events.
Is this the exact code that is in the file systemwatch.m? Without any function prototype? If that is the case, then systemwatch.m is a script not a function. Possibly it doesn't work in a function because the listenerhandle goes out of scope.
Also shouldn't the code for listenerhandle be:
listenerhandle = addlistener(fsw, 'Changed', @(q,a) testing1234(q,a));
1 comentario
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!