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 slave to the first.\n" ); - /* If valid geometry specified on command line, use it for both streams. */ PLFLT xp0, yp0; PLINT xleng0, yleng0, xoff0, yoff0; @@ -72,10 +63,18 @@ int main( char[][] args ) else plsetopt( "geometry", geometry_master ); - plsdev( driver ); plssub( 2, 2 ); plinit(); + 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 slave to the first.\n" ); + /* Start next stream */ plsstrm( 1 ); @@ -366,4 +365,4 @@ class plot { pllab( "X Coordinate", "Y Coordinate", "Streamlines of flow" ); plflush(); } -} \ No newline at end of file +} diff --git a/examples/f77/x14f.fm4 b/examples/f77/x14f.fm4 index b1eb15a..c873e17 100644 --- a/examples/f77/x14f.fm4 +++ b/examples/f77/x14f.fm4 @@ -54,18 +54,6 @@ c although this is not demanded on g77 it also works there. c Process command-line arguments call plparseopts(PL_PARSE_FULL) - call plgdev(driver) - call plgfam(fam,num,bmax) - - write(6,'(3A)') 'Demo of multiple output streams via the ', - & driver(:lnblnk(driver)), ' driver.' - write(6,'(A)') 'Running with the second stream as slave '// - & 'to the first.' - write(6,*) -c flush unit 6 so this part of stdout is guaranteed to be written prior -c to stdout generated by second plinit below. - call flush(6) - c If valid geometry specified on command line, use it for both streams. call plgpage(xp0, yp0, xleng0, yleng0, xoff0, yoff0) valid_geometry = (xleng0 .gt. 0 .and. yleng0 .gt. 0) @@ -78,10 +66,21 @@ c Set up first stream call plsetopt( 'geometry', geometry_master) endif - call plsdev(driver) call plssub(2, 2) call plinit() + call plgdev(driver) + call plgfam(fam,num,bmax) + + write(6,'(3A)') 'Demo of multiple output streams via the ', + & driver(:lnblnk(driver)), ' driver.' + write(6,'(A)') 'Running with the second stream as slave '// + & 'to the first.' + write(6,*) +c flush unit 6 so this part of stdout is guaranteed to be written prior +c to stdout generated by second plinit below. + call flush(6) + c Start next stream call plsstrm(1) diff --git a/examples/f95/x14f.f90 b/examples/f95/x14f.f90 index b7a510d..0a0330d 100644 --- a/examples/f95/x14f.f90 +++ b/examples/f95/x14f.f90 @@ -51,18 +51,6 @@ ! Process command-line arguments call plparseopts(PL_PARSE_FULL) - call plgdev(driver) - call plgfam(fam,num,bmax) - - write(6,'(3A)') 'Demo of multiple output streams via the ', & - trim(driver), ' driver.' - write(6,'(A)') 'Running with the second stream as slave '// & - 'to the first.' - write(6,*) -! flush unit 6 so this part of stdout is guaranteed to be written prior -! to stdout generated by second plinit below. - call flush(6) - ! If valid geometry specified on command line, use it for both streams. call plgpage(xp0, yp0, xleng0, yleng0, xoff0, yoff0) valid_geometry = (xleng0 .gt. 0 .and. yleng0 .gt. 0) @@ -75,10 +63,21 @@ call plsetopt( 'geometry', geometry_master) endif - call plsdev(driver) call plssub(2, 2) call plinit() + call plgdev(driver) + call plgfam(fam,num,bmax) + + write(6,'(3A)') 'Demo of multiple output streams via the ', & + trim(driver), ' driver.' + write(6,'(A)') 'Running with the second stream as slave '// & + 'to the first.' + write(6,*) +! flush unit 6 so this part of stdout is guaranteed to be written prior +! to stdout generated by second plinit below. + call flush(6) + ! Start next stream call plsstrm(1) diff --git a/examples/java/x14.java b/examples/java/x14.java index 563d13b..e97e120 100644 --- a/examples/java/x14.java +++ b/examples/java/x14.java @@ -63,15 +63,6 @@ class x14 { pls1.parseopts( args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM ); - StringBuffer driver = new StringBuffer( 80 ); - - pls1.gdev( driver ); - pls1.gfam( fam, num, bmax ); - String sdriver = new String( driver ); - System.out.println( "Demo of multiple output streams via the " + sdriver + " driver." ); - System.out.println( "Running with the second stream as slave to the first." ); - System.out.println( "" ); - // If valid geometry specified on command line, use it for both streams. pls1.gpage( xp0, yp0, xleng0, yleng0, xoff0, yoff0 ); @@ -84,10 +75,18 @@ class x14 { else pls1.setopt( "geometry", geometry_master ); - pls1.sdev( sdriver ); pls1.ssub( 2, 2 ); pls1.init(); + StringBuffer driver = new StringBuffer( 80 ); + + pls1.gdev( driver ); + pls1.gfam( fam, num, bmax ); + String sdriver = new String( driver ); + System.out.println( "Demo of multiple output streams via the " + sdriver + " driver." ); + System.out.println( "Running with the second stream as slave to the first." ); + System.out.println( "" ); + // Start next stream // Turn off pause to make this a slave (must follow master) diff --git a/examples/lua/x14.lua b/examples/lua/x14.lua index c0f4ccd..d2f6887 100644 --- a/examples/lua/x14.lua +++ b/examples/lua/x14.lua @@ -268,12 +268,6 @@ geometry_slave = "500x410+650+200" -- Parse and process command line arguments pl.parseopts(arg, pl.PL_PARSE_FULL) -driver = pl.gdev() -fam, num, bmax = pl.gfam() - -print("Demo of multiple output streams via the " .. driver .." driver.") -print("Running with the second stream as slave to the first.\n") - -- If valid geometry specified on command line, use it for both streams. xp0, yp0, xleng0, yleng0, xoff0, yoff0 = pl.gpage() valid_geometry = xleng0>0 and yleng0>0 @@ -285,10 +279,15 @@ else pl.setopt("geometry", geometry_master) end -pl.sdev(driver) pl.ssub(2, 2) pl.init() +driver = pl.gdev() +fam, num, bmax = pl.gfam() + +print("Demo of multiple output streams via the " .. driver .." driver.") +print("Running with the second stream as slave to the first.\n") + -- Start next stream pl.sstrm(1) diff --git a/examples/ocaml/x14.ml b/examples/ocaml/x14.ml index 91394cd..f91bcaa 100644 --- a/examples/ocaml/x14.ml +++ b/examples/ocaml/x14.ml @@ -227,27 +227,26 @@ let () = (* Parse and process command line arguments *) plparseopts Sys.argv [PL_PARSE_FULL]; - let driver = plgdev () in - let fam, num, bmax = plgfam () in - (* If valid geometry specified on command line, use it for both streams. *) let xp0, yp0, xleng0, yleng0, xoff0, yoff0 = plgpage () in let valid_geometry = ( xleng0 > 0 && yleng0 > 0 ) in - 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"; - (* Set up first stream *) if valid_geometry then plspage xp0 yp0 xleng0 yleng0 xoff0 yoff0 else plsetopt "geometry" geometry_master; - plsdev driver; plssub 2 2; plinit (); + let driver = plgdev () in + let fam, num, bmax = plgfam () in + + 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/octave/x14c.m b/examples/octave/x14c.m index ef9ad4e..da48e4e 100644 --- a/examples/octave/x14c.m +++ b/examples/octave/x14c.m @@ -34,13 +34,6 @@ function ix14c(fname2,strm) plplot_stub endif - device = sprintf("%s",plgdev'); - if(isempty(device)) - device = "xwin"; - endif - - [fam, num, bmax] = plgfam(); - xleng0 = 400; yleng0 = 300; xoff0 = 200; yoff0 = 200; xleng1 = 400; yleng1 = 300; xoff1 = 500; yoff1 = 500; @@ -49,11 +42,6 @@ function ix14c(fname2,strm) geometry_master = "500x410+100+200"; geometry_slave = "500x410+650+200"; - fprintf(strm,"Demo of multiple output streams via the %s driver.\n", device); - fprintf(strm,"Running with the second stream as slave to the first.\n"); - ##fprintf(strm,"To advance to the next plot, press the third mouse button\n"); - ##fprintf(strm,"or the enter key in the first (left) window\n"); - ## This is an entirely bogus message since the output file name is ## set by the function arguments - but it does ensure that stdout ## is identical to the C version of the example for ctest. @@ -66,10 +54,21 @@ function ix14c(fname2,strm) ## Set up first stream */ plSetOpt("geometry", geometry_master); - plsdev(device); plssub(2,2); plinit(); + device = sprintf("%s",plgdev'); + if(isempty(device)) + device = "xwin"; + endif + + [fam, num, bmax] = plgfam(); + + fprintf(strm,"Demo of multiple output streams via the %s driver.\n", device); + fprintf(strm,"Running with the second stream as slave to the first.\n"); + ##fprintf(strm,"To advance to the next plot, press the third mouse button\n"); + ##fprintf(strm,"or the enter key in the first (left) window\n"); + ## Start next stream */ plsstrm(1); diff --git a/examples/perl/x14.pl b/examples/perl/x14.pl index 0516dcb..0627943 100755 --- a/examples/perl/x14.pl +++ b/examples/perl/x14.pl @@ -56,13 +56,6 @@ sub main { plParseOpts (\...@argv, PL_PARSE_SKIP | PL_PARSE_NOPROGRAM); - my $driver = plgdev (); - my ($fam, $num, $bmax) = plgfam (); - - print ("Demo of multiple output streams via the $driver driver.\n" - . "Running with the second stream as slave to the first.\n" - . "\n"); - # If valid geometry specified on command line, use it for both streams. my ($xp0, $yp0, $xleng0, $yleng0, $xoff0, $yoff0) = plgpage (); printf("%s %i, %i\n", "xleng0, yleng0 = ", $xleng0, $yleng0); @@ -82,10 +75,16 @@ sub main { plsetopt ("geometry", $geometry_master); } - plsdev ($driver); plssub (2, 2); plinit (); + my $driver = plgdev (); + my ($fam, $num, $bmax) = plgfam (); + + print ("Demo of multiple output streams via the $driver driver.\n" + . "Running with the second stream as slave to the first.\n" + . "\n"); + # Start next stream plsstrm (1); diff --git a/examples/tcl/x14.tcl b/examples/tcl/x14.tcl index a211c68..41cc0d6 100644 --- a/examples/tcl/x14.tcl +++ b/examples/tcl/x14.tcl @@ -7,19 +7,18 @@ proc x14 {{w loopback}} { set geometry_master "500x410+100+200" set geometry_slave "500x410+650+200" - $w cmd plgdev driver - $w cmd plgfam fam num bmax - puts "Demo of multiple output streams via the $driver driver." - puts "Running with the second stream as slave to the first." - puts "" - # Set up first stream $w cmd plsetopt "geometry" $geometry_master - if {$driver != ""} {$w cmd plsdev $driver} $w cmd plssub 2 2 $w cmd plinit + $w cmd plgdev driver + $w cmd plgfam fam num bmax + puts "Demo of multiple output streams via the $driver driver." + puts "Running with the second stream as slave to the first." + puts "" + # Start next stream $w cmd plsstrm 1 -- 1.6.6.1 ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel