Changes examples/*/x14*.* to call plgdev and print the driver name after
calling plinit. Calling plgdev after plparseopts but before plinit will
only get a device name if one is specified on the command line via the
-dev option. If the device is not specified via -dev, calling plgdev
before plinit will get an empty string. To ensure that plgdev gets a
device name regardless of how it is specified, it must be called after
plinit (specifically, after pllib_devinit, which is called by plinit).
Without this change, running example 14 with no device specified on the
command line would result in the following message...
"Demo of multiple output streams via the driver."
Note the double space between "the" and "driver" where the driver name
belongs.
Also removes previously superfluous, now invalid call to plsdev before
plinit.
Tested C++, C, F77, and F95 versions. Not sure if other languages are
modified correctly.
---
examples/c++/x14.cc| 17 -
examples/c/x14c.c | 17 -
examples/d/x14d.d | 21 ++---
examples/f77/x14f.fm4 | 25 -
examples/f95/x14f.f90 | 25 -
examples/java/x14.java | 19 +--
examples/lua/x14.lua | 13 ++---
examples/ocaml/x14.ml | 15 +++
examples/octave/x14c.m | 25 -
examples/perl/x14.pl | 15 +++
examples/tcl/x14.tcl | 13 ++---
11 files changed, 97 insertions(+), 108 deletions(-)
diff --git a/examples/c++/x14.cc b/examples/c++/x14.cc
index 80569ad..54759c8 100644
--- a/examples/c++/x14.cc
+++ b/examples/c++/x14.cc
@@ -92,7 +92,7 @@ x14::x14( int argc, const char ** argv )
// Using DP results in a crash at the end due to some odd cleanup problems
// The geometry strings MUST be in writable memory
-char driver[80];
+char driver[80] = "";
PLINT fam, num, bmax;
@@ -110,13 +110,6 @@ x14::x14( int argc, const char ** argv )
// Parse and process command line arguments.
pls1->parseopts( &argc, argv, PL_PARSE_FULL );
-pls1->gdev( driver );
-pls1->gfam( fam, num, bmax );
-
-cout << "Demo of multiple output streams via the " <<
-driver << " driver." << endl;
-cout << "Running with the second stream as slave to the first.\n" << endl;
-
//If valid geometry specified on command line, use it for both streams.
pls1->gpage( xp0, yp0, xleng0, yleng0, xoff0, yoff0 );
valid_geometry = ( xleng0 > 0 && yleng0 > 0 );
@@ -128,12 +121,18 @@ x14::x14( int argc, const char ** argv )
else
pls1->setopt( "geometry", geometry_master );
-pls1->sdev( driver );
pls1->ssub( 2, 2 );
// Initialize PLplot.
pls1->init();
+pls1->gdev( driver );
+pls1->gfam( fam, num, bmax );
+
+cout << "Demo of multiple output streams via the " <<
+driver << " driver." << endl;
+cout << "Running with the second stream as slave to the first.\n" << endl;
+
pls2 = new plstream();
if ( valid_geometry )
diff --git a/examples/c/x14c.c b/examples/c/x14c.c
index 22e38ba..ace4aa4 100644
--- a/examples/c/x14c.c
+++ b/examples/c/x14c.c
@@ -58,7 +58,7 @@ main( int argc, const char *argv[] )
char geometry_master[] = "500x410+100+200";
char geometry_slave[] = "500x410+650+200";
-char driver[80];
+char driver[80] = "";
PLINT fam, num, bmax;
PLFLT xp0, yp0;
@@ -70,13 +70,6 @@ main( int argc, const char *argv[] )
(void) plparseopts( &argc, argv, PL_PARSE_FULL );
-plgdev( driver );
-plgfam( &fam, &num, &bmax );
-
-printf( "Demo of multiple output streams via the %s driver.\n", driver );
-printf( "Running with the second stream as slave to the first.\n" );
-printf( "\n" );
-
/* If valid geometry specified on command line, use it for both streams. */
plgpage( &xp0, &yp0, &xleng0, &yleng0, &xoff0, &yoff0 );
valid_geometry = ( xleng0 > 0 && yleng0 > 0 );
@@ -88,10 +81,16 @@ main( int argc, const char *argv[] )
else
plsetopt( "geometry", geometry_master );
-plsdev( driver );
plssub( 2, 2 );
plinit();
+plgdev( driver );
+plgfam( &fam, &num, &bmax );
+
+printf( "Demo of multiple output streams via the %s driver.\n", driver );
+printf( "Running with the second stream as slave to the first.\n" );
+printf( "\n" );
+
/* Start next stream */
plsstrm( 1 );
diff --git a/examples/d/x14d.d b/examples/d/x14d.d
index 41fe5bb..0782f90 100644
--- a/examples/d/x14d.d
+++ b/examples/d/x14d.d
@@ -51,15 +51,6 @@ int main( char[][] args )
/* Parse and process command line arguments */
plparseopts( args, PL_PARSE_FULL );
-string driver;
-plgdev( driver );
-
-PLINT fam, num, bmax;
-plgfam( &fam, &num, &bmax );
-
-writefln( "Demo of multiple output streams via the %s driver.", driver );
-writefln( "Running with the second stream as