(FILECREATED "15-Dec-86 11:35:38" {INDIGO}<GSLWS>KOTO>LIBRARY>MATHSERVERPLOT.;4 49010  

      changes to:  (FNS MAPL.Simple.MakePlot MAPL.ExpandFilename MAPL.Meta.MakePlot MAPL.Gen.MakePlot)
		   (VARS MATHSERVERPLOTCOMS)

      previous date: " 8-Dec-86 09:46:39" {INDIGO}<GSLWS>KOTO>LIBRARY>MATHSERVERPLOT.;3)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT MATHSERVERPLOTCOMS)

(RPAQQ MATHSERVERPLOTCOMS ((* * ALL PLOTS)
			     (* Files for Log functions)
			     (FILES plotexamples.dcom {INDIGO}<GSLWS>IDLPLOT>FIXES>LOGPATCH.DCOM)
			     (* Low-level I/0 functions)
			     (FNS MAPL.TopLevel MAPL.MakeReadtable MAPL.ReadASCIILine 
				  MAPL.ExpandFilename)
			     (* * METACODE PLOT STUFF)
			     (* Menu and window functions)
			     (FNS MAPL.Meta.TopLevel MAPL.Meta.FreeMenu MAPL.Meta.MakeIconWindow)
			     (* Plot functions)
			     (FNS MAPL.Meta.MakePlot MAPL.Meta.Plot MAPL.Meta.ASCIIToLisp)
			     (* Metaplot functions)
			     (FNS MAPL.Meta.NewPlotCom MAPL.Meta.MoveCom MAPL.Meta.DrawCom 
				  MAPL.Meta.EndPlotCom MAPL.Meta.NewPenCom)
			     (* Icon bitmaps)
			     (BITMAPS MAPL.Meta.Icon MAPL.Meta.IconMask)
			     (* * SIMPLE PLOT STUFF)
			     (* Menu and window functions)
			     (FNS MAPL.Simple.TopLevel MAPL.Simple.FreeMenu 
				  MAPL.Simple.MakeIconWindow)
			     (* Plot functions)
			     (FNS MAPL.Simple.MakePlot MAPL.Simple.Plot)
			     (* Icon bitmaps)
			     (BITMAPS MAPL.Simple.Icon MAPL.Simple.IconMask)
			     (* * GENERAL PLOT STUFF)
			     (* Menu and window functions)
			     (FNS MAPL.Gen.TopLevel MAPL.Gen.FreeMenu MAPL.Gen.MakeIconWindow)
			     (* Plot functions)
			     (FNS MAPL.Gen.MakePlot MAPL.Gen.Plot MAPL.Gen.ASCIIToLisp 
				  MAPL.Gen.NewPlot MAPL.Gen.PlotObject MAPL.Gen.EndPlot 
				  MAPL.Gen.NewPen MAPL.Gen.CollectData)
			     (* Icon bitmaps)
			     (BITMAPS MAPL.Gen.Icon MAPL.Gen.IconMask)
			     (* vars)
			     (P (MAPL.MakeReadtable))
			     (GLOBALVARS MAPL.ASCIIRDTBL)
			     (ADDVARS (BackgroundMenuCommands (Plot% Menus
								(QUOTE (MAPL.TopLevel))
								"Opens all Plot Menus"
								(SUBITEMS (General% PlotMenu
									    (QUOTE (MAPL.Gen.TopLevel)
										   )
									    
								       "Open a General Plot Menu")
									  (Simple% PlotMenu
									    (QUOTE (
MAPL.Simple.TopLevel))
									    "Open a Simple Plot Menu")
									  (Meta% PlotMenu
									    (QUOTE (MAPL.Meta.TopLevel
										     ))
									    
								      "Open a MetaCode Plot Menu")))))
			     (VARS (BackgroundMenu NIL))))
(* * ALL PLOTS)




(* Files for Log functions)

(FILESLOAD plotexamples.dcom {INDIGO}<GSLWS>IDLPLOT>FIXES>LOGPATCH.DCOM)



(* Low-level I/0 functions)

(DEFINEQ

(MAPL.TopLevel
  (LAMBDA NIL                                                (* DSB " 5-Dec-86 11:39")
                                                             (* opens all plot menus)
    (MAPL.Gen.TopLevel)
    (MAPL.Simple.TopLevel)
    (MAPL.Meta.TopLevel)))

(MAPL.MakeReadtable
  (LAMBDA NIL                                                (* DSB "24-Nov-86 09:53")

          (* * Makes a readtable that reads ASCII records which end in carriage returns as strings, recognizing only CR as a 
	  separator character)


    (SETQ MAPL.ASCIIRDTBL (COPYREADTABLE FILERDTBL))
    (SETSEPR (QUOTE (13))
	       NIL MAPL.ASCIIRDTBL)))

(MAPL.ReadASCIILine
  (LAMBDA (fileStream)                                       (* DSB "24-Nov-86 13:27")

          (* * reads one record from a free-form ASCII file and returns a list of the data items in that record)


    (LET ((stringstream (OPENSTRINGSTREAM (RSTRING fileStream MAPL.ASCIIRDTBL)))
	  newChar)
         (READC fileStream)
         (while (NOT (EOFP stringstream)) collect (READ stringstream)))))

(MAPL.ExpandFilename
  (LAMBDA (ITEM WINDOW BUTTONS)                              (* DSB "15-Dec-86 11:21")
                                                             (* if filename is fullFilename, expand it into the 
							     separate slots)
    (PROG ((state (FM.READSTATE WINDOW))
	     filename host directory name extension version shortName)
	    (SETQ filename (LISTGET state (QUOTE FILENAME)))
	    (SETQ host (UNPACKFILENAME filename (QUOTE HOST)))
	    (COND
	      (host (SETQ directory (UNPACKFILENAME filename (QUOTE DIRECTORY)))
		    (SETQ name (UNPACKFILENAME filename (QUOTE NAME)))
		    (SETQ extension (UNPACKFILENAME filename (QUOTE EXTENSION)))
		    (SETQ version (UNPACKFILENAME filename (QUOTE VERSION)))
		    (SETQ shortName (PACKFILENAME (QUOTE NAME)
						      name
						      (QUOTE EXTENSION)
						      extension
						      (QUOTE VERSION)
						      version))
		    (FM.CHANGELABEL (FM.ITEMFROMID WINDOW (QUOTE FILENAME))
				      WINDOW shortName)
		    (FM.CHANGELABEL (FM.ITEMFROMID WINDOW (QUOTE DIRECTORY))
				      WINDOW directory)
		    (FM.CHANGELABEL (FM.ITEMFROMID WINDOW (QUOTE HOST))
				      WINDOW host)
		    (SETQ state (FM.READSTATE WINDOW))))
	    (RETURN state))))
)
(* * METACODE PLOT STUFF)




(* Menu and window functions)

(DEFINEQ

(MAPL.Meta.TopLevel
  (LAMBDA NIL                                                (* DSB " 5-Dec-86 11:49")
                                                             (* Sets up the MetaCode Plot Free Menu)
    (PROG (menuWindow)
	    (SETQ menuWindow (MAPL.Meta.FreeMenu))       (* initialize to PenFlag ON)
	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE PEN))
			      menuWindow)                    (* set up menu window)
	    (WINDOWPROP menuWindow (QUOTE ICONFN)
			  (FUNCTION MAPL.Meta.MakeIconWindow))
	    (SHAPEW menuWindow (QUOTE (200 420 271 127)))
	    (OPENW menuWindow))))

(MAPL.Meta.FreeMenu
  (LAMBDA (LEFT BOTTOM)                                      (* DSB " 3-Dec-86 12:33")
                                                             (* returns a free menu window for MetaCode plots at 
							     specified position)
    (FM.FORMATMENU (BQUOTE (((TYPE TITLE LABEL Command: FONT (MODERN 12 BOLD))
				 (LABEL MakePlot SELECTEDFN MAPL.Meta.MakePlot))
				((TYPE TITLE LABEL "FILE INFO" FONT (MODERN 12 BOLD)))
				((TYPE EDITSTART LABEL Filename: FONT (MODERN 12 BOLD)
				       ITEMS
				       (FILENAME))
				 (TYPE EDIT ID FILENAME LABEL ""))
				((TYPE EDITSTART LABEL Directory: FONT (MODERN 12 BOLD)
				       ITEMS
				       (DIRECTORY))
				 (TYPE EDIT ID DIRECTORY LABEL ""))
				((TYPE EDITSTART LABEL Host: FONT (MODERN 12 BOLD)
				       ITEMS
				       (HOST))
				 (TYPE EDIT ID HOST LABEL ""))
				((TYPE TITLE LABEL "PLOT INFO" FONT (MODERN 12 BOLD)))
				((TYPE TITLE LABEL PenWidth: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID PEN LABEL ON)
				 (TYPE NWAY ID PEN LABEL OFF))
				(WINDOWPROPS TITLE "MetaCode Plot Menu" LEFT , LEFT BOTTOM , BOTTOM)))
		     )))

(MAPL.Meta.MakeIconWindow
  (LAMBDA (WINDOW OLDICON)                                   (* DSB " 5-Dec-86 18:01")

          (* * Creates a shrink window with an icon formed by two bit maps.)


    (OR OLDICON (ICONW MAPL.Meta.Icon MAPL.Meta.IconMask))))
)



(* Plot functions)

(DEFINEQ

(MAPL.Meta.MakePlot
  (LAMBDA (ITEM WINDOW BUTTONS)                              (* DSB "15-Dec-86 11:32")
                                                             (* checks that required data is specified and that the
							     fullFilename is valid, and makes the MetaCode plot.)
    (PROG ((promptW (GETPROMPTWINDOW WINDOW))
	     state filename directory host penFlag fullFilename)

          (* * check that all required data is specified)


	    (CLEARW promptW)
	    (SETQ state (MAPL.ExpandFilename ITEM WINDOW BUTTONS))
	    (SETQ filename (LISTGET state (QUOTE FILENAME)))
	    (COND
	      ((EQUAL filename "")
		(PRIN1 "Unspecified file name." promptW)
		(RETURN)))
	    (SETQ directory (LISTGET state (QUOTE DIRECTORY)))
	    (COND
	      ((EQUAL directory "")
		(PRIN1 "Unspecified directory." promptW)
		(RETURN)))
	    (SETQ host (LISTGET state (QUOTE HOST)))
	    (COND
	      ((EQUAL host "")
		(PRIN1 "Unspecified host (DSK,IVY,etc.)" promptW)
		(RETURN)))
	    (SETQ penFlag (EQ (QUOTE ON)
				  (LISTGET state (QUOTE PEN))))

          (* * make fullFilename)


	    (SETQ fullFilename (PACKFILENAME (QUOTE HOST)
						 host
						 (QUOTE DIRECTORY)
						 directory
						 (QUOTE BODY)
						 filename))

          (* * if fullFilename is valid, then make plot)


	    (COND
	      ((NOT (INFILEP fullFilename))
		(PRIN1 "File not found" promptW)
		(RETURN))
	      (T (PRIN1 "Making plot ..." promptW)
		 (MAPL.Meta.Plot fullFilename penFlag)
		 (CLEARW promptW)
		 (PRIN1 "Done" promptW)
		 (RETURN))))))

(MAPL.Meta.Plot
  (LAMBDA (file penFlag)                                     (* DSB " 3-Dec-86 13:14")

          (* * makes a PLOT of the metacode file)


    (PROG (dataList plot code newVal1 newVal2 curveList pen)
	    (SETQ dataList (MAPL.Meta.ASCIIToLisp file))
                                                             (* (PRIN1 dataList PROMPTWINDOW))
	    (COND
	      ((NOT dataList)
		(RETURN (PROMPTPRINT "There is no data"))))
	    (for item in dataList
	       do (SETQ code (CAR item))
		    (SETQ newVal1 (CADR item))
		    (SETQ newVal2 (CADDR item))
		    (SELECTQ code
			       (1 (SETQ plot (MAPL.Meta.NewPlotCom))
                                                             (* New plot)
				  )
			       (2 (SETQ curveList (MAPL.Meta.DrawCom curveList newVal1 newVal2)))
			       (3 (SETQ curveList (MAPL.Meta.MoveCom plot curveList pen newVal1 
									 newVal2)))
			       (4 (MAPL.Meta.EndPlotCom plot curveList pen)
                                                             (* End of plot)
				  )
			       (5 (SETQ pen (MAPL.Meta.NewPenCom newVal1 penFlag))
                                                             (* New pen)
				  )
			       NIL)))))

(MAPL.Meta.ASCIIToLisp
  (LAMBDA (file)                                             (* DSB "25-Nov-86 09:54")

          (* * returns ASCII data from a file in a list, with one sub-list per line. The file must end in a CR.)


    (PROG ((tempFile (QUOTE {core}tempplot.dat))
	     fileStream dataList)
	    (COND
	      ((NOT (INFILEP file))
		(RETURN NIL)))
	    (COPYFILE file tempFile)                       (* copy to {core} because reads from filestream to 
							     {core} are much faster than reads from filestream to a
							     VAX on the network.)
	    (SETQ fileStream (OPENSTREAM tempFile (QUOTE INPUT)))
	    (SETQ dataList (while (NOT (EOFP tempFile)) collect (MAPL.ReadASCIILine
									    fileStream)))
	    (CLOSEF fileStream)
	    (DELFILE tempFile)
	    (RETURN dataList))))
)



(* Metaplot functions)

(DEFINEQ

(MAPL.Meta.NewPlotCom
  (LAMBDA NIL                                                (* DSB " 5-Dec-86 11:51")

          (* * starts a new plot)


    (PROG NIL
	    (SETQ curveList NIL)
	    (RETURN (CREATEPLOT NIL (QUOTE (471 420 250 250))
				    "MetaCode Plot")))))

(MAPL.Meta.MoveCom
  (LAMBDA (plot curveList pen newVal1 newVal2)               (* DSB "25-Nov-86 09:01")

          (* * Plots the previous curve, and moves to a new position, starting a new curve)


    (PROG NIL
	    (COND
	      ((AND curveList (GREATERP (LENGTH curveList)
					    1))
		(PLOTCURVE plot curveList NIL pen NIL T)))
	    (SETQ curveList (LIST (CONS newVal1 newVal2)))
	    (RETURN curveList))))

(MAPL.Meta.DrawCom
  (LAMBDA (curveList newVal1 newVal2)                        (* DSB "24-Nov-86 13:31")

          (* * adds a new set of points to the curveList)


    (PROG NIL
	    (SETQ curveList (CONS (CONS newVal1 newVal2)
				      curveList))
	    (RETURN curveList))))

(MAPL.Meta.EndPlotCom
  (LAMBDA (plot curveList pen)                               (* DSB "25-Nov-86 09:01")

          (* * plots the last curve and opens the plot. It is expected that no more curves will be drawn to the plot)


    (PROG NIL
	    (COND
	      ((AND curveList (GREATERP (LENGTH curveList)
					    1))
		(PLOTCURVE plot curveList NIL pen NIL T)))
	    (OPENPLOTWINDOW plot))))

(MAPL.Meta.NewPenCom
  (LAMBDA (newVal1 penFlag)                                  (* DSB " 3-Dec-86 15:25")

          (* * If penFlag is OFF, sets pen to 1)



          (* * if penFlag is ON, sets the pen to INT ((PEN + 1) /2))


    (PROG (pen)
	    (COND
	      (penFlag (SETQ pen (IQUOTIENT (PLUS newVal1 1)
						2)))
	      (T (SETQ pen 1)))
	    (RETURN pen))))
)



(* Icon bitmaps)


(RPAQ MAPL.Meta.Icon (READBITMAP))
(70 70
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"L@@@@@@@@@ON@@@@@L@@"
"L@@@@@@@@@GO@@@@@L@@"
"LGOH@COOOOOOOOOOLL@@"
"LDLH@B@@@@AOH@@@DL@@"
"LDLH@B@@@@@OL@@@DL@@"
"LD@H@B@@@@@GN@@@DL@@"
"LD@H@BB@@@@CO@@@DL@@"
"LNAL@BB@@@@AOH@@DL@@"
"L@@@@BF@@@@@OH@@DL@@"
"L@@@@BB@@@@@GL@@DL@@"
"L@A@@BB@@@@@CL@@DL@@"
"LCO@@BB@@@@@AN@@DL@@"
"LBA@@BF@@@@@@F@@DL@@"
"LB@@@BB@@@@@@C@@DL@@"
"LCH@@BB@@@@@@AH@DL@@"
"LCH@@BB@@CL@@GH@DL@@"
"LB@@@BF@@FF@AL@@DL@@"
"LBAAOBB@@LC@C@@@DL@@"
"LCOAOBB@AHAHN@@@DL@@"
"L@A@@BB@C@@OH@@@DL@@"
"L@@@@BF@F@@@@@@@DL@@"
"L@@@@BB@L@@@@@@@DL@@"
"LCO@@BB@H@@@@@@@DL@@"
"L@L@@BBAH@@@@@@@DL@@"
"L@L@@BFA@@@@@@@@DL@@"
"L@L@@BBC@@@@@@@@DL@@"
"L@L@@BBB@@@@@@@@DL@@"
"L@L@@BBF@@@@@@@@D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OOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@")
(* * SIMPLE PLOT STUFF)




(* Menu and window functions)

(DEFINEQ

(MAPL.Simple.TopLevel
  (LAMBDA NIL                                                (* DSB " 8-Dec-86 08:00")
                                                             (* Sets up the Simple Plot Free Menu)
    (PROG (menuWindow)
	    (SETQ menuWindow (MAPL.Simple.FreeMenu 200 250))

          (* * initialize plot defaults)


	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE TYPE))
			      menuWindow)
	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE REP))
			      menuWindow)
	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE DEST))
			      menuWindow)

          (* * finish setup of free menu)


	    (WINDOWPROP menuWindow (QUOTE ICONFN)
			  (FUNCTION MAPL.Simple.MakeIconWindow))
	    (OPENW menuWindow))))

