/*
COMPUTER SCIENCE PROJECT
PDA
Personal Digital Asistant

Made by: Rohit Rawat
XII-C
VVDAV Public School, Vikas Puri, New Delhi.
*/

#include<graphics.h> //for graphic functions
#include<iostream.h> //for input-output
#include<fstream.h> //for file I/O
#include<conio.h> //for getch, clrscr, gotoxy, kbhit
#include<string.h> //for string functions
#include<stdio.h> //for sscanf, sprintf, remove etc.
#include<dos.h> //for mouse, delay, sound, time etc.
#include<stdlib.h> //for rand , itoa, exit etc.
#include<iomanip.h> //for setw
#include<ctype.h> //for isprint
#include<math.h> //for floor, modf etc.

//Prototypes of main component functions
void diary();
void calendar();
void showtime();
void calculator();
void options();
void help();

void app();
void drwsqr(int,int,int,int,int=0);
void drwrct(int,int,int,int,int);
int getapps();
int validate_date(int,int,int);
class win;
void winfunc(win *);
void alarm(char*,win *);
void paint();

//Structures used
struct opts
{
int start_graphic;
int end_graphic;
int rtc;
char name[15];
int theme;
int crc;
} ini; //stores program settings
struct appo {
char name[40];
int dd,mm,yy;
int h,m;
};
struct {
int hrs;
int min;
} alarm_time; //stores alarm time
struct theme
{
int bak;
int tex;
int title;
int buta;
int buti;
char name[10];
};
theme themes[3]={ { DARKGRAY,WHITE,BLUE,YELLOW,RED,"Default" },
{ LIGHTBLUE,WHITE,BLUE,BLUE,CYAN,"Blue" },
{ GREEN,YELLOW,RED,RED,DARKGRAY,"Fire" }
}; //stores window colour themes

//Constants used:
//Window sizes
#define AUTO 0
#define FULL 1
#define INPT 2
#define FREE 4
//Theme names
#define GREEN 0
#define BLUE 1
#define FIRE 2

/*Class to implement the mouse interface.
It utilizes the interrupt number 0x33 to perform the various
mouse operations.*/

class mouse
{
private:
union REGS i,o; //from <dos.h>
public:
mouse() //constructor
{
initmouse();
}
void initmouse() //initialises the mouse
{
i.x.ax=0;
int86 ( 0x33,&i,&o );
}
void showmouseptr() //display the pointer
{
i.x.ax=1;
int86 ( 0x33,&i,&o );
}
void hidemouseptr() //hide the pointer
{
i.x.ax=2;
int86 ( 0x33,&i,&o );
}
void getmousepos(int &button,int &x,int &y)
{ //to obtain mouse coordinates
i.x.ax=3; //and button status
int86 ( 0x33,&i,&o );
button=o.x.bx;
x=o.x.cx;
y=o.x.dx;
}
};

/*Button class - To draw a button composed of a rectangle with
circular sides at the given coordinates in the specified colour.*/
class button
{
char text[21];
int x,y,rlen,len;
int state;
public:
int c1,c2;
button();
void s(int a,int b,char *s);
void draw(int);
};
button::button() //constructor
{
strcpy(text,"");
state=0;
c1=RED;
c2=YELLOW;
}
void button::s(int a,int b,char *s) //settings
{
x=a;
y=b;
strcpy(text,s);
}
void button::draw(int state) //draws the button
{
int col;
rlen=strlen(text);
if(rlen<=12)
len=12;
else if(rlen<=16)
len=16;
else len=20;
len=len*7;
rlen=rlen*7;
if(state==0)
col=c1;
else
col=c2;
setcolor(BLACK);
circle(x-len/2,y,10);
setfillstyle(1,col);
floodfill(x-len/2-6,y,BLACK);
circle(x+len/2,y,10);
setfillstyle(1,col);
floodfill(x+len/2+6,y,BLACK);
setfillstyle(1,col);
int pol[]={x-len/2,y-10,x+len/2,y-10,x+len/2,y+11,x-len/2,y+11};
fillpoly(4,pol);
settextstyle(SMALL_FONT,HORIZ_DIR,0);
setusercharsize(5,4,2,1);
if(state==1)
{
setusercharsize(5,4,9,4);
outtextxy(x-rlen/2+2,y-15,text);
}
if(state==0)
outtextxy(x-rlen/2+2,y-12,text);
if(state==-1)
{
setusercharsize(5,4,2,1);
outtextxy(x-rlen/2+2,y-10,text);
}
settextstyle(SMALL_FONT,HORIZ_DIR,5);
}

////////////////END OF button CLASS/////////////////////////
////////////////////////////////////////////////////////////


/* win class - the GUI backbone of the program.
This class allows you to draw a window on the screen having
extremely close resemblence with a typical Windows98(R) screen.
Once this class is defined, it makes programming in GUI mode
a childs play. It contains inbuilt functions to display the
contents in Windows98(R) manner and to input from keyboard
or mouse via buttons.*/

class win
{
int x1,y1,x2,y2; //top-left coordinates of the window
int maxx,maxy,cx,cy; //maximum and central coordinates
int type; //type of window- NORM/INPT/FULL/FREE
int w,h,tx; //width, height and no. of text lines
int rect[8]; //stores all four coordinates of the window
int _graphic; //if graphics mode is present
int bigbk,titlebk,bigtxt; //background, title & text colours
char text[15][80]; //store the body text
char title[30]; //store title text
char ip[30]; //the title for input window in INPT type
int buts; //store no. of buttons
char btxt[10][20]; //store button texts
int wait; //to wait for key hit or not
theme t; //the colour theme of the window
button b1; //to draw the buttons
mouse m; //an object of mouse class
void setrect(int,int,int,int,int,int,int,int); //to initialise rect[8]
void drwsqr(int,int,int,int,int=0); //draws a square
void drwrct(int,int,int,int,int); //draws a rectangle

public:

char inpt[50]; //to store inputed text - in INPT
int choice; //to store button selected by user
int func; //if there is a realtime function

win(); //initialise the window settings
void stl(char*); //set title text
void stx(int,char*); //set body text (according to line no.)
void atx(int,char*); //append to a text line
void shw(int,int); //set height and width in characters
void sxy(int,int,int,int); //set height and width in pixels
void trans(); //calculate coordinates
void st(int); //set window type- NORM/INPT/FULL/FREE
void sb(int); //set the no. of buttons
void sbt(int,char*); //set buton text (according to button no.)
void sip(char*); //set input window title
void settheme(int=BLUE); //set colour scheme for window
void setwait(int); //set wait status
void getclose(int &xx2,int &yy1); //to obtain to-right(X) coordinates
void draw(); //calls trans(), showbody() and draw() in order
void showbody(); //only draws the body
void show(); //draws the buttons and gets any input etc.
};

