Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
running a script in a function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Guillaume
le 22 Jan 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 commentaire
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!