Category : Communication (modem) tools and utilities
Archive   : MRUN200.ZIP
Filename : MRUN200A.WAS

 
Output of file : MRUN200A.WAS contained in archive : MRUN200.ZIP
;MailRun v2.00: Part A, Main body of script
;1992 Gerald P. Sully, all rights reserved.

#comment
*************************************************************
*************************************************************

This file serves as "home base" for the rest of the script.
All other scripts will return to this one if they are
exited normally. It initializes the script, creates the
user interface, and then waits for action on the part of the
user. If the user executes a mailrun, this section is also
responsible for taking care of scheduling.

*************************************************************
*************************************************************
#endcomment

#define MRUN200A
#define MRUN200AG

#include "mrun200.h"

string CurrentConf, MainBoxTabs
string BBSidx, BBSdbf
integer GoWait
integer MailRunMenu, RunningMenu, FileMenu, ConfigMenu, AddMenu
integer DefaultsMenu, ExecuteMenu, HelpMenu
integer promptstatus, xferstatus, holdstatus, escapestatus


#comment
********************************************************

MAIN()

Calls checkchild(), initialize(), maketasklist(),
makebbslist(), makemailrunlist(), runmenu(), mrunmenu(),
getfirstitem(), mailrunbox(), parsedialog(), parsekeystate(),
interfaceon(), executor(), makefullname()

Main first calls the initialization routines, then puts
up the main dialog box and waits for user action.

********************************************************
#endcomment

proc main
string MRunIcons
checkchild()
when userexit call cleanup
initialize()
runmenu()
mrunmenu()
mrunwin()
makemailrunlist()
makebbslist()
maketasklist()
getfirstitem()
mailrunbox()
interfaceon()
MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL")
when dialog call parsedialog
while 1
if FLAGS & RUNNING
copyfile MRunIcons "C:\MRUNICON.DLL"
iconbutton 1 40 0 "" "C:\MRUNICON.DLL" 16 background
paint
delfile "C:\MRUNICON.DLL"
showmenu RunningMenu
executor()
copyfile MRunIcons "C:\MRUNICON.DLL"
iconbutton 1 40 0 "" "C:\MRUNICON.DLL" 0 background
paint
delfile "C:\MRUNICON.DLL"
showmenu MailRunMenu
endif
parsekeystate()
endwhile
endproc


#comment
********************************************************

INITIALIZE()

Called by main()

Calls gettempdir(), cleardir(), makemrn(), loadsettings(),
makebbslist(), makemailrunlist()

Saves system state and initializes global variables.

********************************************************
#endcomment

proc initialize
string LastRun, env, temp
string StateCapPath, StateCapFile, StateDnldPath, StateUpldPath
integer StateAutoDL, StateActionBar, StateMetaKeys
integer blank = 0

;Create the working directory
getenv "TEMP" env
if NULLSTR env
TempDir = makefullname($PWTASKPATH, "MRUNTEMP")
else
TempDir = makefullname(env, "MRUNTEMP")
endif

FLAGS = 0
MailRunIni = makefullname($WINPATH, "MAILRUN.INI")
profilerd MailRunIni "MailRun" "MailRun" MailRunTrunc
getfilenames()

;Name the script files
changesettings = makefullname(MailRunDir, "MRUN200B")
changebbs = makefullname(MailRunDir, "MRUN200C")
adddlfile = makefullname(MailRunDir, "MRUN200D")
addulfile = makefullname(MailRunDir, "MRUN200E")
othercmds = makefullname(MailRunDir, "MRUN200F")
domailrun = makefullname(MailRunDir, "MRUN200G")

;Save the current state of PCPlus/Win
fetch autodnld StateAutoDL
fetch capture path StateCapPath
fetch capture file StateCapFile
fetch dnldpath StateDnldPath
fetch upldpath StateUpldPath
StateActionBar = $ACTIONBAR
StateMetaKeys = $METAKEYS

;Save the system state in the cleanup file
profilewr CleanupFile "Cleanup" "StateAutoDL" StateAutoDL
profilewr CleanupFile "Cleanup" "StateCapPath" StateCapPath
profilewr CleanupFile "Cleanup" "StateCapFile" StateCapFile
profilewr CleanupFile "Cleanup" "StateDnldPath" StateDnldPath
profilewr CleanupFile "Cleanup" "StateUpldPath" StateupldPath
profilewr CleanupFile "Cleanup" "StateActionBar" StateActionBar
profilewr CleanupFile "Cleanup" "StateMetaKeys" StateMetaKeys

