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

  1. //////////////////////////////////////////////////////////////////////////////
  2. //                                        //
  3. //                       SENDPAWS.SLT Telix 3.15 Script                     //
  4. //                                        //
  5. //  A script to display all the files in your "Upload" 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 scrolling 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. // "SENDLOOP.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 F12 for the "SendLoop" 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.  
  48. main() {
  49.      int File_Count=0, Back_Color=0, More_Color=0, Listing_Loop=0;
  50.      int Top_Row=0, Box_Row=0, Orig_Row=0, Orig_Col=0, Result=0;
  51.      str Found[16], Look_For[64], Directory_Name[64], Num[3];
  52.  
  53.      cursor_onoff(0);                                   // Begin by turning the cursor off...
  54.      Orig_Col=getx();                                   // Save the cursor position you entered
  55.      Orig_Row=gety();                                   // from (to restore upon exiting)...
  56.  
  57.      If   (_back_color == 07) {                         // Check to see if you're using a white
  58.            Back_Color=48;                               // background & assign CYAN if you are,
  59.            More_Color=176;                              // & BLINKING for the MORE prompt
  60.           }
  61.      Else {                                             // OTHERWISE...
  62.            Back_Color=112;                              // assign a WHITE window background...
  63.            More_Color=240;                              // & BLINKING for the MORE prompt
  64.           }
  65.  
  66.      Directory_Name=_Up_Dir;                            // Set the Directory_Name variable to
  67.      Look_For=Directory_Name;                           // your "Telix Upload Directory Name"
  68.      strcat(Look_For, "*.*");                           // & add the "*.*" wild card to it...
  69.  
  70.      while (FileFind(Look_For,0,Found) != 0) {          // "Loop" through the "Upload
  71.             File_Count=File_Count+1;                    //  Directory" counting the
  72.             Look_For="";                                //  number of files...
  73.            }
  74. ///////////////////////////////////////////////////////////////////////////////////////////////
  75. //   If the directory's empty (you don't have ANY files in your "Upload Directory")...       //
  76. //         The script will display the directory name within the window and display          //
  77. //       " 0 Files ", but if you remove the beginning "//" from the following section it     //
  78. //         will skip this entirely, which might make you think this isn't working...         //
  79. ///////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81. //   If    (File_Count == 0) {                          // If there's no files here
  82. //          gotoxy(Orig_Col, Orig_Row);                 // restore the position, & turn
  83. //          cursor_onoff(1);                            // the cursor back on, then
  84. //          return -1;                                  // exit the script...
  85. //         }
  86.  
  87.      itos(File_Count, Num);                             // Convert the File Count to a
  88.                                                         // String (for display purposes)
  89.      Listing_Loop=0;                                    // then reset the variables to
  90.      if    (Directory_Name == "")                       // Loop again for the actual
  91.             Directory_Name=_Up_Dir;                     // display...
  92.      Look_For=Directory_Name;
  93.      strcat(Look_For, "*.*");
  94.  
  95.      If    (File_Count < 10)                            // If there's less than 10 files
  96.             Box_Row=20-File_Count;                      // set the top row of the window
  97.      Else                                               // on screen row 20 minus the #
  98.             Box_Row=10;                                 // of files, OTHERWISE set it at
  99.                                                         // row 10...
  100.  
  101.      Box(60, Box_Row, 79, 22, 3, 0, Back_Color);              // Draw the window
  102.      pstraxy(" ", 61, Box_Row, Back_Color);
  103.      pstraxy(Num, getx(), Box_Row, Back_Color+14);            // Display the File Count
  104.      If (File_Count == 1)
  105.          pstraxy(" File",getx(), Box_Row, Back_Color+1);      // Display "File" or "Files"
  106.      Else                                                     // depending on whether there's
  107.          pstraxy(" Files",getx(), Box_Row, Back_Color+1);     // one (1) file or not...
  108.  
  109.      pstraxy(" ", getx(), Box_Row, Back_Color);
  110.      ++Box_Row;                                               // Update the screen row position
  111.  
  112.      pstraxy(Directory_Name, 62, 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)                          // Flush the keyboard buffer
  119.                        inkey();
  120.                 pstraxy("More", 61, Box_Row, More_Color+14);  // Display the prompt
  121.                 pstraxy("...", getx(), Box_Row, Back_Color+14);
  122.                 Result = inkeyw();                            // Get a keystroke
  123.                 pstraxy("       ", 61, 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(62, Top_Row, 77, Box_Row-1, 1, Back_Color+1); // Scroll 1 line
  133.                 --Box_Row;                                           // & reset the row #
  134.                }
  135.             pstraxy(Found,65,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.