(MAPL.Simple.FreeMenu
  (LAMBDA (LEFT BOTTOM)                                      (* DSB " 8-Dec-86 07:59")
                                                             (* returns a free menu window for simple plots at 
							     specified position)
    (FM.FORMATMENU (BQUOTE (((TYPE TITLE LABEL Command: FONT (MODERN 12 BOLD))
				 (LABEL MakePlot SELECTEDFN MAPL.Simple.MakePlot))
				((TYPE TITLE LABEL "FILE INFO" FONT (MODERN 12 BOLD)))
				((TYPE EDITSTART LABEL Filename: FONT (MODERN 12 BOLD)
				       ITEMS
				       (FILENAME))
				 (TYPE EDIT ID FILENAME LABEL ""))
				((TYPE EDITSTART LABEL Directory: FONT (MODERN 12 BOLD)
				       ITEMS
				       (DIRECTORY))
				 (TYPE EDIT ID DIRECTORY LABEL ""))
				((TYPE EDITSTART LABEL Host: FONT (MODERN 12 BOLD)
				       ITEMS
				       (HOST))
				 (TYPE EDIT ID HOST LABEL ""))
				((TYPE TITLE LABEL "PLOT INFO" FONT (MODERN 12 BOLD)))
				((TYPE TITLE LABEL PlotType: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID TYPE LABEL X-Y CLASSNAME XY)
				 (TYPE NWAY ID TYPE LABEL X-LogY CLASSNAME X-LogY)
				 (TYPE NWAY ID TYPE LABEL LogX-Y CLASSNAME LogX-Y)
				 (TYPE NWAY ID TYPE LABEL LogX-LogY CLASSNAME LogX-LogY))
				((TYPE TITLE LABEL Representation: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID REP LABEL Curve CLASSNAME Curve)
				 (TYPE NWAY ID REP LABEL Points CLASSNAME Points)
				 (TYPE NWAY ID REP LABEL Both CLASSNAME Both))
				((TYPE EDITSTART LABEL PenWidth: FONT (MODERN 12 BOLD)
				       ITEMS
				       (PEN))
				 (TYPE EDIT ID PEN LABEL "1"))
				((TYPE TITLE LABEL Destination: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID DEST LABEL New CLASSNAME New)
				 (TYPE NWAY ID DEST LABEL Previous CLASSNAME Previous))
				(WINDOWPROPS TITLE "Simple Plot Menu" LEFT , LEFT BOTTOM , BOTTOM)))))
)

(MAPL.Simple.MakeIconWindow
  (LAMBDA (WINDOW OLDICON)                                   (* DSB " 5-Dec-86 18:00")

          (* * Creates a window with an icon formed by two bit maps.)


    (OR OLDICON (ICONW MAPL.Simple.Icon MAPL.Simple.IconMask))))
)



(* Plot functions)

(DEFINEQ

(MAPL.Simple.MakePlot
  (LAMBDA (ITEM WINDOW BUTTONS)                              (* DSB "15-Dec-86 11:27")
                                                             (* checks that required data is specified and that the
							     fullFilename is valid, and makes the simple plot.)
    (PROG ((promptW (GETPROMPTWINDOW WINDOW))
	     state filename directory host type rep penWidth dest fullFilename)

          (* * check that all required data is specified)


	    (CLEARW promptW)
	    (SETQ state (MAPL.ExpandFilename ITEM WINDOW BUTTONS))
	    (SETQ filename (LISTGET state (QUOTE FILENAME)))
	    (COND
	      ((EQUAL filename "")
		(PRIN1 "Unspecified file name." promptW)
		(RETURN)))
	    (SETQ directory (LISTGET state (QUOTE DIRECTORY)))
	    (COND
	      ((EQUAL directory "")
		(PRIN1 "Unspecified directory." promptW)
		(RETURN)))
	    (SETQ host (LISTGET state (QUOTE HOST)))
	    (COND
	      ((EQUAL host "")
		(PRIN1 "Unspecified host (DSK,IVY,etc.)" promptW)
		(RETURN)))
	    (SETQ type (LISTGET state (QUOTE TYPE)))
	    (COND
	      ((NOT type)
		(PRIN1 "Unspecified plot type (XY, etc)." promptW)
		(RETURN)))
	    (SETQ rep (LISTGET state (QUOTE REP)))
	    (COND
	      ((NOT rep)
		(PRIN1 "Unspecified represent. (Points,etc.)" promptW)
		(RETURN)))
	    (SETQ penWidth (MKATOM (LISTGET state (QUOTE PEN))))
	    (COND
	      ((AND (NUMBERP penWidth)
		      (GREATERP penWidth 0))
		(SETQ penWidth (FIX penWidth)))
	      (T (PRIN1 "PenWidth must be integer > 0" promptW)
		 (RETURN)))
	    (SETQ dest (LISTGET state (QUOTE DEST)))
	    (COND
	      ((NOT dest)
		(PRIN1 "Unspecified destination (New, etc.)" promptW)
		(RETURN)))

          (* * make fullFilename)


	    (SETQ fullFilename (PACKFILENAME (QUOTE HOST)
						 host
						 (QUOTE DIRECTORY)
						 directory
						 (QUOTE BODY)
						 filename))

          (* * if fullFilename is valid, then make plot)


	    (COND
	      ((NOT (INFILEP fullFilename))
		(PRIN1 "File not found" promptW)
		(RETURN))
	      (T (PRIN1 "Making plot ..." promptW)
		 (MAPL.Simple.Plot fullFilename promptW rep type penWidth dest)
		 (CLEARW promptW)
		 (PRIN1 "Done" promptW)
		 (RETURN))))))

(MAPL.Simple.Plot
  (LAMBDA (filename promptW rep type penWidth dest)          (* DSB " 8-Dec-86 08:53")
                                                             (* Makes the plot and puts it into the appropriate 
							     window)

          (* * takes an ASCII file of pairs of X-Y values, converts it into list format, and then converts it into a list of 
	  dotted pairs of data for requested plot.)


    (PROG ((rightMenuItems (QUOTE ((Logscale SCAT.LOGSCALE "Toggle exponential tics"
						 (SUBITEMS (X% axis (SCAT.LOGSCALE (QUOTE X))
								    "X axis only")
							   (Y% axis (SCAT.LOGSCALE (QUOTE Y))
								    "Y axis only")))
					(Coordinates SCAT.WORLDCOORD 
						   "Display world coordinates at cursor position"))))
	     (pointMenuItems (QUOTE ((Coordinates SCAT.POINTCOORDS "Display point coordinates"))))
	     (tempFile (QUOTE {core}tempplot.dat))
	     data first second mouseDown? fileStream dataList newPlot)

          (* * copy to {core} and read into a list, with each line in the original file becoming a sub-list)


	    (COPYFILE filename tempFile)
	    (SETQ fileStream (OPENSTREAM tempFile (QUOTE INPUT)))
	    (SETQ dataList (while (NOT (EOFP tempFile)) collect (MAPL.ReadASCIILine
									    fileStream)))
	    (CLOSEF fileStream)
	    (DELFILE tempFile)

          (* * translate to list of dotted pairs, depending on type of plot to be made)


	    (SETQ data NIL)
	    (COND
	      ((EQUAL type (QUOTE X-Y))
		(for item in dataList
		   do (SETQ first (CAR item))
			(SETQ second (CADR item))
			(COND
			  ((AND (NUMBERP first)
				  (NUMBERP second))
			    (SETQ data (CONS (CONS first second)
						 data))))))
	      ((EQUAL type (QUOTE X-LogY))
		(for item in dataList
		   do (SETQ first (CAR item))
			(SETQ second (CADR item))
			(COND
			  ((AND (NUMBERP first)
				  (NUMBERP second)
				  (GREATERP second 0))
			    (SETQ data (CONS (CONS first (PLOT.LOG10 second))
						 data))))))
	      ((EQUAL type (QUOTE LogX-Y))
		(for item in dataList
		   do (SETQ first (CAR item))
			(SETQ second (CADR item))
			(COND
			  ((AND (NUMBERP first)
				  (GREATERP first 0)
				  (NUMBERP second))
			    (SETQ data (CONS (CONS (PLOT.LOG10 first)
							 second)
						 data))))))
	      ((EQUAL type (QUOTE LogX-LogY))
		(for item in dataList
		   do (SETQ first (CAR item))
			(SETQ second (CADR item))
			(COND
			  ((AND (NUMBERP first)
				  (GREATERP first 0)
				  (NUMBERP second)
				  (GREATERP second 0))
			    (SETQ data (CONS (CONS (PLOT.LOG10 first)
							 (PLOT.LOG10 second))
						 data))))))
	      (T (CLEARW promptW)
		 (PRIN1 "Error: Unknown plot type" promptW)
		 (RETURN)))
	    (CLEARW promptW)

          (* * If the new data is to be put on a previous plot, the user has 20 seconds to button in the desired plot window)



          (* * otherwise, the data goes into a new plot)


	    (COND
	      ((EQUAL dest (QUOTE Previous))
		(PRIN1 "Button in desired plot window" promptW)
		(SETQ mouseDown? (UNTILMOUSESTATE LEFT 20000))
		(COND
		  (mouseDown? (COND
				((EQUAL rep (QUOTE Points))
				  (PLOTPOINTS (WHICHPLOT)
						data)
				  (RETURN))
				((EQUAL rep (QUOTE Curve))
				  (PLOTCURVE (WHICHPLOT)
					       data NIL penWidth)
				  (RETURN))
				((EQUAL rep (QUOTE Both))
				  (PLOTPOINTS (WHICHPLOT)
						data)
				  (PLOTCURVE (WHICHPLOT)
					       data NIL penWidth)
				  (RETURN))
				(T (PRIN1 "Error: Unknown represent." promptW)
				   (RETURN))))
		  (T (PRIN1 "Making a new plot." promptW)))))
	    (SETQ newPlot (CREATEPLOT NIL (QUOTE (471 250 250 250))
					  "Simple Plot"))
	    (PLOTADDMENUITEMS newPlot (QUOTE RIGHT)
				rightMenuItems)
	    (PLOTMENUITEMS newPlot (QUOTE POINTMENU)
			     (APPEND (PLOTMENUITEMS newPlot (QUOTE MIDDLE))
				       pointMenuItems))
	    (COND
	      ((EQUAL rep (QUOTE Curve))
		(PLOTCURVE newPlot data NIL penWidth))
	      ((EQUAL rep (QUOTE Points))
		(PLOTPOINTS newPlot data))
	      ((EQUAL rep (QUOTE Both))
		(PLOTCURVE newPlot data NIL penWidth)
		(PLOTPOINTS newPlot data))
	      (T (PRIN1 "Error: Unknown represent." promptW)
		 (RETURN)))
	    (OPENPLOTWINDOW newPlot))))
)



(* Icon bitmaps)


(RPAQ MAPL.Simple.Icon (READBITMAP))
(70 70
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"L@@@@@@@@@ON@@@@@L@@"
"L@@@@@@@@@GO@@@@@L@@"
"L@@@@COOOOOOOOOOLL@@"
"L@@@@B@@@@AOH@@@DL@@"
"L@@@@B@@@@@OL@@@DL@@"
"L@@@@B@@@@@GN@@@DL@@"
"L@@@@BB@@@@CO@@@DL@@"
"L@@@@BB@@@@AOH@@DL@@"
"L@@@@BF@@@@@OH@@DL@@"
"L@@@@BB@@@@@GL@@DL@@"
"L@@@@BB@@@@@CL@@DL@@"
"LOO@@BB@@@@@AN@@DL@@"
"LLC@@BF@@@@@@F@@DL@@"
"LLC@@BB@@@@@@C@@DL@@"
"LL@@@BB@@@@@@AH@DL@@"
"LL@@@BB@@CL@@GH@DL@@"
"LL@@@BF@@FF@AL@@DL@@"
"LL@CNBB@@LC@C@@@DL@@"
"LOOCNBB@AHAHN@@@DL@@"
"L@C@@BB@C@@OH@@@DL@@"
"L@C@@BF@F@@@@@@@DL@@"
"L@C@@BB@L@@@@@@@DL@@"
"L@C@@BB@H@@@@@@@DL@@"
"LLC@@BBAH@@@@@@@DL@@"
"LLC@@BFA@@@@@@@@DL@@"
"LOO@@BBC@@@@@@@@DL@@"
"L@@@@BBB@@@@@@@@DL@@"
"L@@@@BBF@@@@@@@@DL@@"
"L@@@@BFD@@@@@@@@DL@@"
"L@@@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"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@")
(* * GENERAL PLOT STUFF)




(* Menu and window functions)

(DEFINEQ

(MAPL.Gen.TopLevel
  (LAMBDA NIL                                                (* DSB " 5-Dec-86 11:45")
                                                             (* Sets up the General Plot Free Menu)
    (PROG (menuWindow)
	    (SETQ menuWindow (MAPL.Gen.FreeMenu 200 50))

          (* * initialize plot defaults)


	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE TYPE))
			      menuWindow)
	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE REP))
			      menuWindow)
	    (FM.CHANGESTATE (FM.ITEMFROMID menuWindow (QUOTE PEN))
			      menuWindow)

          (* * finish setup of free menu)


	    (WINDOWPROP menuWindow (QUOTE ICONFN)
			  (FUNCTION MAPL.Gen.MakeIconWindow))
	    (OPENW menuWindow))))

