function existPlatform( hMainFig ) % existPlatform( hMainFig ) % if tsg_platform.csv exist, add entry for platform information % if not, create default tsg_platform.csv % % $Id$ 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 if str2double(match{1}{1}) ~= VERSION 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 = %6.4f\n', ... VERSION); fprintf( fid, '%%\n%%\n'); fprintf( fid, 'id;PLATFORM_NAME;SHIP_CALL_SIGN;SHIP_MMSI;PROJECT_NAME;TYPE_TSG;NUMBER_TSG;TYPE_TINT;NUMBER_TINT;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;char;integer;integer;float;float;float;float;float;float;float \n'); fclose( fid ); % Refresh function and file system caches % --------------------------------------- rehash; end end