home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / D7.CPP < prev    next >
C/C++ Source or Header  |  1995-10-29  |  38KB  |  1,423 lines

  1. #include "c:\tc\keyboard.h"
  2. #include "c:\tc\misc.h"
  3. #include "C:\tc\bios10.h"
  4. #include "C:\tc\bios21.h"
  5. #define TRUE2 1
  6. #define X_WIDTH1 15
  7. #define MAX_DIR2 2000
  8.  
  9. #define BOTTOM 20
  10. #define TOP 5
  11. #define LEFTX 2
  12. #define RIGHTX 79
  13. #define MAXIMUM_PAGE 85
  14. #define FIRSTPAGE 1
  15. ////////////////////////////////////////////////
  16. // Function PhotoTypes /////////////////////////
  17. ////////////////////////////////////////////////
  18. int Get_all_Files(void);
  19. int Get_all_Direc(void);
  20. void Assign_Location(void);
  21. void Show_all_Entries(void);
  22. int Replace_Background(void);
  23. void Draw_Text_Box(void);
  24. void Erase_Background(void);
  25. void Clear_Box(void);
  26. int Get_Background(void);
  27. int Perform(void);
  28. char *current_directory(char *path);
  29. void Draw_Screen(void);
  30. void Erase_Screen(void);
  31. int Change_Direct(void);
  32. void Update_Top(void);
  33. int Run_Program(char *t);
  34. void Reset_Files(void);
  35. void Reset_Directories(void);
  36. void Selection(void);
  37. void Erasebox(void);
  38. void del(void);
  39. void Chgdrv(void);
  40. void Copy_File(void);
  41. void Get_Field(void);
  42.  
  43.  
  44.  
  45.  
  46. //////////////////////////////////////////////////////
  47. /// Structures //////////////////////////////////////
  48. /////////////////////////////////////////////////////
  49. //Array to hold names & Location X&Y
  50. struct  STRUCT{
  51.     char Name[15];
  52.     int  RowX;
  53.         int  ColumnY;
  54.         };
  55. STRUCT Entry[MAX_DIR2];
  56.  
  57. //Struct for total entries and current location
  58. struct  STRUCT2{
  59.         int total_entries;
  60.         int Current_Entry;
  61.         int Total_Pages;
  62.         int Current_Page;
  63.         }Array;
  64.  
  65.  
  66.  
  67. //Struct for count of of Files above
  68. struct  STRUCT3{
  69.         int sw;
  70.         }Num_Files;
  71. //Struct for count of of Dir above
  72. struct  STRUCT4{
  73.         int sw;
  74.         }Num_Dir;
  75.  
  76. struct Win{
  77.         int leftX;
  78.         int topY;
  79.         int rightX;
  80.         int bottomY;
  81.         int style;
  82.         int buff;
  83.         char buffer[4096];
  84.         int Bcolor;
  85.         int Fcolor;
  86.         int page;
  87.         char Title[50];
  88.         int Title_Length;
  89.         int TitleSW;
  90.     }Window,Field;
  91. /*
  92. Window.leftX =;
  93. Window.topY =;
  94. Window.rightX =;
  95. Window.bottomY =;
  96. Window.style =;
  97. Window.buff =;
  98. Window.buffer[4096] =;
  99. Window.Bcolor =;
  100. Window.Fcolor =;
  101. Window.page =;
  102. Window.Title[50] =;
  103. Window.Title_Length =;
  104. Window.TitleSW =;
  105.  
  106.  
  107.  */
  108.  
  109. char Field_Entry[60];
  110.  
  111.  
  112.  
  113. ////////////////////////////////////////////////////////
  114. /*******************************************************
  115. Function: void main(void)
  116.  
  117. Description:
  118. *******************************************************/
  119. ////////////////////////////////////////////////////////
  120. void main(void)
  121. {
  122. TEXT_Mode();
  123. Draw_Screen();
  124. Perform();
  125. Erase_Screen();
  126. TEXT_Mode();
  127. return;
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. /*******************************************************
  137. Function: int Perform(void)
  138.  
  139. Description:
  140. *******************************************************/
  141. int Perform(void)
  142. {
  143. Array.Current_Page = 1;
  144. Reset_Directories();
  145. Update_Top();
  146. //Keyboard Variables
  147. char char_ch = NULL;
  148. int Scan1,Alt_Ctrl = NULL;
  149. int int_ch;
  150. while((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl))  != ESC)
  151.         {
  152.         switch(Scan1)
  153.                 {
  154.  
  155.                 case LEFT:
  156.                 if(Num_Files.sw == TRUE)
  157.                         {
  158.                         Reset_Directories();
  159.                         break;
  160.                         }
  161.                 if(Num_Dir.sw == TRUE)
  162.                         {
  163.                         Reset_Files();
  164.                         break;
  165.                         }
  166.  
  167.                 case RIGHT:
  168.                         if(Array.total_entries != 0)
  169.                             {
  170.                                if(Num_Files.sw == TRUE)
  171.                                         {
  172.                                         Selection();
  173.                                         break;
  174.                                         }
  175.                                if(Num_Dir.sw == TRUE)
  176.                                         {
  177.                                         chdir(Entry[Array.Current_Entry].Name);
  178.                                         Reset_Directories();
  179.                                         break;
  180.                                         }
  181.                             }
  182.                         break;
  183.  
  184.                 case PAGE_DOWN:
  185.         Array.Current_Page++;
  186.                 if(Array.Current_Page > Array.Total_Pages)
  187.                         {
  188.                         Array.Current_Page = Array.Total_Pages;
  189.                         break;
  190.                         }
  191.                 Erasebox();
  192.                 Show_all_Entries();
  193.                 gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  194.                 Write_Teletype(26,0,0);
  195.                 break;
  196.  
  197.                 case PAGE_UP:
  198.                 Array.Current_Page--;
  199.                 if(Array.Current_Page < FIRSTPAGE)
  200.                         {
  201.                         Array.Current_Page = FIRSTPAGE;
  202.                         break;
  203.                         }
  204.         Erasebox();
  205.                 Show_all_Entries();
  206.                 gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  207.                 Write_Teletype(26,0,0);
  208.                 break;
  209.  
  210.  
  211.                 case F1:
  212.                 Copy_File();
  213.                 break;
  214.  
  215.                 case F2: //Show Files
  216.                 Reset_Files();
  217.                 break;
  218.  
  219.         case F3:  //Show Directories
  220.         Reset_Directories();
  221.         break;
  222.  
  223.  
  224.         case BACKSPACE:
  225.             {
  226.             char list[120] = "pixfx.exe ";        //Array.Current_Entry
  227.             strcat(list,Entry[Array.Current_Entry].Name);
  228.             Run_Program(list);
  229.             }
  230.         break;
  231.  
  232.         case F4: // Shell to Dos
  233.         Run_Program("command.com /K ECHO Type EXIT to return");
  234.         break;
  235.  
  236.  
  237.         case F5:  //Run List to view a file
  238.         if((Num_Files.sw == TRUE)  AND (Array.total_entries != 0))
  239.             {
  240.             char list[120] = "list.com ";        //Array.Current_Entry
  241.             strcat(list,Entry[Array.Current_Entry].Name);
  242.             Run_Program(list);
  243.             }
  244.         break;
  245.  
  246.         case DELETE:
  247.         if(Array.total_entries != 0)
  248.             {
  249.             if(Num_Files.sw == TRUE)
  250.                 {
  251.                 del();
  252.                 break;
  253.                 }
  254.                         if(Num_Dir.sw == TRUE)
  255.                                 {
  256.                                 rmdir(Entry[Array.Current_Entry].Name);
  257.                                 Reset_Directories();
  258.                                 break;
  259.                                 }
  260.                         }
  261.                 break;
  262.  
  263.                 case F6: //Edit a File
  264.                 if((Num_Files.sw == TRUE)  AND (Array.total_entries != 0))
  265.                         {
  266.                         char list2[120] = "q.exe ";        //Array.Current_Entry
  267.                         strcat(list2,Entry[Array.Current_Entry].Name);
  268.             Run_Program(list2);
  269.                         }
  270.  
  271.                 break;
  272.  
  273.                 case F7: //Unzip a File
  274.                 if((Num_Files.sw == TRUE)  AND (Array.total_entries != 0))
  275.                         {
  276.                         char list2[120] = "itC.exe ";        //Array.Current_Entry
  277.                         strcat(list2,Entry[Array.Current_Entry].Name);
  278.                         Run_Program(list2);
  279.                         }
  280.                 break;
  281.  
  282.                 case F8: //Change Drive
  283.                 Chgdrv();
  284.                 break;
  285.                 }//Ends Switch
  286.  
  287.  
  288.    if(Array.total_entries != 0)
  289.         {
  290.             switch(Scan1)
  291.                {
  292.                 case ENTER:
  293.                 if(Num_Files.sw == TRUE)
  294.                         {
  295.                         Selection();
  296.                         break;
  297.                         }
  298.                 if(Num_Dir.sw == TRUE)
  299.                         {
  300.                         chdir(Entry[Array.Current_Entry].Name);
  301.                         Reset_Directories();
  302.                         break;
  303.                         }
  304.  
  305.                 case UP:
  306.         if((Entry[Array.Current_Entry].RowX == 2) AND (Entry[Array.Current_Entry].ColumnY == 5))
  307.                         {
  308.                         Entry[Array.Current_Entry].RowX = 2;
  309.                         Entry[Array.Current_Entry].ColumnY = 5;
  310.                         }
  311.                 else
  312.                         {
  313.                         gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  314.                         Write_Teletype(32,0,0);
  315.                         Array.Current_Entry--;
  316.                         if(Array.Current_Entry < 1)Array.Current_Entry = 1;
  317.                         gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  318.                         Write_Teletype(26,0,0);
  319.                         }
  320.                 break;
  321.  
  322.                 case DOWN:
  323.                 if((Entry[Array.Current_Entry].RowX == 62) AND (Entry[Array.Current_Entry].ColumnY == 21))
  324.                         {
  325.             Entry[Array.Current_Entry].RowX = 62;
  326.                         Entry[Array.Current_Entry].ColumnY = 21;
  327.                         }
  328.                 else
  329.                         {
  330.                         gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  331.                         Write_Teletype(32,0,0);
  332.                         Array.Current_Entry++;
  333.                         if(Array.Current_Entry >= Array.total_entries) Array.Current_Entry = Array.total_entries;
  334.                         gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
  335.                         Write_Teletype(26,0,0);
  336.                         }
  337.                 break;
  338.                 }//Ends switch case
  339.         }//Ends file if test
  340.     }//End While
  341. return int_ch;
  342. }
  343.  
  344.  
  345.  
  346.  
  347.  
  348. /*******************************************************
  349. Function: void Erasebox(void)
  350.  
  351. Description:
  352. *******************************************************/
  353. void Erasebox(void)
  354. {
  355. for(int YY = 5;YY <= 22;YY++)
  356.         {
  357.         for(int XX = 2; XX <= 78; XX++)
  358.                 {
  359.                 gotoxy(XX,YY);
  360.                 Write_Teletype(' ',BLUE,0);  /////Write Teletype is fastest
  361.                 }
  362.         }
  363. return;
  364. }
  365.  
  366.  
  367. /*******************************************************
  368. Function: int Get_all_Files(void)
  369.  
  370. Description: Gets all Files in current directory &
  371.              assigns them to array
  372. *******************************************************/
  373. int Get_all_Files(void)
  374. {
  375. int done;
  376. Array.Total_Pages = 1;
  377. Array.Current_Page = 1;
  378. int count = 0;
  379. Array.total_entries = 0;
  380. char temp[MAXPATH];
  381. struct ffblk ffblk;
  382. done = findfirst("*.*",&ffblk,0);
  383. while (!done)
  384.    {
  385.    if (ffblk.ff_attrib != FA_DIREC)
  386.         {
  387.         Array.total_entries++;
  388.         count++;
  389.         if(count > MAXIMUM_PAGE)
  390.                 {
  391.                 count = 0;
  392.                 Array.Total_Pages++;
  393.                 }
  394.         strcpy(Entry[Array.total_entries].Name,ffblk.ff_name);
  395.     strcat(Entry[Array.total_entries].Name,"");
  396.     }
  397.    done = findnext(&ffblk);
  398.    }
  399. return Array.total_entries;
  400. }
  401.  
  402.  
  403.  
  404. /*******************************************************
  405. Function: int Get_all_Direc(void)
  406.  
  407. Description: Gets all Directories in current directory &
  408.              assigns them to array
  409. *******************************************************/
  410. int Get_all_Direc(void)
  411. {
  412. int done;
  413. int count = 0;
  414. Array.total_entries = 0;
  415. Array.Total_Pages = 1;
  416. Array.Current_Page = 1;
  417. char temp[MAXPATH];
  418. struct ffblk ffblk;
  419. done = findfirst("*.*",&ffblk,FA_DIREC);
  420. while (!done)
  421.    {
  422.    if (ffblk.ff_attrib == FA_DIREC)
  423.         {
  424.         Array.total_entries++;
  425.         count++;
  426.         if(count > MAXIMUM_PAGE)
  427.                 {
  428.                 count = 0;
  429.                 Array.Total_Pages++;
  430.                 }
  431.         strcpy(Entry[Array.total_entries].Name,ffblk.ff_name);
  432.         }
  433.    done = findnext(&ffblk);
  434.    }
  435. return Array.total_entries;
  436. }
  437.  
  438.  
  439.  
  440.  
  441.  
  442. /*******************************************************
  443. Function: void Assign_Location(void)
  444.  
  445. Description: Assigns a X & Y Location to each Entry
  446. *******************************************************/
  447. void Assign_Location(void)
  448. {
  449. int  RowX = LEFTX;
  450. int  ColumnY = TOP;
  451. Entry[1].ColumnY = TOP;
  452. Entry[1].RowX = LEFTX;
  453. for(int temp = 2; temp <= Array.total_entries; temp++)
  454.         {
  455.         if(ColumnY > BOTTOM)
  456.             {
  457.             ColumnY = TOP;
  458.             Entry[temp].ColumnY = ColumnY;
  459.         RowX = RowX + X_WIDTH1;
  460.             if(RowX > 62)
  461.                 {
  462.                 RowX = LEFTX;
  463.                 }
  464.             Entry[temp].RowX = RowX;
  465.             }
  466.          else
  467.             {
  468.             ColumnY++;
  469.             Entry[temp].ColumnY = ColumnY;
  470.             Entry[temp].RowX = RowX;
  471.  
  472.             }
  473.         }
  474.  
  475.  
  476. }
  477.  
  478.  
  479. /*******************************************************
  480. Function: int Show_all_Entries(void)
  481.  
  482. Description:
  483. *******************************************************/
  484. void Show_all_Entries(void)
  485. {
  486. int tt,temp,end;
  487. if(Array.Current_Page == 1)
  488.         {
  489.         if(Array.total_entries <= MAXIMUM_PAGE)
  490.                 {
  491.                 tt = Array.total_entries;
  492.                 }
  493.         else
  494.                 {
  495.                 tt = MAXIMUM_PAGE;
  496.                 }
  497.     Array.Current_Entry  = 1;
  498.         for(temp = Array.Current_Entry; temp <=  tt ; temp++)
  499.              {
  500.              gotoxy(Entry[temp].RowX,Entry[temp].ColumnY);
  501.              printf("  %s",Entry[temp].Name);
  502.              }
  503.         }
  504. else
  505.         {
  506.         //Sets up cursor for first entry
  507.         Array.Current_Entry = ( (Array.Current_Page - 1)  * MAXIMUM_PAGE) + 1;
  508.         //If true then files display ends on this page
  509.         //else there are more files..Page down
  510.         if(Array.total_entries <= Array.Current_Entry + 84 )
  511.                 {
  512.                 end = Array.total_entries;
  513.                 }
  514.         else
  515.                 {
  516.          end =  Array.Current_Entry + 84;
  517.                 }
  518.         for(temp = Array.Current_Entry; temp <=  end ; temp++)
  519.              {
  520.              gotoxy(Entry[temp].RowX,Entry[temp].ColumnY);
  521.              printf("  %s",Entry[temp].Name);
  522.              }
  523.  
  524.  
  525.  
  526.         }
  527. return;
  528. }
  529.  
  530.  
  531.  
  532.  
  533. /*******************************************************
  534. Function: int Replace_Background(void)
  535.  
  536. Description:
  537. *******************************************************/
  538. int Replace_Background(void)
  539. {
  540. if(Window.buff)
  541.         {
  542.         //bytes = (h rows) x (w columns) x 2
  543.         gotoxy(Window.leftX,Window.topY);
  544.         if(puttext(Window.leftX,Window.topY, Window.rightX +1,Window.bottomY+1,Window.buffer));
  545.                 {
  546.                 return TRUE;
  547.                 }
  548.         }
  549. return FALSE;
  550. }
  551.  
  552. /*******************************************************
  553. Function: int Get_Background(void)
  554.  
  555. Description:
  556. *******************************************************/
  557. int Get_Background(void)
  558. {
  559. if(Window.buff)
  560.         {
  561.         //bytes = (h rows) x (w columns) x 2
  562.         if(gettext(Window.leftX,Window.topY, Window.rightX + 1,Window.bottomY + 1,Window.buffer));
  563.                 {
  564.                 return TRUE;
  565.                 }
  566.         }
  567. return FALSE;
  568. }
  569.  
  570.  
  571.  
  572.  
  573. /*******************************************************
  574. Function: void Clear_Box(void)
  575.  
  576. Description:
  577. *******************************************************/
  578. void Clear_Box(void)
  579. {
  580. for( int a = (Window.topY + 1); a <= (Window.bottomY - 1);a++)
  581.         {
  582.         for(int b = (Window.leftX + 1);b <= (Window.rightX - 1);b++)
  583.                 {
  584.                 gotoxy(b,a);
  585.                 cprintf(" ");
  586.                 }
  587.         }
  588. return;
  589. }
  590.  
  591.  
  592. /*******************************************************
  593. Function: void Erase_Background(void)
  594.  
  595. Description:
  596. *******************************************************/
  597. void Erase_Background(void)
  598. {
  599.  
  600. for( int a = Window.topY; a <= Window.bottomY;a++)
  601.         {
  602.         for(int b = Window.leftX;b<= Window.rightX;b++)
  603.                 {
  604.                 gotoxy(b,a);
  605.                 cprintf(" ");
  606.                 }
  607.         }
  608.  
  609. return;
  610. }
  611.  
  612.  
  613. /*******************************************************
  614. Function: void Draw_Text_Box(void)
  615.  
  616. Description:
  617. *******************************************************/
  618. void Draw_Text_Box(void)
  619. {
  620. textcolor(Window.Fcolor);
  621. textbackground(Window.Bcolor);
  622. if(Window.buff)
  623.         {
  624.         Get_Background();
  625.         }
  626. Erase_Background();
  627. int chr;
  628. int chr2;
  629. int chr3;
  630. int chr4;
  631. int chr5;
  632. int chr6;
  633.  
  634. switch(Window.style)
  635.         {
  636.         case 1:
  637.         chr  = 205;// -
  638.         chr2 = 186;// ▌
  639.         chr3 = 201;// +
  640.         chr4 = 187;//  +
  641.         chr5 = 200;// +
  642.         chr6 = 188;// +
  643.         break;
  644.  
  645.         case 2:
  646.         chr  = 196;// -
  647.         chr2 = 179;// ▌
  648.         chr3 = 218;// +
  649.     chr4 = 191;//  +
  650.         chr5 = 192;// +
  651.         chr6 = 217;// +
  652.         break;
  653.         }
  654. for(int temp = Window.leftX;temp <= Window.rightX;temp++)
  655.         {
  656.         gotoxy(temp,Window.topY);
  657.         Write_Teletype(chr,Window.Fcolor,Window.page);
  658.         gotoxy(temp,Window.bottomY);
  659.         Write_Teletype(chr,Window.Fcolor,Window.page);
  660.         }
  661.  
  662. for(temp = Window.topY;temp <= Window.bottomY;temp++)
  663.         {
  664.         gotoxy(Window.leftX,temp);
  665.         Write_Teletype(chr2,Window.Fcolor,Window.page);
  666.         gotoxy(Window.rightX,temp);
  667.         Write_Teletype(chr2,Window.Fcolor,Window.page);
  668.     }
  669. gotoxy(Window.leftX,Window.topY);
  670. Write_Teletype(chr3,Window.Fcolor,Window.page);
  671. gotoxy(Window.rightX,Window.topY);
  672. Write_Teletype(chr4,Window.Fcolor,Window.page);
  673. gotoxy(Window.leftX,Window.bottomY);
  674. Write_Teletype(chr5,Window.Fcolor,Window.page);
  675. gotoxy(Window.rightX,Window.bottomY);
  676. Write_Teletype(chr6,Window.Fcolor,Window.page);
  677.  
  678. if(Window.TitleSW)
  679.         {
  680.         int left = (Window.leftX - ((Window.Title_Length + 1) / 2));
  681.         for(temp = 0;temp <= Window.Title_Length;temp ++)
  682.                 {
  683.                 gotoxy(left,Window.topY);
  684.                 Write_Teletype(Window.Title[temp],Window.Fcolor,Window.page);
  685.                 left++;
  686.                 }
  687.     }
  688. return;
  689. }
  690.  
  691.  
  692.  
  693.  
  694.  
  695. /*******************************************************
  696. Function: char *current_directory(char *path)
  697.  
  698. Description:
  699. *******************************************************/
  700. char *current_directory(char *path)
  701. {
  702.    strcpy(path, "X:\\");      /* fill string with form of response: Cursor.X:\ */
  703.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  704.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  705.    return(path);
  706. }
  707.  
  708.  
  709.  
  710.  
  711. /*******************************************************
  712. Function: void Draw_Screen(void)
  713.  
  714. Description:
  715. *******************************************************/
  716. void Draw_Screen(void)
  717. {
  718. _setcursortype(_NOCURSOR);
  719. textcolor(WHITE);
  720. textbackground(BLUE);
  721. clrscr();
  722.         Window.leftX = 1;
  723.         Window.topY = 1;
  724.         Window.rightX = 80;
  725.     Window.bottomY = 23;
  726.         Window.style = 1;
  727.         Window.buff = FALSE;
  728.         Window.Bcolor = BLUE;
  729.         Window.Fcolor = WHITE;
  730.         Window.page = 0;
  731.         Window.TitleSW = FALSE;
  732. Draw_Text_Box();
  733. gotoxy(1,24);
  734. printf("  F1-[Copy] F2-[Files] F3-[Directory] F4-[Shell] F5-[View] F6-[Edit] F7-[Unzip]");
  735. gotoxy(1,25);
  736. printf("  F8-[Chng_Drv] PAGEDOWN-[Next_Page] PAGEUP-[Prev_Page] DELETE-[Del_file]");
  737. return;
  738. }
  739.  
  740.  
  741.  
  742.  
  743.  
  744. /*******************************************************
  745. Function: void Erase_Screen(void)
  746.  
  747. Description:
  748. *******************************************************/
  749. void Erase_Screen(void)
  750. {
  751. textcolor(WHITE);
  752. textbackground(BLACK);
  753. _setcursortype(_NORMALCURSOR);
  754. clrscr();
  755. return;
  756. }
  757.  
  758.  
  759.  
  760.  
  761. /*******************************************************
  762. Function: void Reset_Files(void)
  763.  
  764. Description:
  765. *******************************************************/
  766. void Reset_Files(void)
  767. {
  768.                 Num_Dir.sw = FALSE;
  769.                 Num_Files.sw = TRUE;
  770.                 Array.total_entries = 0;
  771.                 Array.Current_Entry = 1;
  772.                 Get_all_Files();
  773.  
  774.                 Erasebox();
  775.  
  776.  
  777.                 Update_Top();
  778.                 if(Array.total_entries != 0)
  779.                         {
  780.                 Assign_Location();
  781.                 Show_all_Entries();
  782.             }
  783.                 else
  784.                         {
  785.                         Entry[0].RowX = LEFTX;
  786.                         Entry[0].ColumnY = TOP;
  787.                         strcpy(Entry[0].Name,"<EMPTY>");
  788.                         Array.Current_Page = 1;
  789.                         Array.Total_Pages  = 1;
  790.                         gotoxy(LEFTX,TOP);
  791.                         puts(">> <EMPTY> Press F3");
  792.                         return;
  793.                         }
  794.                 gotoxy(LEFTX + 1,TOP);
  795.                 Write_Teletype(26,0,0);
  796. return;
  797. }
  798.  
  799.  
  800.  
  801.  
  802. /*******************************************************
  803. Function: void Reset_Directories(void)
  804.  
  805. Description:
  806. *******************************************************/
  807. void Reset_Directories(void)
  808. {
  809.  
  810.                 Num_Dir.sw = TRUE;
  811.                 Num_Files.sw = FALSE;
  812.                 Array.total_entries = 0;
  813.                 Array.Current_Entry = 1;
  814.                 Get_all_Direc();
  815.                 Erasebox();
  816.  
  817.                 Update_Top();
  818.                 if(Array.total_entries != 0)
  819.                         {
  820.         Assign_Location();
  821.                 Show_all_Entries();
  822.                         }
  823.                 else
  824.                         {
  825.                         Entry[0].RowX = LEFTX;
  826.                         Entry[0].ColumnY = TOP;
  827.                         strcpy(Entry[0].Name,"<EMPTY>");
  828.                         Array.Current_Page = 1;
  829.                         Array.Total_Pages  = 1;
  830.                         gotoxy(LEFTX,TOP);
  831.                         puts(">> <EMPTY> Press F2");
  832.                         return;
  833.                         }
  834.                 gotoxy(LEFTX + 1,TOP);
  835.                 Write_Teletype(26,0,0);
  836.  
  837. return;
  838. }
  839.  
  840.  
  841.  
  842.  
  843. /*******************************************************
  844. Function: void Selection(void)
  845.  
  846. Description:
  847. *******************************************************/
  848. void Selection(void)
  849. {
  850. union REGS regs;
  851. char char_ch = NULL;
  852. int Scan1,Alt_Ctrl = NULL;
  853. int int_ch;
  854. int selection;
  855. int counter=11;
  856.  
  857. Window.leftX = 19;
  858. Window.topY = 9;
  859. Window.rightX = 60;
  860. Window.bottomY = 15;
  861.  
  862. Window.style = 1;
  863. Window.buff = TRUE;
  864. Window.Bcolor = RED;
  865. Window.Fcolor = WHITE;
  866. Window.page = 0;
  867. Window.TitleSW = FALSE;
  868. Draw_Text_Box();
  869.  
  870. gotoxy(23,10);
  871. printf("File---> %s",Entry[Array.Current_Entry].Name);
  872. gotoxy(23,11);
  873. printf("Select 1: Run Program and return");
  874. gotoxy(23,12);
  875. printf("Select 2: Run Program and NOT return");
  876. gotoxy(23,13);
  877. printf("Select 3: View Program with List");
  878. gotoxy(23,14);
  879. printf("Select 4: Quit and not Run Program");
  880. gotoxy(20,counter);
  881. Write_Teletype(26,0,0);
  882.  
  883.                while(int_ch != ESC)
  884.                        {
  885.                        Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
  886.                        switch(Scan1)
  887.                             {
  888.                             case UP:
  889.                             gotoxy(20,counter);
  890.                             puts("  ");
  891.                             counter--;
  892.                             if(counter < 11)counter = 11;
  893.                             gotoxy(20,counter);
  894.                             Write_Teletype(26,0,0);
  895.                             break;
  896.  
  897.                             case DOWN:
  898.                             gotoxy(20,counter);
  899.                             puts("  ");
  900.                             counter++;
  901.                             if(counter > 14)counter = 14;
  902.                             gotoxy(20,counter);
  903.                             Write_Teletype(26,0,0);
  904.                             break;
  905.  
  906.                             case ENTER:
  907.                             selection = counter - 10;
  908.                             int_ch = ESC;
  909.                             break;
  910.  
  911.                             case RIGHT:
  912.                             selection = counter - 10;
  913.                             int_ch = ESC;
  914.                             break;
  915.  
  916.                             }
  917.                        }
  918.  
  919.  
  920.                         switch(selection)
  921.                         {
  922.                                 case 1:
  923.                                 Run_Program(Entry[Array.Current_Entry].Name);
  924.                                 char_ch = NULL;
  925.                                 Scan1,Alt_Ctrl = NULL;
  926.                                 break;
  927.  
  928.                                 case 2:
  929.                                 if(Num_Files.sw == TRUE)
  930.                                         {
  931.                                         textcolor(WHITE);
  932.                                         textbackground(BLACK);
  933.                                         _setcursortype(_NORMALCURSOR);
  934.                     clrscr();
  935.                                         char chrr;
  936.                                         int len = 0;
  937.                                         for(int ch = 0; ch < 13; ch++)
  938.                                                 {
  939.                                                 chrr = Entry[Array.Current_Entry].Name[ch];
  940.                                                 if(isgraph(chrr))
  941.                                                         {
  942.                                                         len++;
  943.                                                         }
  944.                                                 }
  945.                                         flush_buffer();
  946.                                         for(int ch2 = 0;ch2 <= len;ch2++)
  947.                                                 {
  948.                                                 regs.x.ax =  0x0500;   //Reads Flags
  949.                                                 regs.h.cl =  Entry[Array.Current_Entry].Name[ch2];//'L';
  950.                                                 if(getvect(KEYBOARD_INTERRUPT)) //Checks for error
  951.                                                         {
  952.                                                         int86(KEYBOARD_INTERRUPT,®s,®s);
  953.                             }
  954.  
  955.                                                 }
  956.                                         regs.x.ax =  0x0500;   //Reads Flags
  957.                                         regs.h.cl =  0x0D; //Enter
  958.                                         if(getvect(KEYBOARD_INTERRUPT)) //Checks for error
  959.                                                 {
  960.                                                 int86(KEYBOARD_INTERRUPT,®s,®s);
  961.                                                 }
  962.  
  963.                                         TEXT_Mode();
  964.                                         _exit(0);
  965.                                         }
  966.                                 break;
  967.  
  968.  
  969.                                 case 3:
  970.                                 if(Num_Files.sw == TRUE)
  971.                                         {
  972.                     char list[120] = "list.com ";        //Array.Current_Entry
  973.                                         strcat(list,Entry[Array.Current_Entry].Name);
  974.                                         Run_Program(list);
  975.                                         }
  976.                                 break;
  977.  
  978.                                 case 4:
  979.                                 if(Window.buff) Replace_Background();
  980.                                 break;
  981.                         }
  982.  
  983. return;
  984. }
  985.  
  986.  
  987.  
  988. /*******************************************************
  989. Function: int Run_Program(char *t)
  990.  
  991. Description:
  992. *******************************************************/
  993. int Run_Program(char *t)
  994. {
  995. Erase_Screen();
  996.  
  997.  
  998. system(t);
  999.  
  1000. Pause(TRUE);
  1001. TEXT_Mode();
  1002. _setcursortype(_NOCURSOR);
  1003. textcolor(WHITE);
  1004. textbackground(BLUE);
  1005. Draw_Screen();
  1006. if(Num_Files.sw == TRUE)
  1007.         {
  1008.         Reset_Files();
  1009.         }
  1010. else
  1011.         {
  1012.         Reset_Directories();
  1013.         }
  1014. return FALSE;
  1015. }
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021. /*******************************************************
  1022. Function: void Update_Top(void)
  1023.  
  1024. Description:
  1025. *******************************************************/
  1026. void Update_Top(void)
  1027. {
  1028. char curdir[MAXPATH];
  1029. struct diskfree_t diskinfo;
  1030. long disk_space;
  1031. //Gets Current Directory
  1032. current_directory(curdir);
  1033. //Shows Current Directory
  1034. for(int X = 2; X <=78;X++)
  1035.         {
  1036.         gotoxy(X,2);
  1037.         Write_Teletype(' ',BLUE,0);  /////Write Teletype is fastest
  1038.         }
  1039.  
  1040. gotoxy(2,2);
  1041. printf("The current directory is %s", curdir);
  1042. _dos_getdiskfree(0, &diskinfo);//getdisk(), &diskinfo);
  1043. disk_space = (long) diskinfo.avail_clusters *
  1044.             (long) diskinfo.bytes_per_sector *
  1045.             (long) diskinfo.sectors_per_cluster;
  1046. gotoxy(2,3);
  1047. printf("Available disk space %ld", disk_space);
  1048. printf("  Dos version %3.2f",Get_Dos_Version()/100);
  1049. Get_Date();
  1050. printf("  Date %d/%d/%d %s",Date.month,Date.day,Date.year,Date.day_string);
  1051. return;
  1052. }
  1053.  
  1054.  
  1055.  
  1056. /*******************************************************
  1057. Function: void del(void)
  1058.  
  1059. Description:
  1060. *******************************************************/
  1061. void del(void)
  1062. {
  1063. if(Num_Files.sw != TRUE)return;
  1064.  
  1065.  
  1066. char char_ch = NULL;
  1067. int Scan1,Alt_Ctrl = NULL;
  1068. int int_ch;
  1069. int selection;
  1070. int counter=11;
  1071.  
  1072. Window.leftX = 19;
  1073. Window.topY = 9;
  1074. Window.rightX = 60;
  1075. Window.bottomY = 14;
  1076.  
  1077. Window.style = 1;
  1078. Window.buff = TRUE;
  1079. Window.Bcolor = RED;
  1080. Window.Fcolor = WHITE;
  1081. Window.page = 0;
  1082. Window.TitleSW = FALSE;
  1083. Draw_Text_Box();
  1084.  
  1085. gotoxy(23,10);
  1086. printf("File---> %s",Entry[Array.Current_Entry].Name);
  1087. gotoxy(23,11);
  1088. printf("Select 1: Delete File");
  1089. gotoxy(23,12);
  1090. printf("Select 2: View File");
  1091. gotoxy(23,13);
  1092. printf("Select 3: Quit and not do anything");
  1093. gotoxy(20,counter);
  1094. Write_Teletype(26,0,0);
  1095.  
  1096.                while(int_ch != ESC)
  1097.                        {
  1098.                        Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
  1099.                        switch(Scan1)
  1100.                             {
  1101.                             case UP:
  1102.                             gotoxy(20,counter);
  1103.                             puts("  ");
  1104.                             counter--;
  1105.                 if(counter < 11)counter = 11;
  1106.                             gotoxy(20,counter);
  1107.                             Write_Teletype(26,0,0);
  1108.                             break;
  1109.  
  1110.                             case DOWN:
  1111.                             gotoxy(20,counter);
  1112.                             puts("  ");
  1113.                             counter++;
  1114.                             if(counter > 13)counter = 13;
  1115.                             gotoxy(20,counter);
  1116.                             Write_Teletype(26,0,0);
  1117.                             break;
  1118.  
  1119.                             case ENTER:
  1120.                             selection = counter - 10;
  1121.                             int_ch = ESC;
  1122.                             break;
  1123.                             }
  1124.                }
  1125.  
  1126.  
  1127.                         switch(selection)
  1128.                         {
  1129.                                 case 1:
  1130.                                 delete_file(Entry[Array.Current_Entry].Name);
  1131.                                 break;
  1132.  
  1133.                                 case 2:
  1134.                                 char list[120] = "list.com ";        //Array.Current_Entry
  1135.                                 strcat(list,Entry[Array.Current_Entry].Name);
  1136.                 Run_Program(list);
  1137.                                 return;
  1138.  
  1139.  
  1140.                                 case 3:
  1141.                                 if(Window.buff) Replace_Background();
  1142.                                 return;
  1143.  
  1144.  
  1145.                         }
  1146.  
  1147.  
  1148.  
  1149.  
  1150. if(Window.buff) Replace_Background();
  1151. Reset_Files();
  1152. return;
  1153. }
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159. /*******************************************************
  1160. Function: void Chgdrv(void)
  1161.  
  1162. Description:
  1163. *******************************************************/
  1164. void Chgdrv(void)
  1165. {
  1166. int  disk, disks;
  1167. /* print number of logic drives */
  1168. char char_ch = NULL;
  1169. int Scan1,Alt_Ctrl = NULL;
  1170. int int_ch;
  1171. int selection;
  1172. int counter=4;
  1173. int save = 0;
  1174. int disk2 = 0;
  1175. int dirnum = -1;
  1176. save = getdisk(); // save original disk for later reset //
  1177.    for (disk2 = 0;disk2 < 12;++disk2) // for a through z //
  1178.       {
  1179.        setdisk(disk2); // try to set disks //
  1180.        if(disk2 == getdisk()) // if disk exists //
  1181.         {
  1182.          dirnum++;
  1183.         }
  1184.     }
  1185. setdisk(save); // reset to original disk //
  1186. unsigned Num_Drives = dirnum;
  1187. Window.leftX = 19;
  1188. Window.topY = 2;
  1189. Window.rightX = 60;
  1190. Window.bottomY = Num_Drives + 5;
  1191. Window.style = 1;
  1192. Window.buff = FALSE;
  1193. Window.Bcolor = RED;
  1194. Window.Fcolor = WHITE;
  1195. Window.page = 0;
  1196. Window.TitleSW = FALSE;
  1197. Draw_Text_Box();
  1198. gotoxy(23,3);
  1199. printf("Select a Drive");
  1200. char cnt = 'A';
  1201. for(int tt = 4;tt <= (Num_Drives+4);tt++)
  1202.         {
  1203.         gotoxy(23,tt);
  1204.         printf("Drive---> %c",cnt);
  1205.     cnt++;
  1206.         }
  1207. gotoxy(20,counter);
  1208. Write_Teletype(26,0,0);
  1209.  
  1210.                while(int_ch != ESC)
  1211.                        {
  1212.                        Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
  1213.                switch(Scan1)
  1214.                             {
  1215.                             case UP:
  1216.                             gotoxy(20,counter);
  1217.                             puts("  ");
  1218.                             counter--;
  1219.                             if(counter < 4)counter = 4;
  1220.                             gotoxy(20,counter);
  1221.                             Write_Teletype(26,0,0);
  1222.                             break;
  1223.  
  1224.                 case DOWN:
  1225.                             gotoxy(20,counter);
  1226.                             puts("  ");
  1227.                             counter++;
  1228.                             if(counter > (tt-1))counter = (tt-1);
  1229.                             gotoxy(20,counter);
  1230.                             Write_Teletype(26,0,0);
  1231.                             break;
  1232.  
  1233.                             case ENTER:
  1234.                             selection = counter - 4;
  1235.                 Erase_Screen();
  1236.                 //cd(char *cdname)
  1237.                 Set_Default_Drive(selection);
  1238.                             int_ch = ESC;
  1239.                             break;
  1240.  
  1241.                             case RIGHT:
  1242.                             selection = counter - 4;
  1243.                 Erase_Screen();
  1244.                             Set_Default_Drive(selection);
  1245.                             int_ch = ESC;
  1246.                             break;
  1247.                             }
  1248.                        }
  1249.  
  1250. Draw_Screen();
  1251. Reset_Directories();
  1252. return;
  1253. }
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261. /*******************************************************
  1262. Function: void Copy_File(void)
  1263.  
  1264. Description:
  1265. *******************************************************/
  1266. void Copy_File(void)
  1267. {
  1268. if(Num_Files.sw != TRUE)return;
  1269.  
  1270.  
  1271. char char_ch = NULL;
  1272. int Scan1,Alt_Ctrl = NULL;
  1273. int int_ch;
  1274. int selection;
  1275. int counter=11;
  1276.  
  1277. Window.leftX = 19;
  1278. Window.topY = 9;
  1279. Window.rightX = 60;
  1280. Window.bottomY = 14;
  1281.  
  1282. Window.style = 1;
  1283. Window.buff = TRUE;
  1284. Window.Bcolor = RED;
  1285. Window.Fcolor = WHITE;
  1286. Window.page = 0;
  1287. Window.TitleSW = FALSE;
  1288. Draw_Text_Box();
  1289.  
  1290. gotoxy(23,10);
  1291. printf("File---> %s",Entry[Array.Current_Entry].Name);
  1292. gotoxy(23,11);
  1293. printf("Select 1: Copy File");
  1294. gotoxy(23,12);
  1295. printf("Select 2: View File");
  1296. gotoxy(23,13);
  1297. printf("Select 3: Quit and not do anything");
  1298. gotoxy(20,counter);
  1299. Write_Teletype(26,0,0);
  1300.  
  1301.                while(int_ch != ESC)
  1302.                        {
  1303.                        Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
  1304.                        switch(Scan1)
  1305.                             {
  1306.                             case UP:
  1307.                             gotoxy(20,counter);
  1308.                             puts("  ");
  1309.                 counter--;
  1310.                             if(counter < 11)counter = 11;
  1311.                             gotoxy(20,counter);
  1312.                             Write_Teletype(26,0,0);
  1313.                 break;
  1314.  
  1315.                             case DOWN:
  1316.                             gotoxy(20,counter);
  1317.                             puts("  ");
  1318.                             counter++;
  1319.                 if(counter > 13)counter = 13;
  1320.                             gotoxy(20,counter);
  1321.                             Write_Teletype(26,0,0);
  1322.                             break;
  1323.  
  1324.                             case ENTER:
  1325.                             selection = counter - 10;
  1326.                             int_ch = ESC;
  1327.                             break;
  1328.                 }
  1329.                        }
  1330.  
  1331.  
  1332.             switch(selection)
  1333.                         {
  1334.                                 case 1:
  1335.                                 if(Window.buff) Replace_Background();
  1336.                                 char copy[120] = "copy ";        //Array.Current_Entry
  1337.                                 strcat(copy,Entry[Array.Current_Entry].Name);
  1338.                 strcat(copy," ");
  1339.                                 Get_Field();
  1340.                                 strcat(copy,Field_Entry);
  1341.  
  1342.                                 gettext(1,1,80,25,Window.buffer);
  1343.  
  1344.                                 clrscr();
  1345.  
  1346.                                 system(copy);
  1347.  
  1348.                                 puttext(1,1,80,25,Window.buffer);
  1349.  
  1350.                                 return;
  1351.  
  1352.                                 case 2:
  1353.                                 char list[120] = "list.com ";        //Array.Current_Entry
  1354.                                 strcat(list,Entry[Array.Current_Entry].Name);
  1355.                                 Run_Program(list);
  1356.                                 return;
  1357.  
  1358.  
  1359.                 case 3:
  1360.                 if(Window.buff) Replace_Background();
  1361.                 return;
  1362.  
  1363.  
  1364.             }
  1365.  
  1366.  
  1367.  
  1368.  
  1369. if(Window.buff) Replace_Background();
  1370. Reset_Files();
  1371. return;
  1372. }
  1373.  
  1374.  
  1375.  
  1376. void Get_Field(void)
  1377. {
  1378. int x = 0;
  1379. Window.leftX = 22;
  1380. Window.topY = 13;
  1381. Window.rightX = 58;
  1382. Window.bottomY = 15;
  1383. Window.style = 2;
  1384. Window.buff = TRUE;
  1385. Window.Bcolor = WHITE;
  1386. Window.Fcolor = BLUE;
  1387. Draw_Text_Box();
  1388. _setcursortype(_SOLIDCURSOR);
  1389. gotoxy(23,14);
  1390. int ch;
  1391. unsigned char ch1;
  1392. stpcpy(Field_Entry," ");
  1393. while( (ch != ENTER) AND (x <= 34) )
  1394.      {
  1395.      ch1 = Get_Key(&ch);
  1396.      if(ch1)
  1397.         {
  1398.          cout << ch1;
  1399.          Field_Entry[x] = ch1;
  1400.          x++;
  1401.         }
  1402.      }
  1403. strcat(Field_Entry," ");
  1404. if(Window.buff) Replace_Background();
  1405. textcolor(WHITE);
  1406. textbackground(BLUE);
  1407. _setcursortype(_NOCURSOR);
  1408. return;
  1409. }
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.