home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / MARTY.CPP < prev    next >
Text File  |  1995-10-31  |  7KB  |  398 lines

  1. #include "c:\tc\keyboard.h"
  2. #include "c:\tc\bios10.h"
  3. #include "c:\tc\bios21.h"
  4. #include "c:\tc\misc.h"
  5. #include "c:\tc\mouse.h"
  6. #define NUL "\0"
  7.  
  8.  
  9. #define CUSTOMER_NAME 0
  10. #define CUSTOMER_PH 1
  11. #define CUSTOMER_WK 2
  12. #define CUSTOMER_ADDI 3
  13. #define CUSTOMER_ADDII 4
  14. #define DATE_IN 5
  15. #define CODE 6
  16. #define MAKE 7
  17. #define MODEL 8
  18. #define SERIAL 9
  19. #define SHAPE 10
  20. #define DATE_OUT 11
  21. #define DATE_PICKED_UP 12
  22. #define PROBLEMI 13
  23. #define PROBLEMII 14
  24. #define SOLUTIONI 15
  25. #define SOLUTIONII 16
  26.  
  27.  
  28. #define PARTSI 15
  29. #define PARTSII 16
  30. #define PARTSIII 17
  31. #define PARTSIV 18
  32. #define PARTSV 19
  33. #define PARTSVI 20
  34. #define PARTSVII 21
  35. #define COSTI 22
  36. #define COSTII 23
  37. #define COSTIII 24
  38. #define COSTIV 25
  39. #define COSTV 26
  40. #define COSTVI 27
  41. #define COSTVII 28
  42. #define LABOR 29
  43. #define SHOP_SUPPLIES 30
  44. #define RR 31
  45. #define DISCOUNT 32
  46. #define TAX 33
  47. #define TOTAL 34
  48. #define MAXIMUM_FIELDS 30
  49.  
  50.  
  51. struct W{
  52.     char Field_Entry[80];
  53.     int Length;
  54.     int X_Location;
  55.     int Y_Location;
  56.     int Fcolor;
  57.     int Bcolor;
  58.     int Field_Exist;
  59.     }Entry[MAXIMUM_FIELDS];
  60.  
  61. /*  Structure to assign info to later, simply just copy to where ever
  62. //  and assign numbers to it
  63. Entry.Field_Entry[]
  64. Entry.Length
  65. Entry.X_Location
  66. Entry.Y_Location
  67. Entry.Fcolor = WHITE;
  68. Entry.Bcolor = BLUE;
  69. Entry.Field_Number
  70. Entry.Field_Exist[Entry.Field_Number] =
  71. */
  72.  
  73.  
  74.  
  75. //*******************
  76. // Function Phototypes
  77. int Perform(void);
  78. void Getfield(int num);
  79. void Init(void);
  80. void Drawfield(int num);
  81. void DrawfieldXOR(int num);
  82. void Erasefield(int num);
  83. void Print_Help(int num);
  84. int AskYN(void);
  85. int Check_Exist(void);
  86. int Save(void);
  87.  
  88. // Gobal thingy
  89. int Maximum_Entries;
  90.  
  91. //oops MAin
  92. void main(void)
  93. {
  94. textcolor(WHITE);
  95. textbackground(BLACK);
  96. clrscr();
  97. Init();
  98. Perform();
  99. textcolor(WHITE);
  100. textbackground(BLACK);
  101. clrscr();
  102. return;
  103. }
  104.  
  105. //Need to make a config file thingy for this
  106. void Init(void)
  107. {
  108. #include "marty.cfg"
  109. }
  110.  
  111.  
  112. int Perform(void)
  113. {
  114. int ch;
  115. int counter = 0;
  116. DrawfieldXOR(counter);
  117. Print_Help(counter);
  118. while(ch != ESC)
  119.     {
  120.     Get_Key(&ch);
  121.     switch(ch)
  122.         {
  123.         case UP:
  124.         Erasefield(counter);
  125.         counter--;
  126.         if(counter <= 0)counter = 0;
  127.                 DrawfieldXOR(counter);
  128.                 Print_Help(counter);
  129.         break;
  130.  
  131.         case TAB:
  132.         Erasefield(counter);
  133.         counter++;
  134.         if(counter >= Maximum_Entries) counter = Maximum_Entries;
  135.                 DrawfieldXOR(counter);
  136.                 Print_Help(counter);
  137.         break;
  138.  
  139.         case DOWN:
  140.         Erasefield(counter);
  141.         counter++;
  142.         if(counter >= Maximum_Entries) counter = Maximum_Entries;
  143.                 DrawfieldXOR(counter);
  144.                 Print_Help(counter);
  145.         break;
  146.  
  147.  
  148.         case ENTER:
  149.         Getfield(counter);
  150.         break;
  151.  
  152.  
  153.  
  154.         case F1:
  155.         if( (counter == 5) OR (counter == 11) OR  (counter == 12) )
  156.             {
  157.             Get_Date();
  158.             gotoxy(1,20);
  159.             char m[5],y[5],d[5],DD[25];
  160.             itoa(Date.month,m,10);
  161.             itoa(Date.day,d,10);
  162.             itoa(Date.year,y,10);
  163.             strcpy(DD,m);
  164.             strcat(DD,"\\");
  165.             strcat(DD,d);
  166.             strcat(DD,"\\");
  167.             strcat(DD,y);
  168.             strcpy(Entry[counter].Field_Entry,DD);
  169.             Drawfield(counter);
  170.                         DrawfieldXOR(counter);
  171.             }
  172.         break;
  173.  
  174.                 //unfinished
  175.         case F2:
  176.         if(!AskYN()) break;
  177.         if(!Check_Exist()) break;
  178.         if(!Save()) break;
  179.         break;
  180.  
  181.                 //unfinishes searches for a record
  182.                 case F3:
  183.                 break;
  184.  
  185.                 //unfinished "Auto Enter" a record, auto goto
  186.                 //the next field to edit, starting at first
  187.                 case F4:
  188.                 break;
  189.         }
  190.     }
  191. return TRUE;
  192. }
  193.  
  194.  
  195. //unfinished
  196. int AskYN(void)
  197. {
  198. return TRUE;
  199. }
  200.  
  201. //unfinished
  202. int Check_Exist(void)
  203. {
  204. return TRUE;
  205. }
  206.  
  207. //unfinished
  208. int Save(void)
  209. {
  210. return TRUE;
  211. }
  212.  
  213. void Print_Help(int num)
  214. {
  215. textcolor(BLACK);
  216. textbackground(WHITE);
  217. for(int temp = 1; temp <=79; temp++)
  218.     {
  219.     gotoxy(temp,25);
  220.         cPrint_Helpf(" ");
  221.     }
  222. gotoxy(1,25);
  223. switch(num)
  224.     {
  225.  
  226.     case 5:
  227.         cPrint_Helpf("Press F1 to add today's DATE");
  228.     break;
  229.  
  230.     case 6:
  231.         cPrint_Helpf("Press F1 to pick CODE's");
  232.     break;
  233.  
  234.  
  235.     case 10:
  236.         cPrint_Helpf("Press F1 to add Code's");
  237.     break;
  238.  
  239.     case 11:
  240.         cPrint_Helpf("Press F1 to add today's DATE");
  241.     break;
  242.  
  243.     case 12:
  244.         cPrint_Helpf("Press F1 to add today's DATE");
  245.     break;
  246.  
  247.     case 9999: //Edit Help
  248.         cPrint_Helpf("Backspace, Left or Right Arrow keys to Edit, Enter to Save or Exit");
  249.     break;
  250.  
  251.     default:
  252.         cPrint_Helpf("Press Enter to Edit Field  F2-to save record F3-to search");
  253.     break;
  254.  
  255.  
  256.     }
  257. return;
  258. }
  259.  
  260.  
  261. void Drawfield(int num)
  262. {
  263. int temp,x = 0;
  264. textcolor(Entry[num].Fcolor);
  265. textbackground(Entry[num].Bcolor);
  266. for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location +  Entry[num].Length);temp++)
  267.     {
  268.     gotoxy(temp,Entry[num].Y_Location);
  269.         cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
  270.     x++;
  271.     }
  272. gotoxy(Entry[num].X_Location,Entry[num].Y_Location);
  273. return;
  274. }
  275.  
  276.  
  277. void DrawfieldXOR(int num)
  278. {
  279. int temp,x = 0;
  280. textcolor(BLACK);
  281. textbackground(WHITE);
  282. for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location +  Entry[num].Length);temp++)
  283.     {
  284.     gotoxy(temp,Entry[num].Y_Location);
  285.         cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
  286.     x++;
  287.     }
  288. gotoxy(Entry[num].X_Location,Entry[num].Y_Location);
  289. return;
  290. }
  291.  
  292.  
  293. void Erasefield(int num)
  294. {
  295. int temp,x = 0;
  296. textcolor(WHITE);
  297. textbackground(BLACK);
  298. for(temp = Entry[num].X_Location;temp <= (Entry[num].X_Location +  Entry[num].Length);temp++)
  299.     {
  300.     gotoxy(temp,Entry[num].Y_Location);
  301.         cPrint_Helpf("%c",Entry[num].Field_Entry[x]);
  302.     x++;
  303.     }
  304. return;
  305. }
  306.  
  307.  
  308.  
  309. /*******************************************************
  310. Function: int Getfield(void)
  311.  
  312. Description:
  313. *******************************************************/
  314. void Getfield(int num)
  315. {
  316. Print_Help(9999);
  317. int ch;
  318. int Entry_Number = num;
  319. int temp,x = 0;
  320. Drawfield(num);
  321. gotoxy(Entry[Entry_Number].X_Location,Entry[Entry_Number].Y_Location);
  322. x = 0;
  323. unsigned char ch1;
  324. while( (ch != ENTER) AND (x <= Entry[Entry_Number].Length) )
  325.      {
  326.          //ch1 Gets char from keyboard, returns NULL or FALSE if no key
  327.          //ch gets Function keys and arrow keys, no CTRL, ALT, etc
  328.          //Will not work correctly from TC thingy
  329.          //Works great from dos and windows 3.1 & 95
  330.      ch1 = Get_Key(&ch);
  331.  
  332.      if(ch1)
  333.         {
  334.          cout << ch1;
  335.          Entry[Entry_Number].Field_Entry[x] = ch1;
  336.          x++;
  337.         }
  338.      if(ch == RIGHT)
  339.         {
  340.         if(x <=  Entry[Entry_Number].Length)
  341.             {
  342.             x++;
  343.             gotoxy(wherex() + 1,wherey());
  344.             }
  345.         }
  346.      if(ch == LEFT)
  347.         {
  348.         if(x >=  1)
  349.             {
  350.             x--;
  351.             gotoxy(wherex() - 1,wherey());
  352.             }
  353.         }
  354.      if(ch == BACKSPACE)
  355.         {
  356.         if(x >= 1)
  357.             {
  358.             //int Y = wherey();
  359.             x--;
  360.             Entry[Entry_Number].Field_Entry[x] = ' ';
  361.             gotoxy( wherex() - 1 , wherey() );
  362.             cout << Entry[Entry_Number].Field_Entry[x];
  363.             gotoxy( wherex() - 1, wherey() );
  364.             }
  365.         }
  366.      }
  367. strcat(Entry[Entry_Number].Field_Entry,"");
  368. Erasefield(num);
  369. DrawfieldXOR(num);
  370. //Print_HelpXY(1,20,"Length of string", strlen(Entry[Entry_Number].Field_Entry));
  371. Print_Help(num);
  372. return;
  373. }
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.