win::win()
{
if(graphresult()!=grOk) //check if graphics are initalised
{
_graphic=0;
}
else
_graphic=1;
maxx=getmaxx();
maxy=getmaxy();
cx=maxx/2;
cy=maxy/2;
x1=cx-200; //default window coordinates
y1=cy-100;
x2=cx+200;
y2=cy+100;
type=AUTO;
h=5;
w=10;
tx=0;
setrect(x1,y1,x2,y1,x2,y2,x1,y2);
bigbk=DARKGRAY;
titlebk=BLUE;
bigtxt=WHITE;
buts=0;
wait=1;
choice=1;
func=0;
for(int i=0;i<10;i++)
strcpy(btxt[i],"");
for(i=0;i<15;i++)
strcpy(text[i],"");
stl("Untitled");
sip("");
}
void win::stl(char *s)
{
sprintf(title," %s",s);
}
void win::stx(int i,char *s)
{
if(i<=15) {
if(i-1>tx)
tx=i-1;
strcpy(text[i-1],s);
}
if(h<tx+5)
h=tx+5;
if(strlen(s)>w)
{
w=strlen(s)+6;
}
}
void win::atx(int i,char *s)
{
if(i<=tx+1)
{
strcat(text[i-1],s);
}
}
void win::shw(int a,int b)
{
if(b==0) h=a;
else if(a==0) w=b;
else
{
h=a;
w=b;
}
}
void win::sxy(int a,int b,int c,int d)
{
type=FREE;
x1=a;
y1=b;
h=c;
w=d;
}
void win::trans()
{
if(type==AUTO||type==INPT)
{
if(type==INPT)
{
strcpy(title," INPUT...");
strcpy(text[0],"");
stx(6,"Please input...");
stx(7,"Hit ENTER to accept or ESC to cancel.");
wait=0;
}
if(y2-y1<(h*13)+15)
{
y1=(maxy/2)-(((h*15)+15)/2);
y2=(maxy/2)+(((h*13)+15)/2);
}
if(x2-x1<(w*8)+4)
{
x1=(maxx/2)-((w*10)+4)/2;
x2=(maxx/2)+((w*10)+4)/2;
}
}
if(type==FULL)
{
x1=y1=1;
x2=maxx;
y2=maxy;
}
if(type==FREE)
{
if(y2-y1<(h*13)+15)
{
y2=y1+((h*13)+15);
}
if(x2-x1<(w*8)+4)
{
x2=x1+(w*8)+4;
}
if(h>0&&h<=5)
y2=y1+100;
}
if(buts>=3&&x2-x1<450) {
x1=cx-250;
x2=cx+250;
}
setrect(x1,y1,x2,y1,x2,y2,x1,y2);
}
void win::st(int t)
{
type=t;
}
void win::sb(int n)
{
buts=n;
wait=0;
}
void win::sbt(int i,char *s)
{
if(i<=buts)
strcpy(btxt[i-1],s);
}
void win::sip(char *s)
{
strcpy(ip,s);
}
void win::settheme(int a)
{
bigbk=themes[a].bak;
titlebk=themes[a].title;
bigtxt=themes[a].tex;
b1.c1=themes[a].buti;
b1.c2=themes[a].buta;
}
void win::setwait(int a)
{
wait=a;
}
void win::getclose(int& xx2,int &yy1)
{
xx2=x2; yy1=y1;
}
void win::draw()
{
trans();
showbody();
show();
}
void win::showbody()
{
setcolor(WHITE);
setfillstyle(1,bigbk);
fillpoly(4,rect);
int ttle[]={x1,y1,x2,y1,x2,y1+15,x1,y1+15};
setfillstyle(1,titlebk);
fillpoly(4,ttle);
drwsqr(x1+2,y1+2,11,BLACK);
drwsqr(x2-13,y1+2,11,BLUE,1);
drwsqr(x2-27,y1+2,11,BLUE,2);
settextstyle(SMALL_FONT,HORIZ_DIR,5);
setcolor(WHITE);
outtextxy(x1,y1,title);
setcolor(bigtxt);
settextstyle(SMALL_FONT,HORIZ_DIR,6);
for(int ii=0;ii<=tx;ii++)
outtextxy(x1+10,y1+15+(13*ii),text[ii]);
}
void win::show()
{
int but=0,x,y,flag=0;
if(!_graphic) //if graphics are not initialised
{
cout<<text; //just display the text
return;
}
else {
if(buts==0&&type!=INPT)
{
if(wait)
{
m.showmouseptr();
while(1)
{
m.getmousepos(but,x,y);
if((but&1)==1)
{
while((but&1)==1)
m.getmousepos(but,x,y);
m.hidemouseptr();
wait=0;
break;
}
if(kbhit())
break;
}
}
}
if(type==INPT)
{
m.hidemouseptr();
button ok;
ok.s((x2-x1)/2+x1,y1+150," OK ");
ok.draw(1);
outtextxy(x1+10,y1+35,"Please Enter");
outtextxy(x1+110,y1+35,ip);
drwrct(x1+10,y1+60,x2-x1-20,20,BLACK);
char buf[80];
buf[0]='\0';
char ch,cha[2];
int x=x1+10,i=0;
setcolor(WHITE);
line(x,y1+80,x+10,y1+80);
do {
ch=getch();
cha[0]=ch;
cha[1]='\0';
if(ch==8&&x>=x1+10&&i>0)
{
setcolor(BLACK);
drwrct(x-10,y1+60,10,20,BLACK);
setcolor(WHITE);
line(x-20,y1+80,x-10,y1+80);
x-=10;
buf[i--]='\0';
}
else
if(isprint(ch))
{
setcolor(WHITE);
outtextxy(x,y1+60,cha);
x+=10;
line(x,y1+80,x+10,y1+80);
buf[i]=ch;
buf[++i]='\0';
}
} while(ch!=13&&ch!=27&&i<76);
strcpy(inpt,buf);
}
else
if(buts!=0)
{
int step=(x2-x1)/(buts+1);
int butx[6],buty[6];
wait=0;
char hit;
do {
if(buts<=3)
for(int i=1;i<=buts;i++)
{
butx[i-1]=x1+step*i;
buty[i-1]=y2-30;
b1.s(butx[i-1],buty[i-1],btxt[i-1]);
if(choice==i)
b1.draw(1);
else
b1.draw(0);
}
else
{
int m=60;
step=(x2-x1)/4;
int ctr=1;
if(buts/4+1==2)
for(int i=0;i<2;i++)
{ for(int j=1;j<=3&&ctr<=buts;j++)
{
butx[ctr-1]=x1+(step*j);
buty[ctr-1]=y2-m;
b1.s(butx[ctr-1],buty[ctr-1],btxt[ctr-1]);
if(choice==ctr)
b1.draw(1);
else
b1.draw(0);
m++;
ctr++;
}
m=30;
}
}
int a11,b11;
if(func)
{
win t;
t.settheme(FIRE);
t.st(FREE);
t.stl("Time");
t.sxy(475,150,5,20);
t.wait=0;
t.draw();
t.getclose(a11,b11);
outtextxy(480,b11+80,"ALARM :");
if(alarm_time.hrs>24)
outtextxy(550,b11+80,"NO ALARM");
else {
char temp[6];
itoa(alarm_time.hrs,temp,10);
strcat(temp,":");
outtextxy(a11-55,b11+80,temp);
itoa(alarm_time.min,temp,10);
outtextxy(a11-30,b11+80,temp);
}
}
int clk=0,key=0;
do
{
m.showmouseptr();
if(func)
winfunc(this);
m.getmousepos(but,x,y);
if((but&1)==1)
{
if(x>a11-13&&x<a11&&y>b11&&y<b11+13)
{
m.hidemouseptr();
func=0;
ini.rtc=0;
showbody();
break;
}
m.hidemouseptr();
if(x>x2-13&&x<x2&&y>y1&&y<y1+13)
{
choice=0;
hit=27;
clk=1;
flag=1;
//break;
}

for(int p=0;p<buts;p++)
{
if(x>butx[p]-35&&x<butx[p]+35&&y>buty[p]-12&&y<buty[p]+12)
{
choice=p+1;
hit=13;
clk=1;
break;

}
}
}
if(kbhit())
{
key=1;
}

}while(!clk&&!key);
if(key)
{
hit=getch();
if(hit==13) break;
if(hit==27)
{ choice=0; break; }
if(hit==77&&choice<buts)
{ choice++; hit=0; }
if(hit==77&&choice==buts)
choice=1;
if(hit==72&&choice>3)
choice-=3;
if(hit==80&&choice<=3)
if(buts>3)
choice+=3;
if(hit==75&&choice>1)
{ choice--; hit=0; }
if(hit==75&&choice==1)
choice=buts;
if(hit==77&&choice==buts)
choice=1;
sound(100);
nosound();
}
if(hit==13)
{
sound(500);
while((but&1)==1)
{ m.getmousepos(but,x,y);

if(buts<=3)
b1.s(x1+step*choice,y2-30,btxt[choice-1]);
else
if(choice<=3)
b1.s(x1+step*choice,y2-60,btxt[choice-1]);
else
b1.s(x1+step*(choice-3),y2-30,btxt[choice-1]);
b1.draw(-1);
flag=1;
}
nosound();
}
} while(flag==0);

}
if(wait)
getch();
}
}

