## Copyright (C) 2005 Petr Mikulik ## ## This program is free software; it is distributed in the hope that it ## will be useful, but WITHOUT ANY WARRANTY; without even the implied ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ## the GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file; see the file COPYING. If not, write to the ## Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## usage: p = gget2(option) ## ## returns gnuplot's parameter setting of the given option. ## Author: Petr Mikulik function p = gget2(option) tmpName = tmpnam(); [err, msg] = mkfifo(tmpName, 6*8*8) % 6*8*8 % 0600 if err < 0 % cannot write to the temporary file p = []; return end graw(['save set "', tmpName, '";\n']); % save all "save set" into a temporary fifo file f = fopen(tmpName,'r'); if f==-1 % cannot write to the temporary file p = []; return end p=' '; [p, count] = fscanf(f,'%c'); % read the whole "save set" file at once what = strcat('set ', option, ' '); % construct the search string i = index(p, what); % find that string if i <= 0 p=[]; return end p = p(i:end); i = index(p, '\n'); p = p(length(what)+1:i-1); % printf('result is |%s|\n', p); fclose(f); unlink(tmpName); return endfunction