home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
volume_3.zip
/
MARTY.CPP
< prev
next >
Wrap
Text File
|
1995-10-31
|
7KB
|
398 lines
#include "c:\tc\keyboard.h"
#include "c:\tc\bios10.h"
#include "c:\tc\bios21.h"
#include "c:\tc\misc.h"
#include "c:\tc\mouse.h"
#define NUL "\0"
#define CUSTOMER_NAME 0
#define CUSTOMER_PH 1
#define CUSTOMER_WK 2
#define CUSTOMER_ADDI 3
#define CUSTOMER_ADDII 4
#define DATE_IN 5
#define CODE 6
#define MAKE 7
#define MODEL 8
#define SERIAL 9
#define SHAPE 10
#define DATE_OUT 11
#define DATE_PICKED_UP 12
#define PROBLEMI 13
#define PROBLEMII 14
#define SOLUTIONI 15
#define SOLUTIONII 16
#define PARTSI 15
#define PARTSII 16
#define PARTSIII 17
#define PARTSIV 18
#define PARTSV 19
#define PARTSVI 20
#define PARTSVII 21
#define COSTI 22
#define COSTII 23
#define COSTIII 24
#define COSTIV 25
#define COSTV 26
#define COSTVI 27
#define COSTVII 28
#define LABOR 29
#define SHOP_SUPPLIES 30
#define RR 31
#define DISCOUNT 32
#define TAX 33
#define TOTAL 34
#define MAXIMUM_FIELDS 30
struct W{
char Field_Entry[80];
int Length;
int X_Location;
int Y_Location;
int Fcolor;
int Bcolor;
int Field_Exist;
}Entry[MAXIMUM_FIELDS];
/* Structure to assign info to later, simply just copy to where ever
// and assign numbers to it
Entry.Field_Entry[]
Entry.Length
Entry.X_Location
Entry.Y_Location
Entry.Fcolor = WHITE;
Entry.Bcolor = BLUE;
Entry.Field_Number
Entry.Field_Exist[Entry.Field_Number] =
*/
//*******************
// Function Phototypes
int Perform(void);
void Getfield(int num);
void Init(void);
void Drawfield(int num);
void DrawfieldXOR(int num);
void Erasefield(int num);
void Print_Help(int num);
int AskYN(void);
int Check_Exist(void);
int Save(void);
// Gobal thingy
int Maximum_Entries;
//oops MAin
void main(void)
{
textcolor(WHITE);
textbackground(BLACK);
clrscr();
Init();
Perform();
textcolor(WHITE);
textbackground(BLACK);
clrscr();
return;
}
//Need to make a config file thingy for this
void Init(void)
{
#include "marty.cfg"
}
int Perform(void)
{
int ch;
int counter = 0;
DrawfieldXOR(counter);
Print_Help(counter);
while(ch != ESC)
{
Get_Key(&ch);
switch(ch)
{
case UP:
Erasefield(counter);
counter--;
if(counter <= 0)counter = 0;
DrawfieldXOR(counter);
Print_Help(counter);
break;
case TAB:
Erasefield(counter);
counter++;
if(counter >= Maximum_Entries) counter = Maximum_Entries;
DrawfieldXOR(counter);
Print_Help(counter);
break;
case DOWN:
Erasefield(counter);
counter++;
if(counter >= Maximum_Entries) counter = Maximum_Entries;
DrawfieldXOR(counter);
Print_Help(counter);
break;
case ENTER:
Getfield(counter);
break;
case F1:
if( (counter == 5) OR (counter == 11) OR (counter == 12) )
{
Get_Date();
gotoxy(1,20);
char m[5],y[5],d[5],DD[25];
itoa(Date.month,m,10);
itoa(Date.day,d,10);
itoa(Date.year,y,10);
strcpy(DD,m);
strcat(DD,"\\");
strcat(DD,d);
strcat(DD,"\\");
strcat(DD,y);
strcpy(Entry[counter].Field_Entry,DD);
Drawfield(counter);
DrawfieldXOR(counter);
}
break;
//unfinished
case F2:
if(!AskYN()) break;
if(!Check_Exist()) break;
if(!Save()) break;
break;
//unfinishes searches for a record
case F3:
break;
//unfinished "Auto Enter" a record, auto goto
//the next field to edit, starting at first
case F4:
break;
}
}
return TRUE;
}
//unfinished
int AskYN(void)
{
return TRUE;
}
//unfinished
int Check_Exist(void)
{
return TRUE;
}
//unfinished
int Save(void)
{
return TRUE;
}
void Print_Help(int num)
{
textcolor(BLACK);
textbackground(WHITE);
for(int temp = 1; temp <=79; temp++)
{
gotoxy(temp,25);
cPrint_Helpf(" ");
}
gotoxy(1,25);
switch(num)
{
case 5:
cPrint_Helpf("Press F1 to add today's DATE");
break;
case 6:
cPrint_Helpf("Press F1 to pick CODE's");
break;
case 10:
cPrint_Helpf("Press F1 to add Code's");
break;
case 11:
cPrint_Helpf("Press F1 to add today's DATE");
break;
case 12:
cPrint_Helpf("Press F1 to add today's DATE");
break;
case 9999: //Edit Help
cPrint_Helpf("Backspace, Left or Right Arrow keys to Edit, Enter to Save or Exit");
break;
default:
cPrint_Helpf("Press Enter to Edit Field F2-to save record F3-to search");
break;
}
return;
}
void Drawfield(int num)
{
int temp,x = 0;
textcolor(Entry[num].Fcolor);
textbackground(Entry[num].Bcolor);
for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location + Entry[num].Length);temp++)
{
gotoxy(temp,Entry[num].Y_Location);
cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
x++;
}
gotoxy(Entry[num].X_Location,Entry[num].Y_Location);
return;
}
void DrawfieldXOR(int num)
{
int temp,x = 0;
textcolor(BLACK);
textbackground(WHITE);
for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location + Entry[num].Length);temp++)
{
gotoxy(temp,Entry[num].Y_Location);
cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
x++;
}
gotoxy(Entry[num].X_Location,Entry[num].Y_Location);
return;
}
void Erasefield(int num)
{
int temp,x = 0;
textcolor(WHITE);
textbackground(BLACK);
for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location + Entry[num].Length);temp++)
{
gotoxy(temp,Entry[num].Y_Location);
cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
x++;
}
return;
}
/*******************************************************
Function: int Getfield(void)
Description:
*******************************************************/
void Getfield(int num)
{
Print_Help(9999);
int ch;
int Entry_Number = num;
int temp,x = 0;
Drawfield(num);
gotoxy(Entry[Entry_Number].X_Location,Entry[Entry_Number].Y_Location);
x = 0;
unsigned char ch1;
while( (ch != ENTER) AND (x <= Entry[Entry_Number].Length) )
{
//ch1 Gets char from keyboard, returns NULL or FALSE if no key
//ch gets Function keys and arrow keys, no CTRL, ALT, etc
//Will not work correctly from TC thingy
//Works great from dos and windows 3.1 & 95
ch1 = Get_Key(&ch);
if(ch1)
{
cout << ch1;
Entry[Entry_Number].Field_Entry[x] = ch1;
x++;
}
if(ch == RIGHT)
{
if(x <= Entry[Entry_Number].Length)
{
x++;
gotoxy(wherex() + 1,wherey());
}
}
if(ch == LEFT)
{
if(x >= 1)
{
x--;
gotoxy(wherex() - 1,wherey());
}
}
if(ch == BACKSPACE)
{
if(x >= 1)
{
//int Y = wherey();
x--;
Entry[Entry_Number].Field_Entry[x] = ' ';
gotoxy( wherex() - 1 , wherey() );
cout << Entry[Entry_Number].Field_Entry[x];
gotoxy( wherex() - 1, wherey() );
}
}
}
strcat(Entry[Entry_Number].Field_Entry,"");
Erasefield(num);
DrawfieldXOR(num);
//Print_HelpXY(1,20,"Length of string", strlen(Entry[Entry_Number].Field_Entry));
Print_Help(num);
return;
}