void win::setrect(int a,int aa,int b,int bb,int c,int cc,int d,int dd)
{
rect[0]=a; rect[1]=aa;
rect[2]=b; rect[3]=bb;
rect[4]=c; rect[5]=cc;
rect[6]=d; rect[7]=dd;
}
void win::drwsqr(int x,int y,int sz,int col,int typ)
{
int coord[8]={x,y,x+sz,y,x+sz,y+sz,x,y+sz};
setfillstyle(1,col);
fillpoly(4,coord);
if(typ==1)
{
line(x,y,x+sz,y+sz);
line(x,y+sz,x+sz,y);
}
if(typ==2)
{
line(x+2,y+sz-2,x+sz-2,y+sz-2);
}
}
void win::drwrct(int x,int y,int sz1,int sz2,int col)
{
int coord[8]={x,y,x+sz1,y,x+sz1,y+sz2,x,y+sz2};
setfillstyle(1,col);
fillpoly(4,coord);
}

////////////////END OF win CLASS////////////////////////////
////////////////////////////////////////////////////////////

/*A class to cover the screen with stars*/
class star {
int p[20];
public:
void draw(int x,int y,int c);
void rain();
};
void star::draw(int x,int y,int c) //draws a single one
{
p[0]=0;p[1]=31;
p[2]=33;p[3]=31;
p[4]=43;p[5]=0;
p[6]=53;p[7]=31;
p[8]=86;p[9]=31;
p[10]=62;p[11]=50;
p[12]=70;p[13]=81;
p[14]=43;p[15]=62;
p[16]=16;p[17]=81;
p[18]=27;p[19]=50;
for(int i=0;i<20;i++)
{
if(i%2)
p[i]+=y;
else
p[i]+=x;
}
setfillstyle(1,c);
fillpoly(10,p);
}
void star::rain() //covers the whole screen
{
int i,j,k,l;
for(l=0;l<104;l+=52)
for(i=l,k=0;k<6-(l/52);i+=105,k++)
{
draw(i,5+l,rand()%14+1);
delay(50);
draw(i,96+l,rand()%14+1);
delay(50);
draw(i,197+l,rand()%14+1);
delay(50);
draw(i,298+l,rand()%14+1);
delay(50);
if(l<50)
draw(i,399+l,rand()%14+1);
}
}

////////////////END OF star CLASS///////////////////////////
////////////////////////////////////////////////////////////


void paint()
{
cleardevice();
setfillstyle(SOLID_FILL,LIGHTGRAY);
floodfill(5,5,LIGHTGRAY);
}

void drwsqr(int x,int y,int sz,int col,int typ)
{
int coord[8]={x,y,x+sz,y,x+sz,y+sz,x,y+sz};
setfillstyle(1,col);
fillpoly(4,coord);
if(typ==1)
{
line(x,y,x+sz,y+sz); //cross(X)
line(x,y+sz,x+sz,y);
}
if(typ==2)
{
line(x+2,y+sz-2,x+sz-2,y+sz-2); //minimise(_)
}
}

void drwrct(int x,int y,int sz1,int sz2,int col)
{
int coord[8]={x,y,x+sz1,y,x+sz1,y+sz2,x,y+sz2};
setfillstyle(1,col);
fillpoly(4,coord);
}

