Home > functions > internal > dsGetConfig.m

dsGetConfig

PURPOSE ^

GETCONFIG - returns the value of the variable specificed as string in argument

SYNOPSIS ^

function varOutput = dsGetConfig(query)

DESCRIPTION ^

 GETCONFIG - returns the value of the variable specificed as string in argument

 Usage: pathOutput = getConfig(pathQueryString)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varOutput = dsGetConfig(query)
0002 % GETCONFIG - returns the value of the variable specificed as string in argument
0003 %
0004 % Usage: pathOutput = getConfig(pathQueryString)
0005 
0006   dsVarsFile = fullfile(dsGetRootPath(),'dsConfig.txt');
0007 
0008   if ~exist(dsVarsFile, 'file')
0009     dsMakeDefaultConfig(); % bring all path vars into namespace
0010   end
0011   
0012   fid = fopen(dsVarsFile);
0013   dsVars = textscan(fid, '%s = %q');
0014   fclose(fid);
0015   
0016   varCell = dsVars{2}(~cellfun(@isempty,strfind(dsVars{1}, query)));
0017   
0018   if ~isempty(varCell)
0019     varOutput = varCell{1}; % eval variable string as variable
0020   else
0021     varOutput = [];
0022     if isempty(varOutput); warning('Requested path not found. dsConfig.txt is possibly corrupt. Try deleting dsConfig.txt and running dsMakeDefaultConfig()');
0023   end
0024     
0025 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005