function waitonlock(filename)
%WAITONLOCK - wait for a file
%
%   This routine will return when a file named 'filename' is written to disk.
%
%   Usage:
%      waitonlock(filename)

test=0;
disp(['waiting for ' filename ' hold on... (Ctrl+C to exit)'])
while test==0
	test=exist(filename,'file');
	pause(1)
end