;Change the settings
set capture path MailRunDir
set capture query OFF
set autodnld OFF
set aspect rangechk OFF
metakeys OFF
actionbar OFF

;If the mailrun in MAILRUN.INI doesn't exist, create it
if NULLSTR MailRunTrunc
blank = 1
else
LastRun = makefullname(MailRunDir, MailRunTrunc)
endif
if !(checkfile(LastRun)) || blank
temp = makefullname(MailRunDir, "*.MRN")
findfirst temp
if FOUND
MailRunTrunc = $FILENAME
LastRun = makefullname(MailRunDir, MailRunTrunc)
else
MailRunTrunc = "mailrun.mrn"
MailRunList = "mailrun.mrn"
makemrn()
LastRun = MailRun
endif
endif

;Copy the mailrun to the temp directory
MailRun = makefullname(TempDir, MailRunTrunc)
copyfile LastRun MailRun
profilerd MailRun "MailRun" "Archiver" Archiver
profilerd MailRun "MailRun" "QWKReader" QWKReader
profilerd MailRun "MailRun" "LogViewer" LogViewer
endproc


#comment
********************************************************

PARSEDIALOG()

Called by main()

Calls changestatus(), changemailrun(), maketasklist(),
getfirstitem()

Checks for dialog box selection and dispatches the
appropriate task.

********************************************************
#endcomment

proc parsedialog
integer dialogstatus
dialogstatus = $DIALOG
switch dialogstatus
case 10
;User double clicked on an item
changestatus()
updatedlg 80
endcase
case 170
;User changed mailruns with combobox
changemailrun()
maketasklist()
getfirstitem()
updatedlg 80
endcase
endswitch
endproc


#comment
********************************************************

PARSEKEYSTATE()

Called by main()

Calls swapbbs(), swapitem(), deleteitem()

If the user holds down Control-Tab, shift the selected item
forward. If the user holds down Control-Shift-Tab, shift
the selected item back. If the user holds down the Delete
key, delete the selected item.

********************************************************
#endcomment

proc parsekeystate
integer TabKey, ShiftKey, CtrlKey, DelKey
integer i, j, k, l
if not $PWACTIVE
;Don't check keyboard activity unless Procomm is the active app
return
endif
keystate 0x09 TabKey
keystate 0x10 ShiftKey
keystate 0x11 CtrlKey
keystate 0x2E DelKey
if (CtrlKey == 1) && (TabKey == 1)
i = getbbsi()
j = getitemi()
if ShiftKey == 0
;If user is just holding Control-Tab, shift it forward
if j == 0
;If the selected TaskItem is a BBS
k = i + 1
swapbbs(i, k)
else
;If the selected TaskItem is an Item
l = j + 1
swapitem(i, j, l)
endif
else
;If user is holding Control-Shift-Tab, shift it backward
if j == 0
;if the selected TaskItem is a BBS
k = i - 1
swapbbs(i, k)
else
;if the selected TaskItem is an Item
l = j - 1
swapitem(i, j, l)
endif
endif
elseif DelKey == 1
deleteitem()
endif
if DelKey || (CtrlKey && TabKey)
updatedlg 80
endif
endproc


#comment
********************************************************

SWAPBBS()

Called by parsekeystate()

Calls readbbs(), writebbs(), maketasklist()

Swaps two BBSs in the task list.

********************************************************
#endcomment

proc swapbbs
intparm i, k
string OldBBS
OldBBS = readbbs(k)
if not NULLSTR OldBBS
;Unless this is the last (or first) BBS, swap with the next BBS
writebbs(i, OldBBS)
writebbs(k, BBS)
maketasklist()
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName k 0
endif
endproc


#comment
********************************************************

SWAPITEM()

Called by parsekeystate()

Calls readitem(), writeitem(), maketasklist(), gettaskstring()

Swaps two Items in the task list.

********************************************************
#endcomment

proc swapitem
intparm i, j, l
string OldItem
OldItem = readitem(l)
if not NULLSTR OldItem
;Unless this is the last Item, swap with the next Item
writeitem(j, OldItem)
writeitem(l, Item)
maketasklist()
TaskItem = gettaskstring(i, l)
endif
endproc


#comment
********************************************************

EXECUTOR()

Called by main()

Calls schedulebox(), mailrunbox(), checktime(),
scheduler(), domailrun()

Puts up the MailRun Scheduling box and parses the result.

********************************************************
#endcomment

