% Plotter for Octave
% By: Michael K. Pellegrino
% 2013 11 12
clear
%clf
disp( "" );
disp( "-------------------------------------" );
disp( " Plotter - By: Michael K. Pellegrino" );
disp( "   Written for Octave - 2013 11 12" );
disp( "  Default Values are in Parentheses" );
disp( "-------------------------------------" );
disp( "" );
Resolution=input( "Resolution (40): ");
if( size( Resolution ) == [ 0 0 ] )
  Resolution=40;
endif
Resolution
disp("");
disp( "Just hit [ENTER] for no save" );
disp( "Must end with .jpg .png .gif and");
disp( " AND must have double-quotes around it." );
disp( "" );
Filename=input( "Image Filename (Put quotes around it): ");
if( size( Filename ) == [ 0 0 ] )
  Filename="";
  disp( "Don't Save" );
endif
Filename

startx=input( "Least value of x (-12): " );
if( size( startx ) == [ 0 0 ] )
  startx=-12;
endif
startx
disp("");
endx=input( "Greatest value of x (12): ");
if( size( endx ) == [ 0 0 ] )
  endx=12;
endif
endx
disp("");
starty=input( "Least value of y (-12): " );
if( size( starty ) == [ 0 0 ] )
  starty=-12;
endif
starty

disp("");
endy=input( "Greatest value of y (12): ");
if( size( endy ) == [ 0 0 ] )
  endy=12;
endif
endy
disp("");

disp("");
eq=input( "Equation in QUOTES! (x*x): ");
if( size( eq ) == [ 0 0 ] )
  eq="x*x";
endif
eq
disp("");

disp( "you MUST put double-quotes around the title!" );
Title=input("Enter Title for the Graph (your equation): ");
if( size( Title ) == [ 0 0 ] )
  Title=eq;
endif
Title
disp("");

hold on
title( Title );
xlabel('x');
axis ([ startx endx starty endy ]);
step=1/Resolution;
for x = startx:step:endx
  plot( x, eval( eq ), "." );
endfor

if( size(Filename) == [ 0 0 ])
  disp( "No filename given, so no file saved." )
else
  saveas( 1, Filename );
endif