(MAPL.Gen.FreeMenu
  (LAMBDA (LEFT BOTTOM)                                      (* DSB " 4-Dec-86 13:09")
                                                             (* returns a free menu window for simple plots at 
							     specified position)
    (FM.FORMATMENU (BQUOTE (((TYPE TITLE LABEL Command: FONT (MODERN 12 BOLD))
				 (LABEL MakePlot SELECTEDFN MAPL.Gen.MakePlot))
				((TYPE TITLE LABEL "FILE INFO" FONT (MODERN 12 BOLD)))
				((TYPE EDITSTART LABEL Filename: FONT (MODERN 12 BOLD)
				       ITEMS
				       (FILENAME))
				 (TYPE EDIT ID FILENAME LABEL ""))
				((TYPE EDITSTART LABEL Directory: FONT (MODERN 12 BOLD)
				       ITEMS
				       (DIRECTORY))
				 (TYPE EDIT ID DIRECTORY LABEL ""))
				((TYPE EDITSTART LABEL Host: FONT (MODERN 12 BOLD)
				       ITEMS
				       (HOST))
				 (TYPE EDIT ID HOST LABEL ""))
				((TYPE TITLE LABEL "PLOT INFO" FONT (MODERN 12 BOLD)))
				((TYPE EDITSTART LABEL X-Position: FONT (MODERN 12 BOLD)
				       ITEMS
				       (XPOS))
				 (TYPE EDIT ID XPOS LABEL "1"))
				((TYPE EDITSTART LABEL Y-Position: FONT (MODERN 12 BOLD)
				       ITEMS
				       (YPOS))
				 (TYPE EDIT ID YPOS LABEL "2"))
				((TYPE TITLE LABEL PlotType: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID TYPE LABEL X-Y CLASSNAME XY)
				 (TYPE NWAY ID TYPE LABEL X-LogY CLASSNAME X-LogY)
				 (TYPE NWAY ID TYPE LABEL LogX-Y CLASSNAME LogX-Y)
				 (TYPE NWAY ID TYPE LABEL LogX-LogY CLASSNAME LogX-LogY))
				((TYPE TITLE LABEL Representation: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID REP LABEL Curve CLASSNAME Curve)
				 (TYPE NWAY ID REP LABEL Points CLASSNAME Points)
				 (TYPE NWAY ID REP LABEL Both CLASSNAME Both))
				((TYPE TITLE LABEL PenWidth: FONT (MODERN 12 BOLD))
				 (TYPE NWAY ID PEN LABEL ON)
				 (TYPE NWAY ID PEN LABEL OFF))
				(WINDOWPROPS TITLE "General Plot Menu" LEFT , LEFT BOTTOM , BOTTOM))))
    ))

(MAPL.Gen.MakeIconWindow
  (LAMBDA (WINDOW OLDICON)                                   (* DSB " 5-Dec-86 17:42")

          (* * Creates a shrink window with an icon formed by two bit maps.)


    (OR OLDICON (ICONW MAPL.Gen.Icon MAPL.Gen.IconMask))))
)



(* Plot functions)