proc executor
string HH, MM, SS, temp, LogFile
integer Hour, Minute, Second
integer dialogstatus, boxstatus
findfirst MailRun
assign LogFile $FNAME
strcat LogFile ".CAP"
if AppendLog == 0
;if user does not want to append to existing log file
temp = makefullname(MailRunDir, LogFile)
delfile temp
endif
set capture file LogFile
profilerd MailRun "MailRun" "ExecTime" ExecTime
;set default for post-mailrun activity to "Remain Idle"
PostRun = 1
schedulebox()
;boxstatus indicates whether or not mailrunbox is showing
boxstatus = 0
;turn off parsedialog() for parsing contols
clearwhen dialog
disable CTRL 230
while FLAGS & RUNNING
dialogstatus = $DIALOG
switch dialogstatus
case 1
;User selected "Cancel"
FLAGS &= IDLE
mailrunbox()
boxstatus = 1
;turn back on parsedialog() for parsing controls
when dialog call parsedialog
return
endcase
case 10
;User selected "OK"
if GoWait == 2
;if the scheduler is turned on...
;parse the entered time
strextract HH ExecTime ":" 0
strextract MM ExecTime ":" 1
strextract SS ExecTime ":" 2
Hour = checktime(HH)
Minute = checktime(MM)
Second = checktime(SS)
if ((Hour < 0) || (Hour > 23)) || ((Minute < 0) || \
(Minute > 59)) || ((Second < 0) || (Second > 59))
usermsg "The time must be in 24 hour format!"
ExecTime = "HH:MM:SS"
updatedlg 128
dialogstatus = $DIALOG
loopwhile
endif
profilewr MailRun "MailRun" "ExecTime" ExecTime
endif
exitwhile
endcase
case 50
;User changed Now/Later status
if GoWait == 2
enable CTRL 230
else
disable CTRL 230
endif
endcase
endswitch
endwhile
while FLAGS & RUNNING
if GoWait == 2
;if user has scheduled for a later time...
mailrunbox()
boxstatus = 1
disable CTRL 170
when dialog call parsedialog
scheduler()
endif
if FLAGS & RUNNING
;if the user has not terminated the mailrun, execute it
execute domailrun
boxstatus = 0
if PostRun == 2
;if post-mailrun activity is "Restart", reset the mailrun
filereset()
elseif PostRun == 3
;if post-mailrun activity is "Shut Down", do so
cleanup()
else
;if post-mailrun activity is "Remain Idle", reset RUNNING flag
FLAGS &= IDLE
endif
endif
endwhile
if boxstatus == 0
;if mailrunbox is not displayed, show it
mailrunbox()
when dialog call parsedialog
endif
if GoWait == 2
;if the scheduler was used, enable the combobox
enable CTRL 170
endif
statmsg ""
maketasklist()
updatedlg 80
endproc


#comment
********************************************************

SCHEDULER()

Called by executor()

Waits until the scheduled time before executing the
mailrun.

********************************************************
#endcomment

proc scheduler
long LExecTime
updatedlg 64
;get the system time for execution
strsltime $DATE ExecTime LExecTime
if LExecTime <= $LTIME
;if the time of execution is earlier than the current time
;increment the time of execution by 24 hours.
LExecTime += 86400
endif
strupr MailRunTrunc
while (LExecTime > $LTIME) && (FLAGS & RUNNING)
;wait until the designated time is reached
statmsg "%s will execute at %s Current time is %s" \
MailRunTrunc ExecTime $TIME24
pause 1
endwhile
strlwr MailRunTrunc
endproc


#comment
********************************************************

CHECKTIME()

Called by executor()

Converts a string into an integer time value. Returns
a value of 60 if a non-numeric character is received.

********************************************************
#endcomment

func checktime : integer
strparm TimeString
integer TimeInteger
atoi TimeString TimeInteger
if TimeInteger == 0
if not strcmpi TimeString "00"
TimeInteger = 60
endif
endif
return TimeInteger
endfunc


#comment
********************************************************

MRUNMENU()

Called by main()

Creates the MailRun menu bar.

********************************************************
#endcomment

