Discussion in "Software" started by    kirangowle    Feb 24, 2011.
Thu Feb 24 2011, 09:58 am
#1
Hi Guys,

This is my one of my old code which is wrtten in Turbo c Complier, But Now i am finding the errors while compling, I am sending data through parallel port.I have used graphics mode for vehicle location.
/*  Online Vehicle Tracking with Remote Lock by Dev...>
Â¥<...ruleS  */

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<bios.h>

#include<stdlib.h>

#include<dos.h>


#define ON 1
#define OFF 0

unsigned char one;
unsigned char two;
unsigned char three;
unsigned char four;

int arr[16][2];
int pos,u;
char com[' '],ori[' ']="devrules",fh;

void menu();
void hardware();
void erase(int);
void erase1(int);
void lock();

void main()
{
	int i,index1;
	int gdriver = DETECT, gmode, errorcode;

	outportb(0x378,0);


	/* initialize graphics and local variables */
	initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

	/* read result of initialization */
	errorcode = graphresult();
	if (errorcode != grOk)  /* an error occurred */
	{
		printf("Graphics error: %s\n", grapherrormsg(errorcode));
		printf("Press any key to halt:");
		getch();
		exit(1); /* terminate with an error code */
	}



      setlinestyle(SOLID_LINE,2,THICK_WIDTH);

      rectangle(0,0,getmaxx(),getmaxy());

      line(0,50,getmaxx(),50);

    //   setcolor(2);

      settextstyle(4,0,3);

      outtextxy(150,15,"Real Time Vehicle Tracking");

      outtextxy(170,80,"Under the guidance of");
      outtextxy(180,110,"Sri.G.Narayanswamy");
      outtextxy(180,130,"rayanswamy");
      outtextxy(180,150,"swamy");

       outtextxy(getmaxx()-150,getmaxy()-150,"Kiran.M");
       outtextxy(getmaxx()-150,getmaxy()-125,"Vinay.S");
       outtextxy(getmaxx()-150,getmaxy()-105,"Raju.D.H");

       getch();
cleardevice();

	for(i=1;i<=4;++i)
	{
	     arr[i][0]=(getmaxx()*(i-1)/4+5);
	     arr[i][1]=60;
	     arr[i+4][0]=(getmaxx()*(i-1)/4)+5;
	     arr[i+4][1]=126;
	     arr[i+8][0]=(getmaxx()*(i-1)/4)+5;
	     arr[i+8][1]=194;
	     arr[i+12][0]=(getmaxx()*(i-1)/4)+5;
	     arr[i+12][1]=265;
	}



	menu();
	closegraph();
}

/*-------------------------------------------------------------------------*/
		    /*--- FUNCTION TO DISPLAY MENU ---*/
/*-------------------------------------------------------------------------*/

void menu()
{
       char select=1,ch='0';
       int again=0,in;

       setbkcolor(0);
       setlinestyle(SOLID_LINE,1,THICK_WIDTH);
       rectangle(0,0,getmaxx(),getmaxy());
       rectangle(2,2,getmaxx()-2,getmaxy()-2);
       setlinestyle(0,0,4);
       line(0,42,getmaxx(),42);
       line(0,420,getmaxx(),420);
       line(0,450,getmaxx(),450);

       settextstyle(4,0,3);
       setcolor(2);
       outtextxy(10,5,"ONLINE VEHICLE TRACKING WITH REMOTE LOCK");

       setlinestyle(DOTTED_LINE,0,NORM_WIDTH);

       settextstyle(11,0,1);
       setcolor(15);
       outtextxy(250,160," START MONITORING ");

       outtextxy(290,270,"  EXIT ");
       setcolor(4);
       outtextxy(250,430,"PRESS Esc TO ABORT");
       settextstyle(4,0,2);
       setcolor(6);
       outtextxy(80,448,"Designed by Nithyananda.M, Ravikumar.R & Naveen.H");
       setcolor(9);
       rectangle(240,150,402,180);

       while(1)
       {
	       if(again==0)
	       {
			while(ch!=13)
			{
				ch=getch();
				if(ch==80)
				{
					select=2;
					in=6;
					erase(in);
					settextstyle(11,0,1);
					setcolor(15);
					outtextxy(250,160," START MONITORING ");
					outtextxy(290,270,"  EXIT ");
					setlinestyle(DOTTED_LINE,0,NORM_WIDTH);
					setcolor(9);
					rectangle(240,260,402,290);
				}
				if(ch==72)
				{
					select=1;
					in=10;
					erase1(in);
					in=11;
					erase1(in);
					settextstyle(11,0,1);
					setcolor(15);
					outtextxy(250,160," START MONITORING ");
					outtextxy(290,270,"  EXIT ");
					setlinestyle(DOTTED_LINE,0,NORM_WIDTH);
					setcolor(9);
					rectangle(240,150,402,180);
				}
				if(ch==27)
					exit(0);
			}

			if(select==1)
			{
				hardware();
				again=1;
			}

			if(select==2)
				exit(0);
	       }

	       select=getch();

	       if(select=='l')
			lock();

	       if(select==27)
			exit(0);
       }
}

