Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

function deletewaitbars(messageString)
% removes the waitbar if it got used

% checks the number of arguments
error(nargchk(0, 1, nargin))

% if the messageString got supplied, it must a string (no support for cell
% arrays of strings yet)
if nargin >= 1 && ~isstring(messageString)
    % errors
    error('Message string to match must be a string.')

% looks for all of the waitbars
waitbars = findall(0, 'Tag', 'TMWWaitbar', 'Type', 'figure');

% if there is only waitbar, or no messageString to match it with, easy to deal with
if numel(waitbars) == 1 || ~nargin
    % simply close it/them all
elseif numel(waitbars) > 1
    % looks for the text objects that are children
    textObjects = findall(waitbars, 'Type', 'text');

    % finds the text objects which contain the text '(readtext)'
    index = ~cellfun('isempty', strfind(get(textObjects, 'String'), messageString));
    % providing something was found
    if any(index)
        % narrows it down
        textObjects = textObjects(index);
        % initialises the parents for the loop
        parents = textObjects;
        % loops round twice (once to get the axes, then once again to get
        % the figures)
        for m = 1:2
            % gets the parents (the axes)
            parents = get(parents, 'Parent');

            % if theres more than 1, its a cell array, so convert it into a
            % normal array
            if iscell(parents)
                % convert it
                parents = cell2mat(parents);
        % closes them

Contact us