0001 function newStr = reformat_matlab_call(origStr, swap)
0002
0003
0004
0005
0006
0007
0008 tokens = regexp(origStr,'\''(\w+)\''','tokens');
0009 tokens = [tokens{:}];
0010 pv_pairs = reshape(tokens,2,length(tokens)/2)';
0011
0012
0013
0014 param_str = '';
0015 for iparam = 1:size(pv_pairs,1)
0016 currParam = pv_pairs{iparam,1};
0017 switch currParam
0018 case {'params','return_type'}
0019 param_str = [param_str sprintf('''%s'',''%s''', currParam, pv_pairs{iparam,2})];
0020 case 'formid'
0021 param_str = [param_str sprintf('''%s'', %d', currParam, swap.form_id)];
0022 case 'subid'
0023 param_str = [param_str sprintf('''%s'', ''%s''', currParam, swap.subject_id)];
0024 case 'sessid'
0025 param_str = [param_str sprintf('''%s'', %d', currParam, swap.session_id)];
0026 case 'lastvisited'
0027 param_str = [param_str sprintf('''%s'', %d', currParam, swap.last_visited)];
0028 end
0029
0030
0031 if iparam < size(pv_pairs,1)
0032 param_str = [param_str ', '];
0033 end
0034 end
0035
0036
0037 newStr = cell2str([regexp(origStr,'^\w+(','match') param_str ');']);
0038
0039 return