void save_set()
{
ofstream write_config;
write_config.open("pda.ini",ios::trunc);
write_config.write((char*)&ini,sizeof(opts));
}

void fwiz()
{
win first;
first.stl("FIRST TIME WIZARD");
first.stx(1,"Preparing to run for the first time...");
first.stx(2,"Please enter your NAME :");
first.stx(3,"Hit a key to continue..");
first.stx(5,"You can change it later from the Options menu.");
first.draw();
win input;
input.st(INPT);
input.sip("Name : ");
input.draw();
ini.start_graphic=1;
ini.end_graphic=1;
ini.rtc=1;
ini.theme=1;
strcpy(ini.name,input.inpt);
ini.crc=0;
for(int cc=0;cc<strlen(ini.name);cc++)
ini.crc+=ini.name[cc];
ini.crc=ini.crc*3;
paint();
}

opts read_ini()
{
opts temp;
ifstream read_config("pda.ini");
if(read_config==NULL)
{
fwiz();
save_set();
temp=ini;
}
else
{
read_config.read((char*)&temp,sizeof(opts));
int crc=0;
for(int cc=0;cc<strlen(temp.name);cc++)
crc+=temp.name[cc];
crc=crc*3;
if(temp.crc!=crc)
{
cout<<"CRC Check Failiure !!!\nPDA.INI is corrupt. Please re-enter the data.";
getch();
fwiz();
save_set();
temp=ini;
}
}
return temp;
}


int getapps()
{
appo a;
struct date d1;
getdate(&d1);
struct time t1;
int dd1=d1.da_day,m1=d1.da_mon,y1=d1.da_year,ctr=0;
int h=30,m=90;
ifstream in("PDA.DAT");
if(in!=NULL)
{
in.read((char*)&a,sizeof(appo));
while(!in.eof())
{
if(a.dd==dd1&&a.mm==m1&&a.yy==y1)
{ ctr++;
if(a.h<h||(a.h<=h&&a.m<m))
{
gettime(&t1);
if((int)t1.ti_hour<a.h||
((int)t1.ti_hour==a.h&&(int)t1.ti_min<a.m))
h=a.h; m=a.m; }
}
if(in.eof())
break;
in.read((char*)&a,sizeof(appo));
}
}
in.close();
alarm_time.hrs=h; alarm_time.min=m;
return ctr;
}

void main()
{
//Initialise graphics
int gd=DETECT,gm,error;
initgraph(&gd,&gm,"\\tc\\bgi");

//Check if graphics have been initialised correctly
error=graphresult();
if(error!=grOk)
{
clrscr();
initgraph(&gd,&gm," ");
cout<<"Graphics Error : "<<grapherrormsg(error);
exit(1);
}

ini=read_ini(); //read program settings


//show startup graphics
if(ini.start_graphic)
{
setfillstyle(6,9);
floodfill(5,5,getmaxcolor());
star s;
setlinestyle(DOTTED_LINE,0,THICK_WIDTH);
setcolor(GREEN);
rectangle(1,1,638,478);
rectangle(5,5,633,473);
moveto(120,100);
settextstyle(TRIPLEX_FONT,0,7);
setcolor(YELLOW);
outtext("WELCOME TO");
moveto(120,170);
lineto(500,170);
moveto(50,200);
settextstyle(GOTHIC_FONT,0,10);
setcolor(RED);
outtext("P . D . A");
getch();
setlinestyle(SOLID_LINE,0,0);
s.rain();
delay(200);
setfillstyle(1,8);
int sqr[8]={300,220,340,220,340,260,300,260};
for(int z=0;z<=300;z+=20)
{
sqr[0]=sqr[6]-=z;
sqr[2]=sqr[4]+=z;
sqr[1]=sqr[3]-=z;
sqr[5]=sqr[7]+=z;
fillpoly(4,sqr);
delay(100);
}
setcolor(YELLOW);
settextstyle(TRIPLEX_FONT,0,2);
moveto(10,10);
outtext("I am deeply thankful to Babita maam");
moveto(10,33);
outtext("for her support and encouragement in");
moveto(10,56);
outtext("the making of this project.");
moveto(400,110);
outtext("Rohit Rawat");
moveto(400,140);
outtext("XII-C");
moveto(400,170);
outtext("Roll No - 33");
for(int zz=1;zz<640;zz++)
{
putpixel(zz,105,zz%15);
putpixel(zz,107,zz%15);
putpixel(zz,195,15-zz%15);
putpixel(zz,197,15-zz%15);
}
s.draw(450,10,BLUE);
getch();
s.rain();

///////////////////////////

//Show acknowledgements
win ack;
ack.settheme(FIRE);
ack.stl("Acknowledgement....");
ack.stx(1,"I am deeply thankful to Babita maam");
ack.stx(2,"for her support and encouragement in");
ack.stx(3,"the making of this project.");
ack.stx(6," Rohit Rawat");
ack.stx(7," XII-C");
ack.stx(8," Roll No - 33");
ack.draw();
}
//Show Reminders
paint();
int n=getapps();
if(n>0)
{
char temp[5];
itoa(n,temp,10);
win alert;
alert.settheme(ini.theme);
alert.stl("PDA Alert !!!");
alert.stx(3," You have ");
alert.atx(3,temp);
alert.atx(3," appointments");
alert.stx(5," Scheduled for Today.");
alert.draw();
}

//Show Main Screen
win mainscr;
mainscr.st(FULL); //set as fullscreen
mainscr.settheme(ini.theme);
mainscr.stl("Welcome to P.D.A.");
mainscr.stx(2,"Welcome ");
mainscr.atx(2,ini.name);
mainscr.stx(4,"PDA, your friendly and easy to use assistant is at your service.");
mainscr.stx(6,"PDA (Personal Digital Assistant) is a friendly and");
mainscr.stx(7,"easy to use way to organise yourself and manage your ");
mainscr.stx(8,"time properly.");
mainscr.stx(14,"Select Help from the Options Menu for more help");
mainscr.stx(15,"Please choose one of the sections below :");
mainscr.sb(6);
mainscr.sbt(1,"DIARY");
mainscr.sbt(2,"CALENDAR");
mainscr.sbt(3,"CLOCK");
mainscr.sbt(4,"CALCULATOR");
mainscr.sbt(5,"OPTIONS");
mainscr.sbt(6,"EXIT");
mainscr.func=ini.rtc;

int exit=0;
while(!exit)
{
mainscr.draw();
if(mainscr.choice==1)
{
diary();
}
if(mainscr.choice==2)
{
calendar();
}
if(mainscr.choice==3)
{
showtime();
}
if(mainscr.choice==4)
{
calculator();
}
if(mainscr.choice==5)
{
options();
//Apply new settings
mainscr.func=ini.rtc;
mainscr.stx(2,"Hi ");
mainscr.atx(2,ini.name);
mainscr.atx(2,",");
mainscr.settheme(ini.theme);
}
if(mainscr.choice==6||mainscr.choice==0)
{
paint();
mainscr.choice=1;
//confirm exit
win egxit;
egxit.settheme(FIRE);
egxit.stl("Exit Confirmation...");
egxit.stx(1,"DO YOU REALLY WANT TO EXIT ??");
egxit.sb(2);
egxit.sbt(1,"YES");
egxit.sbt(2,"NO");
egxit.draw();
exit=!(egxit.choice-1);
}
}

//Show end graphics
if(ini.end_graphic)
{
star s;
s.rain();
}

//Close graphics
closegraph();
restorecrtmode();
}