proc mrunmenu
menubar MailRunMenu
menupopup MailRunMenu "&File" FileMenu
menuitem FileMenu 1 "&New"
menuitem FileMenu 2 "&Save"
menuitem FileMenu 3 "Save &As"
menuitem FileMenu SEPARATOR
menuitem FileMenu 4 "&Reset mailrun"
menuitem FileMenu SEPARATOR
menuitem FileMenu 5 "&Delete mailrun"
menuitem FileMenu 6 "De&lete item"
menuitem FileMenu SEPARATOR
menuitem FileMenu 7 "E&xit"
menupopup MailRunMenu "&Configure" ConfigMenu
menuitem ConfigMenu 8 "&Mailrun Settings"
menuitem ConfigMenu 9 "&BBS Settings"
menuitem ConfigMenu 10 "BBS &Prompts"
menuitem ConfigMenu 11 "BBS Mail &Door"
menupopup ConfigMenu "De&faults" DefaultsMenu
menuitem DefaultsMenu 12 "&MailRun"
menuitem DefaultsMenu 13 "&BBS"
menuitem DefaultsMenu 14 "&Prompts"
menuitem DefaultsMenu 15 "Mail &Door"
menupopup MailRunMenu "&Add" AddMenu
menuitem AddMenu 16 "&New BBS"
menuitem AddMenu 17 "&Get/Send Mail"
menuitem AddMenu 18 "&Upload File"
menuitem AddMenu 19 "&Download File"
menuitem AddMenu 20 "Send &Command"
menuitem AddMenu 21 "Execute &Script"
menupopup MailRunMenu "&Execute" ExecuteMenu
menuitem ExecuteMenu 22 "&Execute MailRun"
menuitem ExecuteMenu 23 "&QWK Reader"
menuitem ExecuteMenu 24 "&Archiver"
menuitem ExecuteMenu 25 "&View Log File"
menupopup MailRunMenu "&Help" HelpMenu
menuitem HelpMenu 26 "&Contents"
menuitem HelpMenu 27 "&On current window..."
menuitem HelpMenu SEPARATOR
menuitem HelpMenu 28 "&About MailRun"
showmenu MailRunMenu
endproc


#comment
********************************************************

RUNMENU()

Called by main()

Creates the menu bar used while a mailrun is executing.

********************************************************
#endcomment

proc runmenu
menubar RunningMenu
menupopup RunningMenu "&File" FileMenu
menuitem FileMenu 1 "&New"
menuitem FileMenu 2 "&Save"
menuitem FileMenu 3 "Save &As"
menuitem FileMenu SEPARATOR
menuitem FileMenu 4 "&Reset mailrun"
menuitem FileMenu SEPARATOR
menuitem FileMenu 5 "&Delete mailrun"
menuitem FileMenu 6 "De&lete item"
menuitem FileMenu SEPARATOR
menuitem FileMenu 7 "E&xit"
menupopup RunningMenu "&Configure" ConfigMenu
menuitem ConfigMenu 8 "&Mailrun Settings"
menuitem ConfigMenu 9 "&BBS Settings"
menuitem ConfigMenu 10 "BBS &Prompts"
menuitem ConfigMenu 11 "BBS Mail &Door"
menupopup ConfigMenu "De&faults" DefaultsMenu
menuitem DefaultsMenu 12 "&MailRun"
menuitem DefaultsMenu 13 "&BBS"
menuitem DefaultsMenu 14 "&Prompts"
menuitem DefaultsMenu 15 "Mail &Door"
menupopup RunningMenu "&Add" AddMenu
menuitem AddMenu 16 "&New BBS"
menuitem AddMenu 17 "&Get/Send Mail"
menuitem AddMenu 18 "&Upload File"
menuitem AddMenu 19 "&Download File"
menuitem AddMenu 20 "Send &Command"
menuitem AddMenu 21 "Execute &Script"
menupopup RunningMenu "&Execute" ExecuteMenu
menuitem ExecuteMenu 22 "T&erminate MailRun"
menuitem ExecuteMenu 23 "&QWK Reader"
menuitem ExecuteMenu 24 "&Archiver"
menuitem ExecuteMenu 25 "&View Log File"
menupopup RunningMenu "&Help" HelpMenu
menuitem HelpMenu 26 "&Contents"
menuitem HelpMenu 27 "&On current window..."
menuitem HelpMenu SEPARATOR
menuitem HelpMenu 29 "&About MailRun"
endproc


#comment
********************************************************

MRUNWIN()


Called by main()

Creates the MailRun icon bar. The DLL containing the
icons is copied to the C: root directory because the
iconbutton function will not accept variables as file
names. C:\ is used because it is fairly certain to exist.

********************************************************
#endcomment

