Mercurial > octave
annotate scripts/plot/util/private/__gnuplot_open_stream__.m @ 23219:3ac9f9ecfae5 stable
maint: Update copyright dates.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Feb 2017 12:39:29 -0500 |
parents | e9a0469dedd9 |
children | 092078913d54 |
rev | line source |
---|---|
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
1 ## Copyright (C) 2009-2017 Ben Abbott |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
11104 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
20 ## @deftypefn {} {@var{stream} =} __gnuplot_open_stream__ (@var{npipes}, @var{h}) |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## @end deftypefn |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
23 |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
24 ## Author: Ben Abbott <bpabbott@mac.com> |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
25 ## Created: 2009-04-11 |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
26 |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
27 function plot_stream = __gnuplot_open_stream__ (npipes, h) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
28 |
9461
ff8d7f3ad203
gnuplot_binary.m: accept arguments in addition to program name
John W. Eaton <jwe@octave.org>
parents:
9113
diff
changeset
|
29 [prog, args] = gnuplot_binary (); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
30 |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
31 if (npipes > 1) |
9461
ff8d7f3ad203
gnuplot_binary.m: accept arguments in addition to program name
John W. Eaton <jwe@octave.org>
parents:
9113
diff
changeset
|
32 [plot_stream(1), plot_stream(2), pid] = popen2 (prog, args{:}); |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
33 if (pid < 0) |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
34 error ("__gnuplot_open_stream__: failed to open connection to gnuplot"); |
9561
c60a9e1a0372
try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents:
9461
diff
changeset
|
35 else |
c60a9e1a0372
try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents:
9461
diff
changeset
|
36 plot_stream(3) = pid; |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
37 endif |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
38 else |
9461
ff8d7f3ad203
gnuplot_binary.m: accept arguments in addition to program name
John W. Eaton <jwe@octave.org>
parents:
9113
diff
changeset
|
39 plot_stream = popen (sprintf ("%s ", prog, args{:}), "w"); |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
40 if (plot_stream < 0) |
11588
d5bd2766c640
style fixes for warning and error messages in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
41 error ("__gnuplot_open_stream__: failed to open connection to gnuplot"); |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
42 endif |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
43 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
44 |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
45 if (nargin > 1) |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
46 set (h, "__plot_stream__", plot_stream); |
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
47 endif |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
48 |
9113
4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
49 endfunction |