////////////////////////
//APPOINTMENTS MANAGER//
////////////////////////

/* appointment class : To run the Appointments Manager */
class appointment {
void addapp();
void show(int);
void pack();
void del();
public:
void menu();
};
///////////////////END OF PROTOTYPE///////////////////////

//Appointments Manager function
void diary()
{
appointment a;
a.menu();
}

////////////DEFINITION OF appointment CLASS///////////////
void appointment::menu()
{
paint();
win ap;
ap.settheme(ini.theme);
ap.stl("Appointments/Tasks-Scheduler");
ap.st(FULL);
ap.stx(2,"PDA Appointment Manager.");
ap.stx(4,"Select Today`s to list all appointments scheduled for Today");
ap.stx(5,"Select Show All to display all the appointments");
ap.stx(6,"Select Pack old to delete all appointments prior to Today");
ap.stx(7,"Select Add New to add a new appointment");
ap.stx(8,"Select Delete All to delete all the present and future");
ap.stx(9,"appointments");
ap.stx(14,"Please Choose....");
ap.sb(6);
ap.sbt(1,"Today`s");
ap.sbt(2,"Show All");
ap.sbt(3,"Pack Old");
ap.sbt(4,"Add New");
ap.sbt(5,"Delete All");
ap.sbt(6,"EXIT");
do {
ap.draw();
if(ap.choice==1)
show(2);
if(ap.choice==2)
show(1);
if(ap.choice==3)
pack();
if(ap.choice==4)
addapp();
if(ap.choice==5)
del();
} while(ap.choice!=13&&ap.choice!=6&&ap.choice!=0);

}
void appointment::addapp()
{
appo temp;
int a,b,c,d,e;
win nm;
nm.st(INPT);
nm.sip("Name");
nm.draw();
strcpy(temp.name,nm.inpt);
win das;
das.stl("Choose date...");
das.stx(1,"Please choose the date :");
das.sb(3);
das.sbt(1,"Today");
das.sbt(2,"Tommorrow");
das.sbt(3,"Other");
das.draw();
if(das.choice==3)
{
while(1)
{
win dt;
dt.st(INPT);
dt.sip("Date (dd-mm-yy)");
dt.draw();
sscanf(dt.inpt,"%d-%d-%d",&a,&b,&c);
fflush(stdin);
int ret=validate_date(a,b,c);
if(ret==0) break;
win error;
error.stl("INVALID INPUT");
error.stx(3,"Please re-enter the date.");
error.draw();
}
}
struct date d1;
getdate(&d1);
if(das.choice==1)
{
a=d1.da_day;
b=d1.da_mon;
c=d1.da_year;
}
if(das.choice==2)
{
int months[12]={ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if(d1.da_day==months[d1.da_mon-1])
{
d1.da_day=1;
if(d1.da_mon==12)
{
d1.da_mon=1;
d1.da_year++;
}
else
d1.da_mon++;

}
else
d1.da_day++;
a=d1.da_day;
b=d1.da_mon;
c=d1.da_year;
}
temp.dd=a;
temp.mm=b;
temp.yy=c;
win tm;
tm.st(INPT);
tm.sip("Time (hh-mm)");
tm.draw();
sscanf(tm.inpt,"%d-%d",&d,&e);
fflush(stdin);
if(d<=12)
{
win ap;
ap.stl("AM or PM ?");
ap.sb(2);
ap.sbt(1,"A.M.");
ap.sbt(2,"P.M.");
ap.draw();
if(ap.choice==2)
{
if(d!=12)
d+=12;
}
else if(d==12) d=0;
}
if(d>24) d=d%24;
if(e>60) e=e%60;
temp.h=d;
temp.m=e;
ofstream file;
file.open("PDA.DAT",ios::out|ios::app);
file.write((char*)&temp,sizeof(appo));
file.close();
getapps();
}
void appointment::show(int c)
{
struct date d1;
getdate(&d1);
int dd1=d1.da_day,m1=d1.da_mon,y1=d1.da_year;
win all;
if(c==1)
all.stl("Show All Appointments");
else
all.stl("Show Today`s Appointments");
all.stx(1," Name บ Date บ Time");
all.stx(2,"อออออออออออออออออออออออออออสอออออออออออสอออออออออออออออออ");
all.st(FULL);
all.sb(1);
all.sbt(1,"Continue..");
appo a;
int ctr=3,SNo=0;
char t[5];
char dt[25];
ifstream file;
file.open("PDA.DAT",ios::in);
if(file!=NULL)
{
while(file.read((char*)&a,sizeof(appo)))
{
if((c==2&&a.dd==dd1&&a.mm==m1&&a.yy==y1)||c==1)
{
SNo++;
all.stx(ctr,itoa(SNo,t,10));
all.atx(ctr," | ");
all.atx(ctr,a.name);
for(int i=2;i<25-strlen(a.name);i++)
all.atx(ctr," ");
all.atx(ctr,"| ");
all.atx(ctr,itoa(a.dd,t,10));
all.atx(ctr,"-");
all.atx(ctr,itoa(a.mm,t,10));
all.atx(ctr,"-");
all.atx(ctr,itoa(a.yy,t,10));
all.atx(ctr," ");
all.atx(ctr,itoa(a.h,t,10));
all.atx(ctr," Hrs ");
all.atx(ctr,itoa(a.m,t,10));
all.atx(ctr," min.");
ctr++;
}
if(ctr%12==0)
{
all.draw();
ctr=3;
}
}
}
if(SNo==0)
all.stx(4," NO APPOINTMENTS ");
if(ctr%12)
all.draw();
file.close();
}
void appointment::pack()
{
win sure;
sure.stl("Are You Sure ??");
sure.stx(2,"Are you sure you want to delete all the");
sure.stx(3,"old Appointments scheduled for yesterday and earlier?");
sure.sb(2);
sure.sbt(1,"YES-Delete");
sure.sbt(2,"NO-Return");
sure.draw();
if(sure.choice==1)
{
ifstream file;
ofstream temp;
appo a;
struct date d;
getdate(&d);
file.open("PDA.DAT");
temp.open("PDA.TMP");
while(file.read((char*)&a,sizeof(appo)))
{
if(a.yy>d.da_year||(a.yy==d.da_year&&a.mm>d.da_mon)||
(a.yy==d.da_year&&a.mm==d.da_mon&&a.dd>=d.da_day))
temp.write((char*)&a,sizeof(appo));
}
file.close();
temp.close();
remove("PDA.DAT");
rename("PDA.TMP","PDA.DAT");
}
}
void appointment::del()
{
win confirm;
confirm.stl("Delete Confirmation");
confirm.stx(3,"Are you sure you want to");
confirm.stx(4,"delete all the entries ??");
confirm.sb(2);
confirm.sbt(1,"NO-Return");
confirm.sbt(2,"YES-Delete");
confirm.draw();
if(confirm.choice==2)
{
remove("PDA.DAT");
}
alarm_time.hrs=30; alarm_time.min=90;
}

////////////END OF appointment CLASS////////////////////////
////////////////////////////////////////////////////////////

////////////////
//CLOCK WINDOW//
////////////////

void showtime()
{
struct date date1;
getdate(&date1);
struct time time1;
gettime(&time1);
win timez;
timez.settheme(ini.theme);
timez.stl("PDA Clock");
timez.stx(2," The current time is :");
timez.stx(5," The current date is :");
timez.stx(8," Hit a key to Return");
timez.setwait(0);
timez.draw();
int m=0;
m=(int)time1.ti_hour/12;
gotoxy(46,14);
cout<<" "<<(int)date1.da_day<<" - "<<(int)date1.da_mon<<" - "<<date1.da_year<<" ";
gotoxy(1,1);

char timestr[20];
char tempstr[5];
mouse mou;
mou.initmouse();
mou.showmouseptr();
int b,x,y;
mou.getmousepos(b,x,y);
while(1)
{
gettime(&time1);
itoa((int)(time1.ti_hour<=12?time1.ti_hour:(int)time1.ti_hour-12),tempstr,10);
strcpy(timestr,tempstr);
strcat(timestr," : ");
itoa((int)time1.ti_min,tempstr,10);
strcat(timestr,tempstr);
strcat(timestr," : ");
itoa((int)time1.ti_sec,tempstr,10);
strcat(timestr,tempstr);
tempstr[0]=' ';
tempstr[1]=(m?'P':'A');
tempstr[2]='M';
tempstr[3]='\0';
strcat(timestr,tempstr);
drwrct(365,167,150,20,0);
outtextxy(370,167,timestr);
delay(100);
mou.getmousepos(b,x,y);
if((b&1)==1) { mou.hidemouseptr(); break; }
if(kbhit())
{ getch(); break; }
}
}

/////////////////////
//CALENDAR FUNCTION//
/////////////////////

void calendar()
{
paint();
int months[12]={ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
char *mn[12]={ "January","February","March","April","May","June",
"July","August","September","October","November","December" };
struct date d;
getdate(&d);
int temp=3,yy=d.da_year,mm=d.da_mon;
for(int i=1992;i<yy;i++)
{
if(i%4)
temp++;
else
temp=temp+2;
if(temp>7)
temp=temp%7;
}
if(!yy%4)
months[1]=29;
else
months[1]=28;
for(int j=1;j<mm;j++)
{
temp=temp+(months[j-1]%7);
if(temp>7)
temp=temp%7;
}
char title[25];
strcpy(title,"Calendar - ");
strcat(title,mn[mm-1]);
win calendar;
calendar.settheme(ini.theme);
calendar.stl(title);
calendar.stx(1,"Calender for the month of ");
calendar.atx(1,mn[mm-1]);
calendar.stx(2,"Hit a key to return.");
calendar.stx(4," Today:");
calendar.shw(25,40);
calendar.setwait(0);
calendar.draw();
gotoxy(49,8);
cout<<(int)d.da_day<<"/"<<mm<<"/"<<yy;
int x=10,k=0;
gotoxy(22,x);
cout<<" Mon Tue Wed Thu Fri Sat Sun";
x+=2;
gotoxy(22,x);
for(int ii=1;ii<temp;ii++)
{
cout<<" ";
k++;
}
for(int i1=1;i1<=months[mm-1];i1++)
{
k++;
cout<<setw(5)<<i1;
if(k>=7)
{
x+=2;
gotoxy(22,x);
k=0;
}
}
mouse m;
m.initmouse();
m.showmouseptr();
int a,b,c;
while(1)
{
m.getmousepos(a,b,c);
if((a&1)==1)
break;
if(kbhit())
{ getch();
break;
}
}
m.hidemouseptr();
}

//////////////
//CALCULATOR//
//////////////

void calculator()
{
void ins(int,char*,int&);
void dispr(float);
win calci;
calci.stl("CALCULATOR");
calci.setwait(0);
calci.shw(25,30);
calci.draw();
int a1,b1;
calci.getclose(a1,b1);
int step=60;
for(int j=0;j<=step*3;j+=step)
{
for(int i=0;i<=step*3;i+=step)
drwsqr(200+i,150+j,50,RED);
}
drwsqr(460,150,50,BLUE);
drwsqr(460,210,50,RED);
drwrct(200,100,step*4,30,0);
outtextxy(220,160,"7");
outtextxy(280,160,"8");
outtextxy(340,160,"9");
outtextxy(400,160,"/");
outtextxy(220,220,"4");
outtextxy(280,220,"5");
outtextxy(340,220,"6");
outtextxy(400,220,"X");
outtextxy(220,280,"1");
outtextxy(280,280,"2");
outtextxy(340,280,"3");
outtextxy(400,280,"-");
outtextxy(220,340,"0");
outtextxy(280,340,".");
outtextxy(340,340,"=");
outtextxy(400,340,"+");
outtextxy(470,170,"OFF");
outtextxy(480,220,"+");
outtextxy(480,240,"-");
mouse cm;
cm.initmouse();
cm.showmouseptr();
int b,x,y,flag=0,ctr=0,exit=0;
char buf[20];
int top=0;
float num1=0,num2=0,resu=0;
int code=0;
strcpy(buf,"");
//int c=0;//
while(!exit)
{
while(1)
{
cm.getmousepos(b,x,y);
if((b&1)==1)
{
while((b&1)==1) {
cm.getmousepos(b,x,y);
};
ctr=0;
if((x>a1-13&&x<a1&&y>b1&&y<b1+13)
||(x>460&&x<510&&y>150&&y<200))
{
cm.hidemouseptr();
exit=1;
break;
}
if(x>460&&x<510&&y>210&&y<260)
{
ctr=18;
flag=1;
}
for(int m=150;m<=150+3*step&&!flag;m+=step)
for(int n=200;n<=200+step*3;n+=step)
{ ctr++;
if(x<n+50&&x>n&&y<m+50&&y>m)
{ flag=1;
break;
}
}
if(flag)
{
sound(100);
delay(100);
nosound();
break;
}
}
}
if(flag)
switch (ctr)
{
case 1:
ins(7,buf,top);
break;
case 2:
ins(8,buf,top);
break;
case 3:
ins(9,buf,top);
break;
case 5:
ins(4,buf,top);
break;
case 6:
ins(5,buf,top);
break;
case 7:
ins(6,buf,top);
break;
case 9:
ins(1,buf,top);
break;
case 10:
ins(2,buf,top);
break;
case 11:
ins(3,buf,top);
break;
case 13:
ins(0,buf,top);
break;
case 14:
buf[top++]='.';
break;
case 4:
if(code==1)
{
num2=atof(buf);
resu=num1/num2;
dispr(resu);
num1=num2=resu=0;
strcpy(buf,"");
top=0;
}
else
{ num1=atof(buf);
resu=num2=0;
code=1;
dispr(resu);
}
strcpy(buf,"");
top=0;
break;
case 8:
if(code==2)
{
num2=atof(buf);
resu=num1*num2;
dispr(resu);
num1=num2=resu=0;
strcpy(buf,"");
top=0;
}
else
{ num1=atof(buf);
resu=num2=0;
code=2;
dispr(resu);
}
strcpy(buf,"");
top=0;
break;
case 12:
if(code==3)
{
num2=atof(buf);
resu=num1-num2;
dispr(resu);
num1=num2=resu=0;
strcpy(buf,"");
top=0;
}
else
{ num1=atof(buf);
resu=num2=0;
code=3;
dispr(resu);
}
strcpy(buf,"");
top=0;
break;
case 16:
if(code==4)
{
num2=atof(buf);
resu=num1+num2;
dispr(resu);
num1=num2=resu=0;
strcpy(buf,"");
top=0;
}
else
{ num1=atof(buf);
resu=num2=0;
code=4;
dispr(resu);
}
strcpy(buf,"");
top=0;
break;
case 15:
num2=atof(buf);
if(code==1)
if(num2==0)
{
resu=0;
drwrct(200,100,60*4,30,0);
outtextxy(210,110,"ERROR:DIVISION BY ZERO");
sound(200);
delay(2000);
nosound();
}
else
resu=num1/num2;
if(code==2)
resu=num1*num2;
if(code==3)
resu=num1-num2;
if(code==4)
resu=num1+num2;
dispr(resu);
code=0;
strcpy(buf,"");
resu=num1=num2=top=0;
break;
case 18:num1=atof(buf);
num1=num1*(-1);
ltoa(num1,buf,10);
break;
}
ctr=0;
flag=0;
}
}
void ins(int a,char buf[],int &top)
{
if(top<7) {
char temp[2];
itoa(a,temp,10);
buf[top++]=temp[0];
buf[top]='\0'; }
drwrct(200,100,60*4,30,0);
outtextxy(210,110,buf);
}
void dispr(float f)
{
char buf[20],t[5];
double temp;
long a=floor(f),b=10000*modf(f,&temp);
ltoa(a,buf,10);
ltoa(b,t,10);
strcat(buf,".");
strcat(buf,t);
drwrct(200,100,60*4,30,0);
outtextxy(210,110,buf);
}

////////////////
//OPTIONS MENU//
////////////////

void options()
{
win opts;
opts.stl("PDA Configuration");
opts.stx(1,"PDA options : ");
opts.stx(8,"Esc : Save and Exit.");
opts.sb(6);
opts.sbt(1,"<<1>>");
opts.sbt(2,"<<2>>");
opts.sbt(3,"<<3>>");
opts.sbt(4,"Change Name");
opts.sbt(5,"Change Theme");
opts.sbt(6,"PDA Help");
do {
if(ini.start_graphic)
opts.stx(3,"(1) Startup Animation : ENABLED");
else
opts.stx(3,"(1) Startup Animation : DISABLED");
if(ini.end_graphic)
opts.stx(4,"(2) End Animations : ENABLED");
else
opts.stx(4,"(2) End Animations : DISABLED");
if(ini.rtc)
opts.stx(5,"(3) Realtime Clock : ENABLED");
else
opts.stx(5,"(3) Realtime Clock : DISABLED");
opts.stx(6,"Change User Name : ");
opts.atx(6,ini.name);
opts.stx(7,"Change Theme : ");
switch(ini.theme)
{
case 0: opts.atx(7,"GREEN");
break;
case 1: opts.atx(7,"BLUE");
break;
case 2: opts.atx(7,"FIRE");
break;
}
opts.draw();
if(opts.choice==1)
ini.start_graphic=!ini.start_graphic;
if(opts.choice==2)
ini.end_graphic=!ini.end_graphic;
if(opts.choice==3)
ini.rtc=!ini.rtc;
if(opts.choice==4)
fwiz();
if(opts.choice==5)
{
win th;
th.stl("Choose a Theme : ");
th.stx(1,"Please choose a theme to apply : ");
th.sb(3);
th.choice=2;
th.sbt(1,"GREEN");
th.sbt(2,"BLUE");
th.sbt(3,"FIRE");
th.draw();
if(th.choice!=0)
ini.theme=th.choice-1;
}
if(opts.choice==6)
help();
} while(opts.choice!=0);
save_set();
}

///////////
//WinFunc//
///////////

//Shows the realtimeclock on desktop

void winfunc(win *a)
{
delay(50);
struct time time1;
gettime(&time1);
int m=0;
m=(int)time1.ti_hour/12;
char timestr[20];
char tempstr[5];
gettime(&time1);
itoa((int)(time1.ti_hour<=12?time1.ti_hour:(int)time1.ti_hour-12),tempstr,10);
strcpy(timestr,tempstr);
strcat(timestr," : ");
itoa((int)time1.ti_min,tempstr,10);
strcat(timestr,tempstr);
strcat(timestr," : ");
itoa((int)time1.ti_sec,tempstr,10);
strcat(timestr,tempstr);
tempstr[0]=' ';
tempstr[1]=(m?'P':'A');
tempstr[2]='M';
tempstr[3]='\0';
strcat(timestr,tempstr);
drwrct(480,180,150,20,0);
outtextxy(485,180,timestr);
if(time1.ti_hour==alarm_time.hrs&&time1.ti_min==alarm_time.min)
alarm(timestr,a);
}

/////////
//ALARM//
/////////

//Sounds an alarm and displays an alert

void alarm(char timestr[],win *a)
{
win alarm;
alarm.stl("PDA ALARM !!");
alarm.settheme(FIRE);
alarm.stx(3," A L A R M ");
alarm.atx(3,timestr);
alarm.stx(5," Hit a key to stop.");
alarm.setwait(0);
alarm.draw();
while(!kbhit())
{
for(int i=440;i<=2000;i+=50)
{
sound(i);
if(kbhit()) break;
delay(100);
}
}
nosound();
alarm_time.hrs=30,alarm_time.min=90;
getapps();
a->showbody();
}

////////////////////
//HELP INFORMATION//
////////////////////

void help()
{
win help1;
help1.stl("PDA Help");
help1.stx(1,"PDA is a program that acts as your own personal secretary");
help1.stx(2,"and mantains records of your appointments and schedules,");
help1.stx(3,"displays a calendar and a clock, sets alarms and includes a");
help1.stx(4,"calculator - All in a friendly Graphical Interface with");
help1.stx(5,"the convenience of operating with a Mouse!");
help1.stx(9,"Hit a key to continue...");
help1.st(FULL);
help1.draw();
win help2;
help2.stl("PDA Help - Navigation");
help2.stx(1,"You can use both the mouse and the keyboard to navigate in the");
help2.stx(2,"application. Just point and click on the buttons with a mouse");
help2.stx(3,"or use the arrow keys on the keyboard to select the buttons.");
help2.stx(5,"All dialoge boxes can be closed by clicking the cross at the");
help2.stx(6,"top-right corner, which responds te same as pressing the Esc");
help2.stx(7,"key on the keyboard.");
help2.stx(9,"Hit a key to continue...");
help2.st(FULL);
help2.draw();
win help3;
help3.stl("PDA Help - Functions");
help3.stx(1,"The main screen consists of the buttons for the various functions.");
help3.stx(3,"1 . Diary - This option brings up the appointments manager.");
help3.stx(4,"In the appointments manager screen you have the following options:");
help3.stx(5,"Today`s-Lists all appointments scheduled for Today");
help3.stx(6,"Show All displays all the appointments");
help3.stx(7,"Pack old deletes all the appointments prior to Today");
help3.stx(8,"Add New adds a new appointment");
help3.stx(9,"Delete All deletes all the present and future appointments");
help3.stx(11,"Whenever you set an appointment, An alarm is automatically sounded");
help3.stx(12,"when the time arrives for that appointment.");
help3.stx(14,"Hit a key to continue...");
help3.st(FULL);
help3.draw();
win help4;
help4.stl("PDA Help - Functions");
help4.stx(1,"2. Calendar : This shows the calendar of the");
help4.stx(2,"current month. The current date is also displayed.");
help4.stx(5,"3. Clock : This window diplays the constantly updated time");
help4.stx(6,"and the date.");
help4.stx(9,"Hit a key to continue...");
help4.st(FULL);
help4.draw();
win help5;
help5.stl("PDA Help - Functions");
help5.stx(1,"4. Calculator : This brings up a fully functional calculator");
help5.stx(2,"which can add, subtract, multiply or divide two numbers.");
help5.st(FULL);
help5.draw();
win help6;
help6.stl("PDA Help - Functions");
help6.stx(1,"5. Options : Here you can change the various settings of the");
help6.stx(2,"program. You can toggle the options of animations and desktop");
help6.stx(3,"clock by clicking the buttons marked 1, 2 and 3.");
help6.stx(4,"You can change the name by which the program addresses you.");
help6.stx(6,"PDA has three vibrant colour schemes to make it look fancier");
help6.stx(7,"and to reduce eye fatigue and boredom.");
help6.st(FULL);
help6.draw();
win help7;
help7.stl("Important notes..");
help7.stx(1,"Some Important notes : ");
help7.stx(2,"Realtime desktop clock : The desktop clock may be disabled");
help7.stx(3,"by the user but it must be turned on for the alarm to function.");
help7.stx(4,"The ALARM will NOT work if it is disabled!");
help7.stx(5,"The first time wizard : This wizard appears when you run");
help7.stx(6,"PDA for the first time and stores your name. It is also ");
help7.stx(7,"invoked when you change your name in options and it automatically");
help7.stx(8,"enables the animations and realtime clock.");
help7.stx(9,"Pack old and Delete all : These automatically delete your");
help7.stx(10,"appointments and are not recoverable once removed,");
help7.stx(11,"so use with caution.");
help7.st(FULL);
help7.draw();
win about;
about.stl("About PDA ... ");
about.stx(1,"P.D.A. 2002");
about.stx(2,"Copyleft 2002 - Rohit Rawat");
about.stx(3," XII-C");
about.stx(4," RollNo-33");
about.stx(6,"This product is licenced to YOU");
about.stx(7,"FREE TO USE AND DISTRIBUTE");
about.stx(8,"Contact email - Get it from Webpage");
about.stx(9,"Web : https://rohitrawat.tripod.com/");
about.stx(10,"Please read README.TXT file for more help.");
about.sb(1);
about.sbt(1,"OK");
about.draw();
}

///////////////////
//Date Validation//
///////////////////
int validate_date (int d, int m, int y)
{ if (y<1|| m<1|| d<1|| m>12)
return(-1);
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
if(y%4==0)
{month[1]=29;}
if (d>month[m-1])
return(-1);
return(0);
}
/////////////////////END OF PROGRAM/////////////////////