proc mrunwin
string MRunBkg, MRunIcons
MRunBkg = makefullname(MailRunDir, "MRUNBKG.BMP")
MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL")
copyfile MRunBkg "C:\MRUNBKG.BMP"
copyfile MRunIcons "C:\MRUNICON.DLL"
defuserwin top pixels 34 255 255 255 bitmap
bitmapbkg TILED TOP MEMORY "C:\MRUNBKG.BMP"
iconbutton 1 40 0 "" "C:\MRUNICON.DLL" 0 background
iconbutton 2 590 0 "" "C:\MRUNICON.DLL" 1 background
iconbutton 3 1140 0 "" "C:\MRUNICON.DLL" 2 background
iconbutton 4 1690 0 "" "C:\MRUNICON.DLL" 3 background
iconbutton 5 2490 0 "" "C:\MRUNICON.DLL" 4 background
iconbutton 6 3040 0 "" "C:\MRUNICON.DLL" 5 background
iconbutton 7 3590 0 "" "C:\MRUNICON.DLL" 6 background
iconbutton 8 4140 0 "" "C:\MRUNICON.DLL" 7 background
iconbutton 9 4690 0 "" "C:\MRUNICON.DLL" 8 background
iconbutton 10 5240 0 "" "C:\MRUNICON.DLL" 9 background
iconbutton 11 5790 0 "" "C:\MRUNICON.DLL" 10 background
iconbutton 12 6590 0 "" "C:\MRUNICON.DLL" 11 background
iconbutton 13 7140 0 "" "C:\MRUNICON.DLL" 12 background
iconbutton 14 7690 0 "" "C:\MRUNICON.DLL" 13 background
iconbutton 15 8490 0 "" "C:\MRUNICON.DLL" 14 background
iconbutton 16 9290 0 "" "C:\MRUNICON.DLL" 15 background
paint
delfile "C:\MRUNBKG.BMP"
delfile "C:\MRUNICON.DLL"
endproc


#comment
********************************************************

MAILRUNBOX()

Called by main(), parsedialog(), callscript(), executor(),
sendscript()

Draws the main MailRun dialog box.

********************************************************
#endcomment

proc mailrunbox
destroydlg
assign MainBoxTabs "20,30,220,230,233,236,239,242"
AttemptNum = "0"
HelpPage = 2
dialogbox 8 36 346 181 15 "MailRun" HELPID HelpPage
groupbox 10 33 228 135 "Task List" shadow
flistbox 15 52 218 102 TaskList MainBoxTabs single TaskItem
text 15 153 49 8 left "# = permanent"
text 76 153 49 8 left "¤ = temporary"
text 140 153 33 8 left "! = error"
text 182 153 53 8 left "@ = completed"
groupbox 244 33 90 135 "Statistics" shadow
text 248 55 62 8 right "BBSs in mailrun:"
text 248 69 62 8 right "BBSs completed:"
text 248 83 62 8 right "BBSs left to call:"
text 248 97 62 8 right "Items in mailrun:"
text 248 111 62 8 right "Items completed:"
text 248 125 62 8 right "Item errors:"
text 248 139 62 8 right "Items remaining:"
text 248 153 62 8 right "Dialing Attempt:"
vtext 314 55 16 9 left BBSTotal
vtext 314 69 16 9 left BBSComplete
vtext 314 83 16 9 left BBSRemaining
vtext 314 97 16 9 left ItemTotal
vtext 314 111 16 9 left ItemComplete
vtext 314 125 16 9 left ItemError
vtext 314 139 16 9 left ItemRemaining
vtext 314 153 16 9 left AttemptNum
text 102 14 74 8 right "The current mailrun is:"
combobox 180 12 76 41 MailRunList MailRunTrunc sort
pushbutton 0 0 0 0 " &t" normal default
enddialog
if FLAGS & RUNNING
disable CTRL 170
endif
endproc


#comment
********************************************************

SCHEDULEBOX()

Called by executor()

Draws the MailRun Scheduler dialog box.

********************************************************
#endcomment

proc schedulebox
GoWait = 1
destroydlg
HelpPage = 3
dialogbox 55 58 238 120 15 "MailRun Scheduler" HELPID HelpPage
groupbox 10 14 122 67 "Schedule" shadow
radiobutton 21 28 90 10 "Execute MailRun Now!" GoWait
radiobutton 21 44 90 10 "Execute MailRun Later..." endgroup
text 17 62 43 8 right "Execute At:"
editbox 64 60 55 12 ExecTime 8
groupbox 142 14 80 67 "When finished... " shadow
radiobutton 152 28 60 10 "Remain Idle" PostRun
radiobutton 152 44 60 10 "Restart"
radiobutton 152 60 60 10 "Shut Down" endgroup
pushbutton 72 93 40 14 "&OK" normal default
pushbutton 126 93 40 14 "&Cancel" cancel
enddialog
endproc





  3 Responses to “Category : Communication (modem) tools and utilities
Archive   : MRUN200.ZIP
Filename : MRUN200A.WAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/