;MailRun v2.11: Part F, othercmds ;1992-1993 Gerald P. Sully, all rights reserved. #comment ************************************************************************** ************************************************************************** * * This file is a grab bag of routines for the following: * adding an item to Get or Send Mail; adding an item to send a * command; adding an item to execute a script; displaying the * "About MailRun" dialog box. The appropriate routine is * selected with a FLAG. * ************************************************************************** ************************************************************************** #endcomment #define MRUN211F #include "MRUN211.h" string Command, ScriptName, ScriptList, MRunIcons, BBSChoice integer GetSendRadio, IconIndex #comment ********************************************************************* * * MAIN() * * Calls checkchild(), addgetmail(), addsendcommand(), * adddoscript(), showabout(), menudim() * * Calls the appropriate function based on the value of * FLAGS. * ********************************************************************* #endcomment proc main integer cmdstatus menudim() checkchild() findfirst MailRun MailRunTrunc = $FILENAME cmdstatus = FLAGS & (AGM + CMD + SCR + ABT) switch cmdstatus case AGM addgetmail() endcase case CMD addsendcommand() endcase case SCR adddoscript() endcase case ABT showabout() endcase endswitch endproc #comment ********************************************************************* * * ADDGETMAIL() * * Called by main() * * Calls getlastitem(), * getmailbox(), gettaskstring(), makebbslist(), * insertitem(), interfaceon() * * Adds a GetMail item to the mailrun. * ********************************************************************* #endcomment proc addgetmail string GetMailString, GetSendMail, StatString, char integer dialogstatus, Perm, j strextract BBSChoice TaskItem "`t" 3 strextract char TaskItem "`t" 4 atoi char j makebbslist() getmailbox() statmsg "" interfaceon() while 1 dialogstatus = $DIALOG switch dialogstatus case 10 ;User selected "Add" if GetSendRadio == 1 GetSendMail = "GetMail" strfmt StatString "Added to %s: `"Get QWK Packet`"" BBSChoice else GetSendMail = "SendMail" strfmt StatString "Added to %s: `"Send REP Packet`"" BBSChoice endif Perm = 2 - PermRadio strfmt GetMailString "1,%d,%s" Perm GetSendMail ;Update MAILRUN.INI, task list j++ insertitem(BBSChoice, j, GetMailString) TaskItem = gettaskstring(BBSChoice, j) statmsg StatString endcase case 11 ;User selected "Done" exit endcase case 170 ;User changed BBS with combobox j = getlastitem(BBSChoice) TaskItem = gettaskstring(BBSChoice, j) endcase endswitch endwhile endproc #comment ********************************************************************* * * GETMAILBOX() * * Called by addgetmail() * * Displays the Get/Send Mail dialog box. * ********************************************************************* #endcomment proc getmailbox PermRadio = 1 GetSendRadio = 1 destroydlg HelpPage = 8 dialogbox 52 68 243 93 15 "Get/Send Mail" HELPID HelpPage radiobutton 16 44 54 14 "Get Mail" GetSendRadio radiobutton 16 63 54 14 "Send Mail" endgroup radiobutton 94 44 54 14 "Permanent" PermRadio radiobutton 94 63 54 14 "Temporary" endgroup pushbutton 184 44 40 14 "&Add" normal default pushbutton 184 63 40 14 "&Done" normal text 52 12 68 8 right "Get/Send Mail for:" combobox 124 10 67 41 BBSList BBSChoice sort enddialog endproc #comment ********************************************************************* * * ADDSENDCOMMAND() * * Called by main() * * Calls getlastitem(), * gettaskstring(), makebbslist(), interfaceon(), * sendcommandbox(), insertitem() * * Adds a "SendCommand" item to the mailrun. A command * string may contain multiple command lines separated by * verticle bars. Successive command lines will be sent * when the terminal screen is quiet for 15 seconds. * ********************************************************************* #endcomment proc addsendcommand string CommandString, StatString, char integer dialogstatus, Perm, j strextract BBSChoice TaskItem "`t" 3 strextract char TaskItem "`t" 4 atoi char j makebbslist() sendcommandbox() statmsg "" interfaceon() while 1 dialogstatus = $DIALOG switch dialogstatus case 10 ;User selected "Add" Perm = 2 - PermRadio strfmt CommandString "1,%d,SendCommand,%s" Perm Command strfmt StatString "Added to %s: `"Send Command: %s`"" \ BBSChoice Command j++ insertitem(BBSChoice, j, CommandString) TaskItem = gettaskstring(BBSChoice, j) statmsg StatString endcase case 11 ;User selected "Done" exit endcase case 170 ;User changed BBS with the combobox j = getlastitem(BBSChoice) TaskItem = gettaskstring(BBSChoice, j) endcase endswitch endwhile endproc #comment ********************************************************************* * * SENDCOMMANDBOX() * * Called by addsendcommand() * * Displays the Send Command dialog box. * ********************************************************************* #endcomment proc sendcommandbox PermRadio = 2 Command = "" destroydlg HelpPage = 11 dialogbox 92 63 196 124 15 "Send Command" HELPID HelpPage text 8 39 42 8 right "Command:" editbox 54 37 124 11 Command radiobutton 32 85 59 11 "Permanent" PermRadio radiobutton 32 101 59 11 "Temporary" endgroup pushbutton 129 77 40 14 "&Add" normal default pushbutton 129 97 40 14 "&Done" normal text 30 15 68 8 right "Send Command to:" combobox 102 13 65 42 BBSList BBSChoice sort text 54 51 97 8 left "Use a vertical bar (`"|`") to" text 54 61 97 8 left "separate multiple commands." enddialog endproc #comment ********************************************************************* * * ADDDOSCRIPT() * * Called by main() * * Calls getlastitem(), * makebbslist(), makescriptlist(), interfaceon(), * gettaskstring(), scriptbox(), insertitem() * * Adds a SendScript Item to the mailrun. * ********************************************************************* #endcomment proc adddoscript string ScriptString, StatString, char integer dialogstatus, Perm, j strextract BBSChoice TaskItem "`t" 3 strextract char TaskItem "`t" 4 atoi char j makebbslist() makescriptlist() scriptbox() statmsg "" interfaceon() while dialogstatus != 1 dialogstatus = $DIALOG switch dialogstatus case 10 ;User chose "Add" Perm = 2 - PermRadio strupr ScriptName strfmt ScriptString "1,%d,SendScript,%s" Perm ScriptName strfmt StatString "Added to %s: `"Execute Script: %s`"" \ BBSChoice ScriptName j++ insertitem(BBSChoice, j, ScriptString) TaskItem = gettaskstring(BBSChoice, j) statmsg StatString endcase case 11 ;User selected "Done" exit endcase case 170 ;User changed BBS with the combobox j = getlastitem(BBSChoice) TaskItem = gettaskstring(BBSChoice, j) endcase endswitch endwhile endproc #comment ********************************************************************* * * MAKESCRIPTLIST() * * Called by adddoscript() * * Calls openfile(), makefullname() * * Creates a list of scripts for display in the scriptbox() * dialog box script fcombobox. * ********************************************************************* #endcomment proc makescriptlist string ScriptSpec, NextScript, ScriptLine ScriptName = "" ScriptList = makefullname(TempDir, "SCRIPTS.TMP") openfile(ScriptFile, ScriptList, _CREATE, _TEXT) ScriptSpec = makefullname(MailRunDir, "*.WA?") findfirst ScriptSpec ;Loop through all files in the directory while FOUND NextScript = $FNAME strlwr NextScript switch NextScript case "MRUN211" case "MRUN211A" case "MRUN211B" case "MRUN211C" case "MRUN211D" case "MRUN211E" case "MRUN211F" case "MRUN211G" case "ARRAY" case "HOST" case "HOSTUTIL" case "USER" case "SUBS" case "MAIL" endcase default rewind ScriptFile fgets ScriptFile ScriptLine while not NULLSTR ScriptLine if strcmp ScriptLine NextScript exitswitch endif fgets ScriptFile ScriptLine endwhile fputs ScriptFile NextScript if NULLSTR ScriptName ScriptName = NextScript endif endcase endswitch findnext endwhile fclose ScriptFile endproc #comment ********************************************************************* * * SCRIPTBOX() * * Called by adddoscript() * * Displays the Execute Script dialog box. * ********************************************************************* #endcomment proc scriptbox PermRadio = 2 destroydlg ScriptName = "terminal" HelpPage = 12 dialogbox 92 60 180 135 15 "Execute Script" HELPID HelpPage text 14 36 64 8 right "Available Scripts:" fcombobox 82 34 76 42 ScriptList ScriptName sort text 20 54 136 22 left "WARNING: Scripts must not alter \ global variables s0-s9 and i0-i9!!!" radiobutton 17 85 62 14 "Permanent" PermRadio radiobutton 17 107 62 14 "Temporary" endgroup pushbutton 114 85 40 14 "&Add" normal default pushbutton 114 107 40 14 "&Done" normal text 14 11 64 8 right "Execute Script at:" combobox 82 9 76 42 BBSList BBSChoice sort enddialog endproc #comment ********************************************************************* * * SHOWABOUT() * * Called by main() * * Calls aboutbox() * * Displays the About MailRun dialog box. * ********************************************************************* #endcomment proc showabout integer dialogstatus statmsg "" aboutbox() dialogstatus = $DIALOG while dialogstatus != 1 dialogstatus = $DIALOG endwhile exit endproc #comment ********************************************************************* * * ABOUTBOX() * * Called by showabout() * * Calls makefullname() * * Displays the About MailRun dialog box. * ********************************************************************* #endcomment proc aboutbox destroydlg HelpPage = 1 MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL") IconIndex = 17 dialogbox 55 55 220 151 15 "About MailRun" HELPID HelpPage text 42 14 136 27 center "MailRun`r`nVersion 2.11`r`n\ Copyright © 1992-1993 Gerald P. Sully" text 20 48 180 28 left "If you use MailRun with any regularity, \ ease your aching conscience by helping out a starving author.`r`n\ Send $15 to:" icon 160 82 MRunIcons IconIndex text 20 80 120 44 left "Jerry Sully`r`n841 Solano Ave. #2`r`n\ Albany, CA 94706`r`n`r`nThank you for your support!" pushbutton 20 128 180 14 "I promise I'll send $15 as soon as I \ can afford it!" cancel enddialog endproc