(DEFINEQ

(MAPL.Gen.MakePlot
  (LAMBDA (ITEM WINDOW BUTTONS)                              (* DSB "15-Dec-86 11:30")
                                                             (* checks that required data is specified and that the
							     fullFilename is valid, and makes the simple plot.)
    (PROG ((promptW (GETPROMPTWINDOW WINDOW))
	     state filename directory host type rep xPos yPos penFlag fullFilename)

          (* * check that all required data is specified)


	    (CLEARW promptW)
	    (SETQ state (MAPL.ExpandFilename ITEM WINDOW BUTTONS))
	    (SETQ filename (LISTGET state (QUOTE FILENAME)))
	    (COND
	      ((EQUAL filename "")
		(PRIN1 "Unspecified file name." promptW)
		(RETURN)))
	    (SETQ directory (LISTGET state (QUOTE DIRECTORY)))
	    (COND
	      ((EQUAL directory "")
		(PRIN1 "Unspecified directory." promptW)
		(RETURN)))
	    (SETQ host (LISTGET state (QUOTE HOST)))
	    (COND
	      ((EQUAL host "")
		(PRIN1 "Unspecified host (DSK,IVY,etc.)" promptW)
		(RETURN)))
	    (SETQ xPos (MKATOM (LISTGET state (QUOTE XPOS))))
                                                             (* if xPos is not a number, set it to NIL for a 
							     Time-Series plot)
	    (COND
	      ((NOT (NUMBERP xPos))
		(SETQ xPos (NUMBERP xPos))
		(PRIN1 "Time-series plot..." promptW)))
	    (SETQ yPos (MKATOM (LISTGET state (QUOTE YPOS))))
	    (COND
	      ((NOT (NUMBERP yPos))
		(PRIN1 "Unspecified position of 'Y' variable" promptW)
		(RETURN)))
	    (SETQ type (LISTGET state (QUOTE TYPE)))
	    (COND
	      ((NOT type)
		(PRIN1 "Unspecified plot type (XY, etc)." promptW)
		(RETURN)))                                 (* if xPos is NIL, do not allow Logs of the "time")
	    (COND
	      ((AND (NOT xPos)
		      (OR (EQUAL type (QUOTE LogX-Y))
			    (EQUAL type (QUOTE LogX-LogY))))
		(PRIN1 "Log of X (time) not permitted" promptW)
		(RETURN)))
	    (SETQ rep (LISTGET state (QUOTE REP)))
	    (COND
	      ((NOT rep)
		(PRIN1 "Unspecified represent. (Points,etc.)" promptW)
		(RETURN)))
	    (SETQ penFlag (EQ (QUOTE ON)
				  (LISTGET state (QUOTE PEN))))

          (* * make fullFilename)


	    (SETQ fullFilename (PACKFILENAME (QUOTE HOST)
						 host
						 (QUOTE DIRECTORY)
						 directory
						 (QUOTE BODY)
						 filename))

          (* * if fullFilename is valid, then make plot)


	    (COND
	      ((NOT (INFILEP fullFilename))
		(PRIN1 "File not found" promptW)
		(RETURN))
	      (T (PRIN1 "Making plot ..." promptW)
		 (MAPL.Gen.Plot fullFilename promptW xPos yPos rep type penFlag)
		 (CLEARW promptW)
		 (PRIN1 "Done" promptW)
		 (RETURN))))))

(MAPL.Gen.Plot
  (LAMBDA (file promptW xPos yPos rep type penFlag)          (* DSB " 5-Dec-86 17:41")

          (* * makes a plot from the general plot input format)


    (PROG (dataList keyword plot objectList (pen 1)
		      (plotNumber 1))

          (* * get a data list of those pairs of data you want to plot)


	    (SETQ dataList (MAPL.Gen.ASCIIToLisp file xPos yPos))
                                                             (* (PRIN1 dataList PROMPTWINDOW))

          (* * parse and plot)


	    (COND
	      ((NOT dataList)
		(RETURN (PRIN1 "There is no data" promptW))))
	    (for item in dataList
	       do (SETQ keyword (CAR item))
		    (SELECTQ keyword
			       (NEWPLOT (SETQ plot (MAPL.Gen.NewPlot plotNumber))
                                                             (* New plot)
					)
			       (START (SETQ objectList NIL)
                                                             (* Start new object)
				      )
			       (END (SETQ objectList (MAPL.Gen.PlotObject plot objectList pen rep)
				      )                      (* Plot the object)
				    )
			       (ENDPLOT (SETQ plotNumber (MAPL.Gen.EndPlot plot plotNumber))
                                                             (* End of plot)
					)
			       (NEWPEN (SETQ pen (MAPL.Gen.NewPen item penFlag))
                                                             (* New pen)
				       )
			       (SETQ objectList (MAPL.Gen.CollectData objectList item type)))))))

(MAPL.Gen.ASCIIToLisp
  (LAMBDA (file xPos yPos)                                   (* DSB " 5-Dec-86 17:34")

          (* * returns ASCII data from a file in a list, with one sub-list per line. The file must end in a CR.)


    (PROG ((tempFile (QUOTE {core}tempplot.dat))
	     (keywordList (QUOTE (NEWPLOT ENDPLOT START END NEWPEN)))
	     fileStream dataList lineList key shortList)
	    (COND
	      ((NOT (INFILEP file))
		(RETURN NIL)))
	    (COPYFILE file tempFile)

          (* * copy to {core} because reads from filestream to {core} are much faster than reads from filestream to a VAX on 
	  the network.)



          (* * if Keyword, return the line as is; otherwise, only include the numbers in the positions requested.)



          (* * if xPos is NIL, put NIL in the first position of the short list)


	    (SETQ fileStream (OPENSTREAM tempFile (QUOTE INPUT)))
	    (while (NOT (EOFP tempFile))
	       do (SETQ lineList (MAPL.ReadASCIILine fileStream))
		    (SETQ key (CAR lineList))
		    (COND
		      ((MEMBER key keywordList)
			(SETQ shortList lineList))
		      ((NOT xPos)
			(SETQ shortList (LIST NIL (CAR (NTH lineList yPos)))))
		      (T (SETQ shortList (LIST (CAR (NTH lineList xPos))
						   (CAR (NTH lineList yPos))))))
		    (SETQ dataList (CONS shortList dataList)))
	    (CLOSEF fileStream)
	    (DELFILE tempFile)
	    (RETURN (REVERSE dataList)))))

(MAPL.Gen.NewPlot
  (LAMBDA (plotNumber)                                       (* DSB " 5-Dec-86 11:44")

          (* * starts a new plot with Log scaling)


    (PROG (newPlot (leftFirst 471)
		     left
		     (bottomFirst 50)
		     bottom region (rightMenuItems (QUOTE
						     ((Logscale SCAT.LOGSCALE 
								"Toggle exponential tics"
								(SUBITEMS (X% axis
									    (SCAT.LOGSCALE
									      (QUOTE X))
									    "X axis only")
									  (Y% axis
									    (SCAT.LOGSCALE
									      (QUOTE Y))
									    "Y axis only")))
						       (Coordinates SCAT.WORLDCOORD 
						   "Display world coordinates at cursor position"))))
		     (pointMenuItems (QUOTE ((Coordinates SCAT.POINTCOORDS 
							    "Display point coordinates")))))
	    (SETQ left (PLUS leftFirst (TIMES 25 (DIFFERENCE plotNumber 1))))
	    (SETQ bottom (PLUS bottomFirst (TIMES 25 (DIFFERENCE plotNumber 1))))
	    (SETQ region (CREATEREGION left bottom 250 250))
	    (SETQ newPlot (CREATEPLOT NIL region "General Plot"))
	    (PLOTADDMENUITEMS newPlot (QUOTE RIGHT)
				rightMenuItems)
	    (PLOTMENUITEMS newPlot (QUOTE POINTMENU)
			     (APPEND (PLOTMENUITEMS newPlot (QUOTE MIDDLE))
				       pointMenuItems))
	    (RETURN newPlot))))

(MAPL.Gen.PlotObject
  (LAMBDA (plot objectList pen rep)                          (* DSB " 8-Dec-86 07:28")

          (* * plots the objectList, with specified pen and according to the chosen representation (e.g., points, curve, 
	  both))



          (* * when plotting points, ignore the pen size)


    (PROG NIL
	    (COND
	      ((NOT plot)
		(RETURN (PRIN1 "ERROR:  NEWPLOT command omitted.  " PROMPTWINDOW))))
	    (COND
	      ((AND objectList (GREATERP (LENGTH objectList)
					     0))
		(COND
		  ((EQUAL rep (QUOTE Curve))
		    (PLOTCURVE plot objectList NIL pen NIL T))
		  ((EQUAL rep (QUOTE Points))
		    (PLOTPOINTS plot objectList NIL NIL NIL T))
		  ((EQUAL rep (QUOTE Both))
		    (PLOTCURVE plot objectList NIL pen NIL T)
		    (PLOTPOINTS plot objectList NIL NIL NIL T))))
	      (T (PROMPTPRINT "ERROR:  PlotObject is NIL and not drawn")))
	    (RETURN NIL))))

(MAPL.Gen.EndPlot
  (LAMBDA (plot plotNumber)                                  (* DSB " 4-Dec-86 14:17")

          (* * opens the plotwindow, and returns a new increment for the next plot position)


    (PROG NIL
	    (OPENPLOTWINDOW plot)
	    (RETURN (PLUS plotNumber 1)))))

(MAPL.Gen.NewPen
  (LAMBDA (item penFlag)                                     (* DSB " 8-Dec-86 07:30")

          (* * If penFlag is OFF, sets pen to 1; otherwise, sets pen width as instructed.)


    (PROG (pen)
	    (COND
	      (penFlag (SETQ pen (CADR item)))
	      (T (SETQ pen 1)))
	    (RETURN pen))))

(MAPL.Gen.CollectData
  (LAMBDA (objectList item type)                             (* DSB " 8-Dec-86 09:43")

          (* * adds the appropriate dotted pair (determined by dest and the input item) to the objectList.)


    (PROG ((xVal (CAR item))
	     (yVal (CADR item))
	     newItem)

          (* * not numbers; don't do anything)


	    (COND
	      ((NOT (NUMBERP yVal))
		(RETURN objectList)))

          (* * if xVal is NIL (not a number) but yVal is a number, then assume the user is asking for a time sequence.
	  However, LogX is not allowed. This will slip past MAPL.Gen.MakePlot if the X-position is given as a 
	  (too large) number. We stop that here.)


	    (COND
	      ((AND (NOT (NUMBERP xVal))
		      (NUMBERP yVal))
		(COND
		  ((OR (EQUAL type (QUOTE LogX-Y))
			 (EQUAL type (QUOTE LogX-LogY)))
		    (PROMPTPRINT "Log X for X=time-sequence not allowed")
		    (RETURN objectList)))
		(COND
		  ((NOT objectList)
		    (SETQ xVal 0))
		  (T (SETQ xVal (PLUS 1 (CAAR objectList)))))))

          (* * non time-series plot)


	    (COND
	      ((EQUAL type (QUOTE X-Y))
		(SETQ newItem (CONS xVal yVal)))
	      ((EQUAL type (QUOTE X-LogY))
		(COND
		  ((GREATERP yVal 0)
		    (SETQ newItem (CONS xVal (PLOT.LOG10 yVal))))
		  (T (PROMPTPRINT "ERROR: Attempt to take Log of negative number " yVal))))
	      ((EQUAL type (QUOTE LogX-Y))
		(COND
		  ((GREATERP xVal 0)
		    (SETQ newItem (CONS (PLOT.LOG10 xVal)
					    yVal)))
		  (T (PROMPTPRINT "ERROR: Attempt to take Log of negative number " xVal))))
	      ((EQUAL type (QUOTE LogX-LogY))
		(COND
		  ((AND (GREATERP xVal 0)
			  (GREATERP yVal 0))
		    (SETQ newItem (CONS (PLOT.LOG10 xVal)
					    (PLOT.LOG10 yVal))))
		  (T (PROMPTPRINT "ERROR: Attempt to take Log of neg. number at point (" xVal "," 
				    yVal ")"))))
	      (T (PRIN1 "ERROR: Unknown plot type requested" PROMPTWINDOW)))
	    (COND
	      (newItem (SETQ objectList (CONS newItem objectList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OOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@"
"OOOOOOOOOOOOOOOOOL@@")



(* vars)

(MAPL.MakeReadtable)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS MAPL.ASCIIRDTBL)
)

(ADDTOVAR BackgroundMenuCommands (Plot% Menus (QUOTE (MAPL.TopLevel))
						"Opens all Plot Menus"
						(SUBITEMS (General% PlotMenu (QUOTE (MAPL.Gen.TopLevel
										      ))
									     
								       "Open a General Plot Menu")
							  (Simple% PlotMenu (QUOTE (
MAPL.Simple.TopLevel))
									    "Open a Simple Plot Menu")
							  (Meta% PlotMenu (QUOTE (MAPL.Meta.TopLevel))
									  "Open a MetaCode Plot Menu")
							  )))

(RPAQQ BackgroundMenu NIL)
(PUTPROPS MATHSERVERPLOT COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2744 5312 (MAPL.TopLevel 2754 . 3043) (MAPL.MakeReadtable 3045 . 3446) (
MAPL.ReadASCIILine 3448 . 3909) (MAPL.ExpandFilename 3911 . 5310)) (5383 7480 (MAPL.Meta.TopLevel 5393
 . 6056) (MAPL.Meta.FreeMenu 6058 . 7203) (MAPL.Meta.MakeIconWindow 7205 . 7478)) (7508 11497 (
MAPL.Meta.MakePlot 7518 . 9264) (MAPL.Meta.Plot 9266 . 10593) (MAPL.Meta.ASCIIToLisp 10595 . 11495)) (
11529 13474 (MAPL.Meta.NewPlotCom 11539 . 11840) (MAPL.Meta.MoveCom 11842 . 12308) (MAPL.Meta.DrawCom 
12310 . 12621) (MAPL.Meta.EndPlotCom 12623 . 13057) (MAPL.Meta.NewPenCom 13059 . 13472)) (16880 19790 
(MAPL.Simple.TopLevel 16890 . 17706) (MAPL.Simple.FreeMenu 17708 . 19514) (MAPL.Simple.MakeIconWindow 
19516 . 19788)) (19818 27100 (MAPL.Simple.MakePlot 19828 . 22323) (MAPL.Simple.Plot 22325 . 27098)) (
30511 33501 (MAPL.Gen.TopLevel 30521 . 31327) (MAPL.Gen.FreeMenu 31329 . 33227) (
MAPL.Gen.MakeIconWindow 33229 . 33499)) (33529 45006 (MAPL.Gen.MakePlot 33539 . 36529) (MAPL.Gen.Plot 
36531 . 38142) (MAPL.Gen.ASCIIToLisp 38144 . 39718) (MAPL.Gen.NewPlot 39720 . 41084) (
MAPL.Gen.PlotObject 41086 . 42080) (MAPL.Gen.EndPlot 42082 . 42388) (MAPL.Gen.NewPen 42390 . 42736) (
MAPL.Gen.CollectData 42738 . 45004)))))
STOP