function existPlatform( hMainFig ) global VERSION % Get the data from the application GUI % ------------------------------------- tsg = getappdata(hMainFig, 'tsg_data'); % get filename % ------------ filename = [tsg.DEFAULT_PATH_FILE '@tsg_nc' filesep 'tsg_platform.csv']; % check if filename exist and should be open in read mode % ------------------------------------------------------- fid = fopen(filename); if (fid ~= -1) % ------------- inputText = textscan(fid, '%s', 1, 'delimiter', '\n'); % use string instead cell % ----------------------- str = inputText{1}{1}; % if reach end of header % ---------------------- match = regexp( str, 'VERSION\s*=\s*(.*)', 'tokens'); % exit while loop if end of header % -------------------------------- if isempty(match) fclose(fid); create_platform_file; end else create_platform_file; end % create new file tsg_platform.csv. Variables SSPS_DEPH ... have changed % from integer to float since V1.0RC5 (VERSION = 0.905) % ---------------------------------------------------------------------- function create_platform_file() fid = fopen( filename, 'wt' ); fprintf( fid, '%% tsg_platform.csv: 14 members & 0 lines with data; VERSION = %5.3f\n', ... VERSION); fprintf( fid, '%% $Id$ \n'); fprintf( fid, '%% \n' ); fprintf( fid, 'id;PLATFORM_NAME;SHIP_CALL_SIGN;SHIP_MMSI;TSG_TYPE;TSG_NUMBER;TINT_TYPE;TINT_NUMBER;SAMPLING_PERIOD;SSPS_DEPH;SSPS_DEPH_MIN;SSPS_DEPH_MAX;SSTP_DEPH;SSTP_DEPH_MIN;SSTP_DEPH_MAX;DATE_TSG;endl \n'); fprintf( fid, 'char;char;char;char;char;char;char;char;integer;integer;float;float;float;float;float;float;float \n'); fclose( fid ); % Refresh function and file system caches % --------------------------------------- rehash; end end