#include "plplot.h"
#include "dispatch.h"
#include <stdio.h>

/* Asks for number of plotting device, and call plbeg to divide the */
/* page into nx by ny subpages */
void plstar(nx,ny)
int nx, ny;
{
   int dev, level, i;
   char response[10];
   extern int npldrivers;
   extern DISPATCH_TABLE  plDispatchTable[];

   glev(&level);
   if(level != 0)
      plend();

/* For the NeXT we'll only use the PostScript driver. */
#ifndef NeXT
   dev = 0;
   while(dev<1 || dev>npldrivers) {
      printf("\nPlotting Options:\n");
      for(i=0; i<npldrivers;i++)
         printf(" <%2d> %s\n",i+1,plDispatchTable[i].pl_MenuStr);
      printf("\nEnter device number: ");
      fgets(response,sizeof(response),stdin);
      if(sscanf(response,"%d",&dev) != 1) {
         printf("Invalid device number.");
         dev = 0;
      }
   }
#endif
   plbeg(dev,nx,ny);
}
