home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PCBSCRPT.ZIP / SCRIPT11.PAS
Encoding:
Pascal/Delphi Source File  |  1986-07-14  |  15.3 KB  |  443 lines

  1. {**********************************************************************
  2. *                                                                     *
  3. *                    PROCOMM Script Generator v1.1                    *
  4. *                                                                     *
  5. *   Kevin J. Gross                            PROCOMM v2.3            *
  6. *   Software Technician                       PC-BOARD v11            *
  7. *   Goshen College                            Turbo Pascal v3.0       *
  8. *   July 13, 1986                             MS-DOS 2.11             *
  9. *                                                                     *
  10. *   This program generates script command files to be used with       *
  11. *   the PROCOMM Communications Utility for automatic file transfers.  *
  12. *   This version is written to support the PC-Board BBS software      *
  13. *   since it seems to currently be the most used BBS software around  *
  14. *   here.  Future versions may support TBBS or some other software.   *
  15. *                                                                     *
  16. *   This program was written specifically for four BBS's I often      *
  17. *   work with. I tried to structure the code in such a way that       *
  18. *   it is easy to modify the generator for other PC-Board systems.    *
  19. *   The procedure GetBBSChoice contains the majority of BBS specific  *
  20. *   information such as the BBS name, dialing entry number and        *
  21. *   protocol.  PCBoardMoreCheck does have a BBS specific IF-THEN      *
  22. *   clauses to provide for long BBS logon messages.                   *
  23. *                                                                     *
  24. *   When run this program asks the user which board they want a       *
  25. *   script for and then asks the user's name, password, and the names *
  26. *   of the files to be downloaded or uploaded.  If the user is        *
  27. *   uploading a file, they will also be prompted for a description.   *
  28. *                                                                     *
  29. *   This generated script file will put the transferred files in the  *
  30. *   specified TransferDrive.  The script file also generates a log    *
  31. *   file of the session in the TransferDrive.                         *
  32. *                                                                     *
  33. *   NOTE:  The 300 second wait time for the %I command is usually     *
  34. *   sufficient for the BBS to time out and hangup on the auto xfer    *
  35. *   if something unexpected happens.  Make sure this time is long     *
  36. *   enough for the BBS's you use or you may get your SYSOP up at      *
  37. *   3:00am in the morning which could have unpredictable results.     *
  38. *                                                                     *
  39. *   NOTE:  This program can be used in conjunction with the TEF       *
  40. *   utility to download files unattended at early morning hours when  *
  41. *   phone rates are cheap and BBS's are less heavily used.  Do not    *
  42. *   use this program or a modified version for unattended transfers   *
  43. *   unless you have supervised two successful transfers to verify its *
  44. *   proper functioning with your BBS.  Also, always read your log     *
  45. *   files to make sure nothing unexpected is happening even if things *
  46. *   seem to have transferred okay.                                    *
  47. *                                                                     *
  48. *   Enjoy, but use with care.                                         *
  49. *                                                                     *
  50. **********************************************************************}
  51.  
  52. PROGRAM PROCOMM_SCRIPT (INPUT,OUTPUT,ScriptFile);
  53.  
  54. CONST   LogFileType = '.LOG';                            { Logfile Extension }
  55.         CommandFileType = '.CMD';                        { Command File Ext. }
  56.         TransferDrive = 'C:';                            { RAMdisk }
  57.         Emulation = '7';                                 { ANSI-BBS }
  58.         SearchWait = 300;                                { So BBS Times Out }
  59.         SkipWait = 20;                                   { Wait w/o Timeout }
  60.         Xmodem = 'X';                                    { Transfer Protocol }
  61.         CRCXmodem = 'C';
  62.         CRCYmodem = 'Y';
  63.         MaxLen = 50;                                     { Maximum String }
  64.  
  65. TYPE    Strings = STRING[MaxLen];
  66.  
  67. VAR     ScriptFile : TEXT;
  68.         FirstName,
  69.         LastName,
  70.         Password,
  71.         BBSName,
  72.         BBSEntry,
  73.         Protocol : Strings;
  74.         BBS : INTEGER;
  75.  
  76.  
  77. {**********************************************************************
  78. *                              Header                                 *
  79. **********************************************************************}
  80.  
  81. PROCEDURE   Header;
  82.  
  83.     BEGIN
  84.  
  85.         WRITELN;
  86.         WRITELN;
  87.         WRITELN('               PROCOMM Script File Generator v1.1');
  88.         WRITELN;
  89.         WRITELN('           for the Procomm Communications Utility v2.3');
  90.         WRITELN('                         and PCBoard v11.x');
  91.         WRITELN;
  92.         WRITELN('                     Written by Kevin J. Gross');
  93.         WRITELN;
  94.         WRITELN
  95.  
  96.         END; { Header }
  97.  
  98.  
  99. {**********************************************************************
  100. *                          Get User Info                              *
  101. **********************************************************************}
  102.  
  103. PROCEDURE   GetUserInfo(VAR FirstName,
  104.                         LastName,
  105.                         Password : Strings);
  106.  
  107.     BEGIN
  108.  
  109.         WRITELN;
  110.         WRITELN;
  111.         WRITE('What is your first name? ');
  112.         READ(FirstName);
  113.  
  114.         WRITELN;
  115.         WRITE('What is your last name? ');
  116.         READ(LastName);
  117.  
  118.         WRITELN;
  119.         WRITE('What is your password? ');
  120.         READ(Password)
  121.  
  122.         END; { GetUserInfo }
  123.  
  124.  
  125. {**********************************************************************
  126. *                         Get BBS Choice                              *
  127. **********************************************************************}
  128.  
  129. PROCEDURE   GetBBSChoice(VAR BBS : INTEGER;
  130.                          VAR BBSName,
  131.                          BBSEntry,
  132.                          Protocol : Strings);
  133.  
  134.     VAR     Again : BOOLEAN;
  135.  
  136.     BEGIN
  137.  
  138.         WRITELN;
  139.         WRITELN('1 : River City Network BBS (South Bend)');
  140.         WRITELN('2 : 1149 BBS (Elkhart)');
  141.         WRITELN('3 : PC-Link Central BBS (Bloomington)');
  142.         WRITELN('4 : Last Chance BBS (Portage)');
  143.  
  144.         REPEAT
  145.             Again := False;
  146.  
  147.             WRITELN;
  148.             WRITE('Which BBS do you want a script for? ');
  149.             READ(BBS);
  150.  
  151.             CASE BBS OF
  152.  
  153.                 1 : BEGIN
  154.                         BBSName := 'RCN';        { BBS Abbrev. for Filename }
  155.                         BBSEntry := '#36';       { Procomm Dialing Entry }
  156.                         Protocol := CRCXmodem    { Transfer Protocol }
  157.                         END;
  158.  
  159.                 2 : BEGIN
  160.                         BBSName := '1149';
  161.                         BBSEntry := '1';
  162.                         Protocol := CRCYmodem
  163.                         END;
  164.  
  165.                 3 : BEGIN
  166.                         BBSName := 'PC-LINK';
  167.                         BBSEntry := '#34';
  168.                         Protocol := CRCXmodem
  169.                         END;
  170.  
  171.                 4 : BEGIN
  172.                         BBSName := 'LAST';
  173.                         BBSEntry := '#30';
  174.                         Protocol := CRCXmodem
  175.                         END
  176.  
  177.                 ELSE Again := TRUE
  178.  
  179.                 END; { CASE }
  180.  
  181.             UNTIL NOT Again
  182.  
  183.         END; { GetBBSChoice }
  184.  
  185.  
  186. {**********************************************************************
  187. *                          PC Board Setup                             *
  188. **********************************************************************}
  189.  
  190. PROCEDURE   PCBoardSetup(BBSName,
  191.                          Emulation,
  192.                          EntryNumber : Strings;
  193.                          VAR ScriptFile : TEXT);
  194.  
  195.     BEGIN
  196.  
  197.         WRITELN(ScriptFile,'%B"',TransferDrive,'"');
  198.         WRITELN(ScriptFile,'%LO"',BBSName,LogFileType,'"');
  199.         WRITELN(ScriptFile,'%P"',SearchWait,'"');
  200.         WRITELN(ScriptFile,'%E',Emulation);
  201.         WRITELN(ScriptFile,'%C"',EntryNumber,'"')
  202.  
  203.         END; { PCBoardSetup }
  204.  
  205.  
  206. {**********************************************************************
  207. *                        PC Board More Check                          *
  208. **********************************************************************}
  209.  
  210. PROCEDURE   PCBoardMoreCheck(BBSName : Strings;
  211.                              VAR ScriptFile : TEXT);
  212.  
  213.     BEGIN
  214.  
  215.         IF (BBSName = '1149') OR
  216.            (BBSName = 'LAST')
  217.         THEN
  218.             BEGIN
  219.                 WRITELN(ScriptFile,'%P"',SkipWait,'"');
  220.                 WRITELN(ScriptFile,'%I"More:"');
  221.                 WRITELN(ScriptFile,'%T"N!"')
  222.                 END { THEN }
  223.  
  224.         END; { PCBoardMoreCheck }
  225.  
  226.  
  227. {**********************************************************************
  228. *                          PC Board Log On                            *
  229. **********************************************************************}
  230.  
  231. PROCEDURE   PCBoardLogon(FirstName,
  232.                          LastName,
  233.                          Password,
  234.                          BBSName : Strings;
  235.                          VAR ScriptFile : TEXT);
  236.  
  237.     BEGIN
  238.  
  239.         WRITELN(ScriptFile,'%I"Want graphics"');
  240.         WRITELN(ScriptFile,'%T"N Q!"');
  241.         WRITELN(ScriptFile,'%I"your first name?"');
  242.         WRITELN(ScriptFile,'%T"',FirstName,'!"');
  243.         WRITELN(ScriptFile,'%I"your last name?"');
  244.         WRITELN(ScriptFile,'%T"',LastName,'!"');
  245.         WRITELN(ScriptFile,'%I"Password"');
  246.         WRITELN(ScriptFile,'%T"',Password,'!"');
  247.  
  248.         PCBoardMoreCheck(BBSName,ScriptFile);
  249.  
  250.         WRITELN(ScriptFile,'%I"Check your mail"');
  251.         WRITELN(ScriptFile,'%T"!"');
  252.  
  253.         WRITELN(ScriptFile,'%I"[C/R] to continue?"');
  254.         WRITELN(ScriptFile,'%T"!"');
  255.         WRITELN(ScriptFile,'%P"',SearchWait,'"');
  256.         WRITELN(ScriptFile,'')
  257.  
  258.         END; { PCBoardLogOn }
  259.  
  260.  
  261. {**********************************************************************
  262. *                        PC Board Download                            *
  263. **********************************************************************}
  264.  
  265. PROCEDURE   PCBoardDownLoad(Filename,
  266.                             Protocol : Strings;
  267.                             VAR ScriptFile : TEXT);
  268.  
  269.     VAR     ProcommProtocol : Strings;
  270.  
  271.     BEGIN
  272.  
  273.         IF Protocol = CRCXmodem
  274.         THEN
  275.             ProcommProtocol := Xmodem
  276.         ELSE
  277.             ProcommProtocol := Protocol;
  278.  
  279.         WRITELN(ScriptFile,'%I"Main Board Command?"');
  280.         WRITELN(ScriptFile,'%T"D;',Filename,';',Protocol,'!"');
  281.         WRITELN(ScriptFile,'%I"Ready to send"');
  282.         WRITELN(ScriptFile,'%W"2"');
  283.         WRITELN(ScriptFile,'%XD',ProcommProtocol,'"',Filename,'"');
  284.         WRITELN(ScriptFile,'')
  285.  
  286.         END; { PCBoardDownLoad }
  287.  
  288.  
  289. {**********************************************************************
  290. *                         PC Board Upload                             *
  291. **********************************************************************}
  292.  
  293. PROCEDURE   PCBoardUpLoad(Filename,
  294.                           Protocol : Strings;
  295.                           VAR ScriptFile : TEXT);
  296.  
  297.     VAR     Description,
  298.             ProcommProtocol : Strings;
  299.  
  300.     BEGIN
  301.  
  302.         REPEAT
  303.  
  304.             WRITELN;
  305.             WRITELN;
  306.             WRITELN('                    ',
  307.                     '[----------------------------------------------]');
  308.             WRITE('Description of file? ');
  309.             READ(Description)
  310.             UNTIL Description <> '';
  311.  
  312.         IF Protocol = CRCXmodem
  313.         THEN
  314.             ProcommProtocol := Xmodem
  315.         ELSE
  316.             ProcommProtocol := Protocol;
  317.  
  318.         WRITELN(ScriptFile,'%I"Main Board Command?"');
  319.         WRITELN(ScriptFile,'%T"U;',Filename,';',Protocol,'!"');
  320.         WRITELN(ScriptFile,'%I"Ready to receive"');
  321.         WRITELN(ScriptFile,'%W"2"');
  322.         WRITELN(ScriptFile,'%XU',ProcommProtocol,'"',Filename,'"');
  323.         WRITELN(ScriptFile,'%I"Enter a description"');
  324.         WRITELN(ScriptFile,'%W"1"');
  325.         WRITELN(ScriptFile,'%T"',Description,'!"');
  326.         WRITELN(ScriptFile,'');
  327.  
  328.         END; { PCBoardUpload }
  329.  
  330.  
  331. {**********************************************************************
  332. *                       PC Board File Transfer                        *
  333. **********************************************************************}
  334.  
  335. PROCEDURE   PCBoardFileTransfer(Protocol : Strings;
  336.                                 VAR ScriptFile : TEXT);
  337.  
  338.     VAR     Choice : CHAR;
  339.             Filename : Strings;
  340.  
  341.     BEGIN
  342.  
  343.         WRITELN;
  344.         WRITELN;
  345.         WRITE('Filename to transfer(Return to stop)? ');
  346.         READ(Filename);
  347.  
  348.         WHILE Filename <> '' DO
  349.         BEGIN
  350.  
  351.             WRITELN;
  352.             WRITE('Do you wish to (U)pload or (D)ownload<D>? ');
  353.             READ(Choice);
  354.  
  355.             IF (Choice = 'U') OR (Choice = 'u')
  356.             THEN
  357.                PCBoardUpload(Filename,Protocol,ScriptFile)
  358.             ELSE
  359.                PCBoardDownload(Filename,Protocol,ScriptFile);
  360.  
  361.             WRITELN;
  362.             WRITELN;
  363.             WRITE('Filename to transfer(Return to stop)? ');
  364.             READ(Filename)
  365.  
  366.             END { While }
  367.  
  368.         END; { FileTransfer }
  369.  
  370.  
  371. {**********************************************************************
  372. *                          PC Board Log Off                           *
  373. **********************************************************************}
  374.  
  375. PROCEDURE   PCBoardLogOff(VAR ScriptFile : TEXT);
  376.  
  377.     BEGIN
  378.  
  379.         WRITELN(ScriptFile,'%I"Main Board Command?"');
  380.         WRITELN(ScriptFile,'%T"G!"');
  381.         WRITELN(ScriptFile,'%W"5"');
  382.         WRITELN(ScriptFile,'');
  383.  
  384.         WRITELN(ScriptFile,'%LC');
  385.         WRITELN(ScriptFile,'%Q')
  386.  
  387.         END; { PCBoardLogOff }
  388.  
  389.  
  390. {**********************************************************************
  391. *                            PC Board                                 *
  392. **********************************************************************}
  393.  
  394. PROCEDURE   PCBoard(FirstName,
  395.                     LastName,
  396.                     Password,
  397.                     BBSName,
  398.                     Protocol,
  399.                     EntryNumber : Strings;
  400.                     VAR ScriptFile : TEXT);
  401.  
  402.     BEGIN
  403.  
  404.         PCBoardSetup(BBSName,Emulation,EntryNumber,ScriptFile);
  405.  
  406.         PCBoardLogon(FirstName,LastName,Password,BBSName,ScriptFile);
  407.  
  408.         PCBoardFileTransfer(Protocol,ScriptFile);
  409.  
  410.         PCBoardLogoff(ScriptFile)
  411.  
  412.         END; { PCBoard }
  413.  
  414.  
  415. {**********************************************************************
  416. *                       Main Control Procedure                        *
  417. **********************************************************************}
  418.  
  419. BEGIN
  420.  
  421.     ClrScr;
  422.  
  423.     Header;
  424.  
  425.     GetBBSChoice(BBS, BBSName, BBSEntry, Protocol);
  426.  
  427.     GetUserInfo(FirstName, LastName, Password);
  428.  
  429.     ASSIGN(ScriptFile, BBSName + CommandFileType);
  430.     REWRITE(ScriptFile);
  431.  
  432.     PCBoard(FirstName,
  433.             LastName,
  434.             Password,
  435.             BBSName,
  436.             Protocol,
  437.             BBSEntry,
  438.             ScriptFile);
  439.  
  440.     CLOSE(ScriptFile)
  441.  
  442. END.
  443.