Difference between revisions of "Tehnical information"

From Mslice
Jump to navigationJump to search
Line 56: Line 56:
 
                 end
 
                 end
 
                    
 
                    
             end                    
+
             end        
 +
 
 +
          % replace sting in old msp file with its new equivalents
 +
 
 +
          if ~isempty(modificators)&&(~is_read_only)
 +
          for i=1:floor(nmodific/2)
 +
            perl('set_key_value.pl',fullname,modificators{2*i-1},modificators{2*i});     
 +
          end
 +
      end
 +
           
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 10:20, 31 March 2011

File location for spe and phx files

Old Mslice kept its whole configuration in msp files. All information a user can see in a Mslice window is stored in an ASCII msp file in a form key = value pairs, where each key corresponds to some visible or invisible field in Mslice GUI. To save whatever you entered into GUI or load your previous data you have to save/load some msp file.

The disadvantage of this approach is that you always have to start you work loading msp file and if you move msp file between two machines, the paths to data files stored in the msp file will probably be wrong. This is why recent Mslice keeps information about its recently used msp file and paths to data files in configuration (see config). When choosing between different paths stored in msp, an arbitration occurs, and the code, which makes the selection located in ms_load_msp.m procedure.

The code, which makes selection is currently as follows:


<syntaxhighlight lang="MATLAB M">

      if isfield(msl_conf,field) 
           % this is a path which may be specified either in the file
           % itself, or in configuration; Arbitration would occur. 
           if (strcmp(field,'MspDir')||strcmp(field,'MspFile')) % if it is MspDir or MspFile, then it has been set already
               if strcmp(field,'MspFile') && ~strcmp(value,file_name) % but the msp file name in defined in the file is different from the filename itself
                   % need to fix it;
                     nmodific =nmodific+1;
                     modificators{nmodific}='MspFile';
                     nmodific =nmodific+1;
                     modificators{nmodific}=file_name;                    
               end      
           elseif strncmp(value,'$.',2) % this is probably relative path to a sample data and the field is read only
              full_dir=fullfile(get(mslice_config,'MspDir'),value(4:length(value)));
              set(mslice_config,field,full_dir);               
              is_read_only=true;
           elseif strncmp(value,'.',1) % this is probably relative path to a sample data below
              full_dir=fullfile(get(mslice_config,'MspDir'),value(3:length(value)));
              if exist(full_dir,'dir')
                   set(mslice_config,field,full_dir);
              else
                  full_dir=get(mslice_config,field);
                  msp_dir =get(mslice_config,'MspDir');
                  short_dir=strrep(full_dir,msp_dir,'./');
                  nmodific =nmodific+1;
                  modificators{nmodific}=field;
                  nmodific =nmodific+1;
                  modificators{nmodific}=short_dir;                
              end
           else
               if exist(value,'dir') % the path is specified by sting in the file;
                   set(mslice_config,field,value);
               else % the path should be y specified by config variables
                  path=get(mslice_config,field);
                  msp_dir =get(mslice_config,'MspDir');
                  path  =strrep(path,msp_dir,'./');
                 
                  nmodific =nmodific+1;
                  modificators{nmodific}=field;
                  nmodific =nmodific+1;
                  modificators{nmodific}=path;
               end
                 
           end         
         % replace sting in old msp file with its new equivalents
         if ~isempty(modificators)&&(~is_read_only)
         for i=1:floor(nmodific/2)
            perl('set_key_value.pl',fullname,modificators{2*i-1},modificators{2*i});       
         end
     end
            

</syntaxhighlight>