/*-------------------------------------------------------------------------*/
     /*--- FUNCTION TO READ DATA CONTINEOUSLY FROM HARDWARE PORT ---*/
/*-------------------------------------------------------------------------*/

void hardware()
{
	 int index,c;
	 char r;

	 setfillstyle(1,0);
	 bar(0,0,getmaxx(),getmaxy());
	 setbkcolor(0);
	 setlinestyle(0,0,3);
	 setcolor(15);
	 rectangle(0,0,getmaxx(),getmaxy());
	 rectangle(2,2,getmaxx()-2,getmaxy()-2);
	 setlinestyle(0,0,3);
	 line(0,42,getmaxx(),42);
	 line(0,420,getmaxx(),420);
	 line(0,450,getmaxx(),450);
	 settextstyle(4,0,3);
	 setcolor(2);
	 outtextxy(10,5,"ONLINE VEHICLE TRACKING WITH REMOTE LOCK");
	 settextstyle(11,0,1);
	 setcolor(4);
	 outtextxy(195,430,"PRESS 'l' TO LOCK or Esc TO EXIT");
	 settextstyle(4,0,2);
	 setcolor(6);
	 outtextxy(80,448,"Designed by Nithyananda.M, Ravikumar.R & Naveen.H");
	 setlinestyle(0,0,3);

	 setcolor(15);
	 line(getmaxx()/2,43,getmaxx()/2,419);
	 line(0,220,getmaxx(),220);

	 settextstyle(11,0,1);
	 outport(0x378,0);

	 while(!kbhit())
	 {
		c=inp(0x379);

		if((c & 0X10)==0 && (c & 0X10)!=one)
		{
			while(r!='u')
			{
				index=7;
				erase(index);
				index=13;
				erase1(index);
				index=15;
				erase1(index);
				index=5;
				erase(index);
				delay(320);
				setcolor(9);
				outtextxy(130,130,"AREA1");
				setcolor(4);
				outtextxy(115,145,"INTRUDER");
				setcolor(2);
				outtextxy(75,160,"PRESS 'u' TO UNLOCK");
				delay(320);
				outport(0x378,1);
				fflush(stdin);
				r=getch();
				if(r=='u')
				{
					 pos=155;
					 u=0;
					 setlinestyle(0,0,3);
					 setcolor(12);
					 rectangle(70,110,250,180);
					 setfillstyle(1,7);
					 bar(71,111,249,179);
					 setcolor(0);
					 outtextxy(85,130,"PASSWORD:");
					 while(fh!=13)
					 {
						  fflush(stdin);
						  fh=getch();
						  com[u++]=fh;
						  setcolor(15);
						  outtextxy(pos,130,"* ");
						  pos+=8;
					 }
					 fh='0';
					 com[u++]=NULL;
					 for(u=0;ori[u]!=NULL;u++)
					 {
						  if(ori[u]!=com[u])
						  {
							   setcolor(4);
							   outtextxy(85,155,"! <NOT MATCHING>
 !");
							   r='r';
						  }
					 }
					 if(r!='r')
					 {
						  setcolor(2);
						  outtextxy(75,155,"!<PASSWORD MATCHING>
!");
					 }
					 sleep(1);
					 setfillstyle(1,0);
					 bar(69,109,251,181);
				}
			}
			setfillstyle(1,0);
			bar(69,109,251,181);
			delay(320);
			setcolor(9);
			outtextxy(130,130,"AREA1");
			setcolor(4);
			outtextxy(115,145,"INTRUDER");
			setcolor(2);
			outtextxy(75,160,"UNLOCKED on REQUEST");
			outport(0x378,0);
		}

		if((c & 0X20)==0 && (c &  0X20)!=two)
		{
			r='0';
			index=5;
			erase(index);
			index=13;
			erase1(index);
			index=15;
			erase1(index);
			setcolor(9);
			outtextxy(450,130,"AREA2");
			outport(0x378,0);
		}

		if((c &0x08)==0 && (c & 0x08)!=three)
		{
			r='0';
			index=5;
			erase(index);
			index=7;
			erase(index);
			index=15;
			erase1(index);
			setcolor(9);
			outtextxy(130,320,"AREA3");
			outport(0x378 ,0);
		}

		if((c & 64)==0 && (c & 64)!=four)
		{
			r='0';
			index=5;
			erase(index);
			index=7;
			erase(index);
			index=13;
			erase1(index);
			setcolor(9);
			outtextxy(450,320,"AREA4");
			outport(0x378,0);
		}

		one=(c & 8);
		two=(c & 16);
		three=(c & 0x20);
		four=(c & 64);
	}
}

/*-------------------------------------------------------------------------*/

void lock()
{
       char ch='0';
       int mach=0;
       while(mach!=1)
       {
	       setlinestyle(0,0,3);
	       setcolor(12);
	       rectangle(220,170,420,270);
	       setfillstyle(1,7);
	       bar(221,171,419,269);
	       setcolor(4);
	       outtextxy(260,200,"VEHICLE LOCKED");
	       outtextxy(245,235,"PRESS 'u' TO UNLOCK");
	       outport(0x378,1);
	       while(ch!='u')
	       {
			ch=getch();
	       }
	       if(ch=='u')
	       {
			 pos=320;
			 u=0;
			 setlinestyle(0,0,3);
			 setcolor(12);
			 rectangle(220,170,420,270);
			 setfillstyle(1,7);
			 bar(221,171,419,269);
			 setcolor(0);
			 outtextxy(245,200,"PASSWORD:");
			 while(fh!=13)
			 {
				  fflush(stdin);
				  fh=getch();
				  com[u++]=fh;
				  setcolor(15);
				  outtextxy(pos,200,"*");
				  pos+=8;
			 }
			 fh='0';
			 com[u++]=NULL;
			 for(u=0;ori[u]!=NULL;u++)
			 {
				  if(ori[u]!=com[u])
				  {
					   setcolor(4);
					   outtextxy(245,230,"! <NOT MATCHING>
 !");
					   ch='r';
				  }
			 }
			 if(ch!='r')
			 {
				  setcolor(2);
				  outtextxy(235,230,"!<PASSWORD MATCHING>
!");
				  mach=1;
			 }
			 sleep(1);
	       }
	       if(ch=='u')
	       {
		       outport(0x378,0);
		       setfillstyle(1,7);
		       bar(221,171,419,269);
		       setcolor(9);
		       outtextxy(258,220,"VEHICLE UNLOCKED");
		       sleep(1);
		       setfillstyle(1,0);
		       bar(219,169,421,271);
		       hardware();
		}
       }
}

/*-------------------------------------------------------------------------*/

void erase(int ch)
{
	setfillstyle(1,0);
	bar(arr[ch][0],arr[ch][1],arr[ch][0]+250,arr[ch][1]+60);
}

void erase1(int ch)
{
	setfillstyle(1,0);
	bar(arr[ch][0],arr[ch][1],arr[ch][0]+175,arr[ch][1]+150);
}




The errors are Undefined symbol setfillstyle in module, undefined symbol initgraph etc...
I have cheeked the path of BGI folder its also correct.
This is code is around of 3-4 years old. Is i need to change the compiler,Currently i m using turbo C++ 3.0 version.

Tue Mar 01 2011, 06:31 pm
#2
yeah probably OS is creating this problem... I donno much about Turbo C++ and gfx in C++. I wish i could help.

[Topic moved to Computer Related > Software]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm