Tehnical information

From Mslice
Revision as of 09:04, 31 March 2011 by Alex Buts (talk | contribs) (Created page with "== 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 ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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                      

</syntaxhighlight>