/* 
 * inputp1p2 
 *
 *
 * Input for new P2 and P1 plotting coordinates
 * Marek Krawus,  PCC, March '89
 */

#include "defn.h"

inputP1P2()
{
    float   X1, Y1, X2, Y2;

    X1 = rintx(getval());
    if (X1 < 0.0)
    {
	if (DEBUG)
	    fprintf(stderr,
		    "WARNING: wrong value of parameter in IP instruction\n");
	return;
    }
    X2 = X1 + (P2x - P1x);

    if (test_token())
    {
	Y1 = rintx(getval());
	if (Y1 < 0.0)
	{
	    if (DEBUG)
	        fprintf(stderr,
		    "WARNING: wrong value of parameter in IP instruction\n");
	    return;
	}
	Y2 = Y1 + (P2y - P1y);
    } else
    {
	if (DEBUG)
	    fprintf(stderr,
		"ERROR: wrong number of parameters in IP instruction\n");
	return;
    }

    if (test_token())
    {
	X2 = rintx(getval());
	if (X2 < 0.0)
	{
	    if (DEBUG)
	        fprintf(stderr,
		    "ERROR: wrong value of parameters in IP instruction\n");
	    return;
	}
	if (X2 == X1)
	    X2 = X1 + 1.0;
    }
    if (test_token())
    {
	Y2 = rintx(getval());
	if (Y2 < 0.0)
	{
	    if (DEBUG)
	        fprintf(stderr,
		    "ERROR: wrong value of parameter in IP instruction\n");
	    return;
	}
	if (Y2 == Y1)
	    Y2 = Y1 + 1.0;
    }
    P1x = X1;
    P1y = Y1;
    P2x = X2;
    P2y = Y2;

    redefineP1P2();      /* in user_unit.c   */
}
