home *** CD-ROM | disk | FTP | other *** search
/ Boldly Go Collection / version40.iso / TS / 05B / TLXDIR01.ZIP / RECVPAWS.SLT < prev    next >
Encoding:
Text File  |  1992-05-27  |  8.7 KB  |  142 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //                                        //
  3. //                       RECVPAWS.SLT Telix 3.15 Script                     //
  4. //                                        //
  5. //  A script to display all the files in your "Download" directory in a     //
  6. //  window with a white background... unless you're using a white back-     //
  7. //  ground, in which case it will use a cyan background.  The window will   //
  8. //  adjust itself to show a maximum of ten files before pausing the file    //
  9. //  list.  The total number of files in the directory will be displayed on  //
  10. //  the top border line of the window.                        //
  11. //                                        //
  12. //  I wrote this script as an exercise, and as the rudiments to a similar   //
  13. //  function I need for a file transfer automation utility I'm working on   //
  14. //  in my "spare time".                             //
  15. //                                        //
  16. //  There's a version without the "Pause" using a Scroll instead, called    //
  17. // "RECVLOOP.SLT" if you're interested (actually it exists even if you're   //
  18. //  NOT interested!)...                             //
  19. //                                        //
  20. //  Make any (and ALL) changes that you need and/or desire and recompile    //
  21. //  this script.  I then assign it to a Function Key.  Personally I use     //
  22. //  Ctrl+F12 for this script (I use Alt+F12 for the "SendPaws" script).     //
  23. //                                        //
  24. //  This script is "thrown" into the Public Domain!  I use it, but take     //
  25. //  NO RESPONSIBILITY for it!  It's behaved for me, but who knows what      //
  26. //  it'll do away from home!                                                //
  27. //                                        //
  28. //////////////////////////////////////////////////////////////////////////////
  29.  
  30.  
  31. //////////////////////////////////////////////////////////////////////////////
  32. //                                        //
  33. //  Any/All questions, comments, words of high praise can be addressed to:  //
  34. //                                        //
  35. //                 Mr. Jiggs (Systems Overlord)            //
  36. //             c/o Fotobeam/Brookside, Inc.                //
  37. //                 260 Lexington St.                    //
  38. //                 Waltham, Ma.  02254-4613                //
  39. //                                        //
  40. //                 Voice: (617) 893-1600                //
  41. //                   Fax: (617) 893-9951                //
  42. //                   BBS: (617) 893-6812   8n1            //
  43. //                       Up To 9600baud v.32/v.42bis/MNP                    //
  44. //                                                                          //
  45. //////////////////////////////////////////////////////////////////////////////
  46.  
  47. main() {
  48.      int File_Count=0, Back_Color=0, More_Color=0, Listing_Loop=0;
  49.      int Top_Row=0, Box_Row=0, Orig_Row=0, Orig_Col=0, Result=0;
  50.      str Found[16], Look_For[64], Directory_Name[64], Num[3];
  51.  
  52.      cursor_onoff(0);                                   // Begin by turning the cursor off...
  53.      Orig_Col=getx();                                   // Save the cursor position you entered
  54.      Orig_Row=gety();                                   // from (to restore upon exiting)...
  55.  
  56.      If   (_back_color == 07) {                         // Check to see if you're using a white
  57.            Back_Color=48;                               // background & assign CYAN if you are,
  58.            More_Color=176;                              // & BLINKING for the MORE prompt
  59.           }
  60.      Else {                                             // OTHERWISE...
  61.            Back_Color=112;                              // assign a WHITE window background...
  62.            More_Color=240;                              // & BLINKING for the MORE prompt
  63.           }
  64.  
  65.      Directory_Name=_Down_Dir;                          // Set the Directory_Name variable to
  66.      Look_For=Directory_Name;                           // your "Telix Download Directory Name"
  67.      strcat(Look_For, "*.*");                           // & add the "*.*" wild card to it...
  68.  
  69.      while (FileFind(Look_For,0,Found) != 0)            // "Loop" through the "Download
  70.            {                                            //  Directory" counting the
  71.              File_Count=File_Count+1;                   //  number of files...
  72.              Look_For="";
  73.            }
  74.  
  75. ///////////////////////////////////////////////////////////////////////////////////////////////
  76. //   If the directory's empty (you don't have ANY files in your "Download Directory")...     //
  77. //         The script will display the directory name within the window and display          //
  78. //       " 0 Files ", but if you remove the beginning "//" from the following section it     //
  79. //         will skip this entirely, which might make you think this isn't working...         //
  80. ///////////////////////////////////////////////////////////////////////////////////////////////
  81.  
  82. //   If    (File_Count == 0) {                          // If there's no files here
  83. //          gotoxy(Orig_Col, Orig_Row);                 // restore the position, & turn
  84. //          cursor_onoff(1);                            // the cursor back on, then
  85. //          return -1;                                  // exit the script...
  86. //         }
  87.  
  88.      itos(File_Count, Num);                             // Convert the File Count to a
  89.                                                         // String (for display purposes)
  90.      Listing_Loop=0;                                    // then reset the variables to
  91.      if    (Directory_Name == "")                       // Loop again for the actual
  92.             Directory_Name=_Down_Dir;                   // display...
  93.      Look_For=Directory_Name;
  94.      strcat(Look_For, "*.*");
  95.  
  96.      If    (File_Count < 10)                            // If there's less than 10 files
  97.             Box_Row=20-File_Count;                      // set the top row of the window
  98.      Else                                               // on screen row 20 minus the #
  99.             Box_Row=10;                                 // of files, OTHERWISE set it at
  100.                                                         // row 10...
  101.  
  102.      Box(00, Box_Row, 19, 22, 3, 0, Back_Color);              // Draw the window
  103.      pstraxy(" ", 01, Box_Row, Back_Color);
  104.      pstraxy(Num, getx(), Box_Row, Back_Color+14);            // Display the File Count
  105.      If     (File_Count == 1)
  106.              pstraxy(" File",getx(), Box_Row, Back_Color+1);  // Display "File" or "Files"
  107.      Else                                                     // depending on whether there's
  108.              pstraxy(" Files",getx(), Box_Row, Back_Color+1); // one (1) file or not...
  109.      pstraxy(" ", getx(), Box_Row, Back_Color);
  110.      ++Box_Row;                                               // Update the screen row position
  111.  
  112.      pstraxy(Directory_Name, 02, Box_Row, Back_Color+4);      // Display the directory
  113.      ++Box_Row;                                               // name in the window
  114.      Top_Row=Box_Row;                                         // set the first row
  115.      while (FileFind(Look_For,0,Found) != 0) {                // for the scrolling list
  116.             ++Listing_Loop;                                   // of file names...
  117.             If (Listing_Loop%10 == 0) {                       // Test for need to pause
  118.                 while (inkey() != 0)
  119.                        inkey();                               // Flush the keyboard buffer
  120.                 pstraxy("More", 01, Box_Row, More_Color+14);  // Display the prompt
  121.                 pstraxy("...", getx(), Box_Row, Back_Color+14);
  122.                 Result = inkeyw();                            // Get a keystroke
  123.                 pstraxy("       ", 01, Box_Row, Back_Color+1);// Erase the prompt
  124.                 if (Result < 0x0020)                          // Test for control character
  125.                     if (Result != 0x000d) {                   // If its NOT a <CR> ("Enter")
  126.                         cursor_onoff(1);                      // reset & restore cursor to
  127.                         gotoxy(Orig_Col, Orig_Row);           // the original position then
  128.                         return -1;                            // exit the script
  129.                        }
  130.                }
  131.             If (Listing_Loop > 10) {                                 // Test for need to scroll
  132.                 scroll(02, Top_Row, 17, Box_Row-1, 1, Back_Color+1); // Scroll 1 line
  133.                 --Box_Row;                                           // & reset the row #
  134.                }
  135.             pstraxy(Found,05,Box_Row, Back_Color+1);          // Display the File Name
  136.             Look_For="";
  137.             ++Box_Row;                                        // Update the display row #
  138.            }
  139. gotoxy(Orig_Col, Orig_Row);                                   // Put the cursor back
  140. cursor_onoff(1);                                              // where it was & turn
  141. }                                                             // it back on...
  142.