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

 
Output of file : MRUN200.H contained in archive : MRUN200.ZIP
;MailRun v2.00: Header File
;1992 Gerald P. Sully, all rights reserved.

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

This header file contains routines that are used in various
places throughout the MailRun source files. It also contains
global variable definitions and macros.

The following procedures/functions are found in this file:

makebbslist(), maketasklist(), makemailrunlist(), makedesc(),
gettaskstring(), loadsettings(), loadbbsinfo(), loadprompts(),
writesettings(), writebbsinfo(), writeprompts(), openerror(),
readbbs(), readitem(), writebbs(), writeitem(), getbbscoord(),
getitemcoord(), gettempdir(), getbbsi(), getitemi(),
changemailrun(), updatemrn(), copymrn(), checkperm(),
insertitem(), checkchild()

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

;Open file indexes

#define IniFile 0
#define MailRunFile 1
#define BBSFile 0
#define TaskFile 1
#define BBSidxFile 0
#define BBSdbfFile 1
#define NewFilesFile 2
#define MRUnarcFile 3
#define OldidxFile 4
#define ScriptFile 0
#define QueueListFile 5
#define OldUBFFile 0
#define OldUDXFile 1
#define MRunUBFFile 2
#define MRunUDXFile 3
#define FileDescFile 4
#define SourceFile 5

;Flags

#define ALLFLAGS 255 ; 2^7 - 1
#define RUNNING 1 ; 2^0
#define CHANGED 2 ; 2^1
#define NEW 4 ; 2^2
#define AGM 8 ; 2^3
#define CMD 16 ; 2^4
#define SCR 32 ; 2^5
#define ABT 64 ; 2^6
#define USR 8 ; 2^3
#define PRMPT 16 ; 2^4
#define QMD 32 ; 2^5
#define DEFAULTS 128 ; 2^7
#define IDLE (ALLFLAGS - RUNNING)
#define UNCHANGED (ALLFLAGS - CHANGED)
#define OLD (ALLFLAGS - NEW)
#define CLEARCMD (ALLFLAGS - AGM - CMD - SCR - ABT)

#define FLAGS i9
#define IdleTimeout i8
#define LogRun i7
#define AppendLog i6
#define AnsiInLog i5
#define NewfileFilter i4
#define GraphicsOn i3
#define PermRadio i2
#define PostRun i1
#define IdleTimer i0

#define TaskItem s9
#define MailRun s8
#define MailRunIni s7
#define TempDir s6
#define changebbs s5
#define adddlfile s4
#define addulfile s3
#define othercmds s2
#define domailrun s1
#define changesettings s0

#define READNAME profilerd MailRun BBS "BBSName" BBSName
#define EscapeFail 0
#define ErrorFail 1
#define ALPHA 0
#define NUMERIC 1
#define MMDDYY 2


;Miscellaneous global variables

string FileDesc, FileChoice
string Item, Conf, BBSList, BBS
string FileName, Command, ScriptName, CleanupFile
string TaskList, MailRunList, MailDoorList, BBSTypeList
#ifndef MRUN200G
string MRunUBF, MRunUDX
#endif
integer HelpPage

;Global variables containing values displayed in the main dialogbox

string BBSTotal, BBSComplete, BBSRemaining, AttemptNum
string ItemTotal, ItemComplete, ItemError, ItemRemaining


#ifndef MRUN200G

;Global variables containing values from [MailRun] section of *.MRN

string MailRunDir, MailDir, ReplyDir, DownloadDir
string UploadDir, DialAttempts, DialTimeout, DialPause
string SavePackets, IdleTime, MailRunTrunc, ExecTime
string Archiver, QWKReader, LogViewer

;Global variables containing general BBS info from *.MRN

string BBSName, UserName, PWord, XferProt
string Confirm1, Confirm2
string Number_1, Number_2, Number_3
string LangNumber, MailDoorType, BBSType

;Global variables containing BBS prompts from MAILRUN.INI

string LangPrompt, GraphicsPrompt, NamePrompt, Confirm1Prompt
string PWordPrompt, ViewPrompt, FilePrompt, Confirm2Prompt
string ScanPrompt, MorePrompt, ContinuePrompt, CommandPrompt
string DLPrompt, DLUnavPrompt, ULPrompt, ULDescPrompt

;Global variables containing Mail Door prompts from MAILRUN.INI

string MailPrompt, ReceiveQWKPrompt, MailDLPrompt
string MailXferProt, MailULPrompt, QWKArchiver, MailDoor

#endif


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

MAKEFULLNAME()

Appends a filename to a directory name.

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

func makefullname : string
strparm Directory, FileNamen
string FullName
FullName = Directory
addfilename FullName FileNamen
return FullName
endfunc

#ifndef MRUN200G

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

MAKEMRN()

Calls loadsettings(), loadbbsinfo(), loadprompts(), loadmaildoor(),
writesettings(), writebbsinfo(), wsriteprompts(), writemaildoor(),
makefullname(), updatemrn()

Create the file MAILRUN.MRN and initialize it.

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

proc makemrn
;load the defaults
MailRun = MailRunIni
BBS = "DEFAULT"
loadsettings()
loadbbsinfo()
loadprompts()
loadmaildoor()
;write the defaults to the new mailrun
MailRun = makefullname(TempDir, MailRunTrunc)
writesettings()
writebbsinfo()
writeprompts()
writemaildoor()
;write the new mailrun to disk
updatemrn()
endproc

#endif

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

MAKEBBSLIST()

Calls readbbs()

Creates a list of BBSs for display the BBS combobox of
various dialog boxes.

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

proc makebbslist
string BBSi
integer i
BBSList = ""
i = 1
BBSi = readbbs(i)
while not NULLSTR BBSi
strlwr BBSi
strfmt BBSList "%s,%s" BBSList BBSi
i++
BBSi = readbbs(i)
endwhile
if i > 1
strdelete BBSList 0 1
endif
endproc


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

MAKETASKLIST()

Calls openerror(), gettaskstring(), readbbs(), readitem()

Creates the list of tasks displayed in the main MailRun
dialog box. Each item of each BBS is read from the *.MRN
file and a "TaskString" is produced to describe its contents.
The BBS and Item coordinates are appended to the TaskString
as an index back into the *.MRN file. Tabstops are used to
push these indexes beyond the right edge of the Task List
flistbox so that they are not visible. TaskStrings for BBS
names have an item coordinate of zero.

Also calculates the values of variables displayed in the
statistics section of the main box.

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

proc maketasklist
string TaskString, Tasks, Pending
string LastBBS, LastItem
integer BBST, BBSC, BBSR, ItemT, ItemC, ItemE, ItemR
integer i, j
;set all values displayed in main dialog box to 0
BBST = 0
BBSC = 0
BBSR = 0
ItemT = 0
ItemC = 0
ItemE = 0
Tasks = makefullname(TempDir, "TASKLIST.TMP")
;Save the values for the current BBS and Item
LastItem = Item
LastBBS = BBS
fopen TaskFile Tasks CREATE
openerror(Tasks)
i = 1
BBS = readbbs(i)
while not NULLSTR BBS
;Loop through each BBS in the MailRun
ItemR = 0
j = 0
profilerd MailRun BBS "BBSName" BBSName
fstrfmt TaskFile "%s`t`t`t%d`t%d`r`n" BBSName i j
j++
Item = readitem(j)
while not NULLSTR Item
;Loop through each Item
strextract Pending Item "," 0
if strcmpi Pending "0"
ItemC++
elseif strcmpi Pending "1"
ItemR++
else
ItemE++
endif
TaskString = gettaskstring(i, j)
fstrfmt TaskFile "%s`r`n" TaskString
ItemT++
j++
Item = readitem(j)
endwhile
BBST++
if ItemR == 0
BBSC++
endif
i++
BBS = readbbs(i)
endwhile
fclose TaskFile
Item = LastItem
BBS = LastBBS
;prepare statistics variables for display in the main box
BBSR = BBST - BBSC
ItemR = ItemT - ItemC - ItemE
itoa BBST BBSTotal
itoa BBSC BBSComplete
itoa BBSR BBSRemaining
itoa ItemT ItemTotal
itoa ItemC ItemComplete
itoa ItemE ItemError
itoa ItemR ItemRemaining
endproc


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

MAKEMAILRUNLIST()

Calls makefullname()

Creates a list of MailRuns for display in the main
MailRun and MailRun settings dialog boxes.

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

proc makemailrunlist
string FileTrunc, MRNFile
MailRunList = ""
MRNFile = makefullname(MailRunDir, "*.MRN")
findfirst MRNFile
;Loop through all files in the directory
while FOUND
FileTrunc = $FILENAME
strlwr FileTrunc
strfmt MailRunList "%s,%s" MailRunList FileTrunc
findnext
endwhile
if not NULLSTR MailRunList
strdelete MailRunList 0 1
endif
endproc

#ifndef MRUN200G

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

MAKEDESC()

Calls openerror()

Creates the file description for display in the upload
and download dialogboxes.

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

proc makedesc
strparm DescSource
string DB, DL
integer char
long DescBegin, DescLength, counter
strextract DB FileChoice "`t" 4
atol DB DescBegin
strextract DL FileChoice "`t" 5
atol DL DescLength
if DescLength != 0
;if there is a description in the database, retrieve it
fopen FileDescFile FileDesc CREATE
openerror(FileDesc)
fopen SourceFile DescSource READ
openerror(DescSource)
fseek SourceFile DescBegin 0
for counter = 1 upto DescLength
fgetc SourceFile char
fputc FileDescFile char
endfor
fclose FileDescFile
fclose SourceFile
else
;otherwise, just delete the previous description
fopen FileDescFile FileDesc CREATE
openerror(FileDesc)
fclose FileDescFile
endif
endproc


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

GETFILENAMES()

Calls makefullname()

Assigns file names to variables.

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

proc getfilenames
profilerd MailRunIni "MailRun" "MailRunDir" MailRunDir
TaskList = makefullname(TempDir, "TASKLIST.TMP")
FileDesc = makefullname(TempDir, "DESC.TMP")
MRunUDX = makefullname(MailRunDir, "MAILRUN.UDX")
MRunUBF = makefullname(MailRunDir, "MAILRUN.UBF")
cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
endproc

#endif


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

GETTASKSTRING()

Produces a TaskString from the current MAILRUN.INI Item.
Items are strings with the format:

"Pending,Perm,TaskType,FileName,Conf"

Pending = 0 if item is completed, 1 if pending, 2 if an
error occurred in previous attempt to execute it.
Perm = 1 if the item is permanent; Perm = 2 if temporary.
TaskType may be SendMail, GetMail, SendFile, GetFile,
SendCommand or SendScript.
FileName is the name of the file to be transferred, used
by SendFile and GetFile items.
Conf is the number of the conference to be joined, used
by SendFile and GetFile items.

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

func gettaskstring : string
intparm i, j ;BBS and Item indexes
string Pending
string Perm
string TaskType
string TaskString
string char
if j == 0
;if this is for a BBS name
READNAME
strfmt TaskString "%s`t`t`t%d`t%d" BBSName i j
else
;if this is for an item
strextract Pending Item "," 0
strextract Perm Item "," 1
strextract TaskType Item "," 2
if strcmpi Pending "1"
If strcmpi Perm "1"
char = "#"
else
char = "¤"
endif
elseif strcmpi Pending "0"
char = "@"
else
char = "!"
endif
switch TaskType
case "SendMail"
TaskString = "Send REP Packet"
endcase
case "GetMail"
TaskString = "Get QWK Packet"
endcase
case "SendFile"
strextract FileName Item "," 3
strextract Conf Item "," 4
strfmt TaskString "Upload %s to Conference %s" FileName Conf
endcase
case "GetFile"
strextract FileName Item "," 3
strextract Conf Item "," 4
strfmt TaskString "Download %s from Conference %s" FileName Conf
endcase
case "SendCommand"
strextract Command Item "," 3
strfmt TaskString "Send Command: %s" Command
endcase
case "SendScript"
strextract ScriptName Item "," 3
strfmt TaskString "Execute Script: %s" ScriptName
endcase
endswitch
strfmt TaskString "`t%s`t%s`t%d`t%d" char TaskString i j
endif
return TaskString
endfunc

#ifndef MRUN200G

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

LOADSETTINGS()

Initializes MailRun settings.

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

proc loadsettings
string _MailRun
if FLAGS & DEFAULTS
_MailRun = MailRunIni
else
_MailRun = MailRun
endif
profilerd _MailRun "MailRun" "MailDir" MailDir
profilerd _MailRun "MailRun" "ReplyDir" ReplyDir
profilerd _MailRun "MailRun" "DownloadDir" DownloadDir
profilerd _MailRun "MailRun" "UploadDir" UploadDir
profilerd _MailRun "MailRun" "SavePackets" SavePackets
profilerd _MailRun "MailRun" "DialAttempts" DialAttempts
profilerd _MailRun "MailRun" "DialTimeout" DialTimeout
profilerd _MailRun "MailRun" "DialPause" DialPause
profilerd _MailRun "MailRun" "IdleTimeout" IdleTimeout
profilerd _MailRun "MailRun" "LogRun" LogRun
profilerd _MailRun "MailRun" "AppendLog" AppendLog
profilerd _MailRun "MailRun" "AnsiInLog" AnsiInLog
profilerd _MailRun "MailRun" "NewfileFilter" NewfileFilter
profilerd _MailRun "MailRun" "Archiver" Archiver
profilerd _MailRun "MailRun" "QWKReader" QWKReader
profilerd _MailRun "MailRun" "LogViewer" LogViewer
itoa IdleTimeout IdleTime
endproc


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

WRITESETTINGS()

Writes MailRun settings to the *.MRN file.

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

proc writesettings
string _MailRun
if FLAGS & DEFAULTS
_MailRun = MailRunIni
else
_MailRun = MailRun
endif
atoi IdleTime IdleTimeout
profilewr _MailRun "MailRun" "MailDir" MailDir
profilewr _MailRun "MailRun" "ReplyDir" ReplyDir
profilewr _MailRun "MailRun" "DownloadDir" DownloadDir
profilewr _MailRun "MailRun" "UploadDir" UploadDir
profilewr _MailRun "MailRun" "DialAttempts" DialAttempts
profilewr _MailRun "MailRun" "DialTimeout" DialTimeout
profilewr _MailRun "MailRun" "DialPause" DialPause
profilewr _MailRun "MailRun" "IdleTimeout" IdleTimeout
profilewr _MailRun "MailRun" "SavePackets" SavePackets
profilewr _MailRun "MailRun" "LogRun" LogRun
profilewr _MailRun "MailRun" "AppendLog" AppendLog
profilewr _MailRun "MailRun" "AnsiInLog" AnsiInLog
profilewr _MailRun "MailRun" "NewfileFilter" NewfileFilter
profilewr _MailRun "MailRun" "Archiver" Archiver
profilewr _MailRun "MailRun" "QWKReader" QWKReader
profilewr _MailRun "MailRun" "LogViewer" LogViewer
endproc


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

LOADBBSINFO()

Initializes BBS information.

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

proc loadbbsinfo
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = "DEFAULT"
else
_MailRun = MailRun
_BBS = BBS
endif
profilerd _MailRun _BBS "BBSName" BBSName
profilerd _MailRun _BBS "UserName" UserName
profilerd _MailRun _BBS "PWord" Pword
profilerd _MailRun _BBS "XFerProt" XFerProt
profilerd _MailRun _BBS "Confirm1" Confirm1
profilerd _MailRun _BBS "Confirm2" Confirm2
profilerd _MailRun _BBS "LangNumber" LangNumber
profilerd _MailRun _BBS "GraphicsOn" GraphicsOn
profilerd _MailRun _BBS "Number_1" Number_1
profilerd _MailRun _BBS "Number_2" Number_2
profilerd _MailRun _BBS "Number_3" Number_3
if (FLAGS & NEW) || (FLAGS & DEFAULTS)
_MailRun = MailRun
endif
profilerd _MailRun _BBS "BBSType" BBSType
profilerd _MailRun _BBS "MailDoorType" MailDoorType
endproc


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

WRITEBBSINFO()

Writes information for current BBS to the *.MRN file.

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

proc writebbsinfo
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = "DEFAULT"
else
_MailRun = MailRun
_BBS = BBS
endif
profilewr _MailRun _BBS "BBSName" BBSName
profilewr _MailRun _BBS "UserName" UserName
profilewr _MailRun _BBS "PWord" PWord
profilewr _MailRun _BBS "XFerProt" XFerProt
profilewr _MailRun _BBS "Confirm1" Confirm1
profilewr _MailRun _BBS "Confirm2" Confirm2
profilewr _MailRun _BBS "LangNumber" LangNumber
profilewr _MailRun _BBS "GraphicsOn" GraphicsOn
profilewr _MailRun _BBS "Number_1" Number_1
profilewr _MailRun _BBS "Number_2" Number_2
profilewr _MailRun _BBS "Number_3" Number_3
if FLAGS & DEFAULTS
_MailRun = MailRun
endif
profilewr _MailRun _BBS "BBSType" BBSType
profilewr _MailRun _BBS "MailDoorType" MailDoorType
endproc


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

LOADPROMPTS()

Initializes BBS prompts.

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

proc loadprompts
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = BBSType
else
_MailRun = MailRun
_BBS = BBS
endif
profilerd _MailRun _BBS "LangPrompt" LangPrompt
profilerd _MailRun _BBS "GraphicsPrompt" GraphicsPrompt
profilerd _MailRun _BBS "NamePrompt" NamePrompt
profilerd _MailRun _BBS "PWordPrompt" PWordPrompt
profilerd _MailRun _BBS "Confirm1Prompt" Confirm1Prompt
profilerd _MailRun _BBS "Confirm2Prompt" Confirm2Prompt
profilerd _MailRun _BBS "ViewPrompt" ViewPrompt
profilerd _MailRun _BBS "ScanPrompt" ScanPrompt
profilerd _MailRun _BBS "FilePrompt" FilePrompt
profilerd _MailRun _BBS "MorePrompt" MorePrompt
profilerd _MailRun _BBS "ContinuePrompt" ContinuePrompt
profilerd _MailRun _BBS "CommandPrompt" CommandPrompt
profilerd _MailRun _BBS "DLPrompt" DLPrompt
profilerd _MailRun _BBS "DLUnavPrompt" DLUnavPrompt
profilerd _MailRun _BBS "ULPrompt" ULPrompt
profilerd _MailRun _BBS "ULDescPrompt" ULDescPrompt
endproc


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

WRITEPROMPTS()

Writes prompts for current BBS to the *.MRN file.

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

proc writeprompts
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = BBSType
else
_MailRun = MailRun
_BBS = BBS
endif
profilewr _MailRun _BBS "LangPrompt" LangPrompt
profilewr _MailRun _BBS "GraphicsPrompt" GraphicsPrompt
profilewr _MailRun _BBS "NamePrompt" NamePrompt
profilewr _MailRun _BBS "PWordPrompt" PWordPrompt
profilewr _MailRun _BBS "Confirm1Prompt" Confirm1Prompt
profilewr _MailRun _BBS "Confirm2Prompt" Confirm2Prompt
profilewr _MailRun _BBS "ViewPrompt" ViewPrompt
profilewr _MailRun _BBS "ScanPrompt" ScanPrompt
profilewr _MailRun _BBS "FilePrompt" FilePrompt
profilewr _MailRun _BBS "MorePrompt" MorePrompt
profilewr _MailRun _BBS "ContinuePrompt" ContinuePrompt
profilewr _MailRun _BBS "CommandPrompt" CommandPrompt
profilewr _MailRun _BBS "DLPrompt" DLPrompt
profilewr _MailRun _BBS "DLUnavPrompt" DLUnavPrompt
profilewr _MailRun _BBS "ULPrompt" ULPrompt
profilewr _MailRun _BBS "ULDescPrompt" ULDescPrompt
endproc


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

LOADMAILDOOR()

Initializes mail door prompts.

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

proc loadmaildoor
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = MailDoorType
else
_MailRun = MailRun
_BBS = BBS
endif
profilerd _MailRun _BBS "MailDoor" MailDoor
profilerd _MailRun _BBS "MailPrompt" MailPrompt
profilerd _MailRun _BBS "ReceiveQWKPrompt" ReceiveQWKPrompt
profilerd _MailRun _BBS "MailDLPrompt" MailDLPrompt
profilerd _MailRun _BBS "MailULPrompt" MailULPrompt
if FLAGS & DEFAULTS
_MailRun = MailRun
_BBS = "DEFAULT"
endif
profilerd _MailRun _BBS "QWKArchiver" QWKArchiver
profilerd _MailRun _BBS "MailXferProt" MailXferProt
endproc


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

WRITEMAILDOOR()

Writes mail door prompts for the current BBS to the .MRN
file.

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

proc writemaildoor
string _MailRun, _BBS
if FLAGS & DEFAULTS
_MailRun = MailRunIni
_BBS = "DEFAULT"
else
_MailRun = MailRun
_BBS = BBS
endif
profilewr _MailRun _BBS "MailDoor" MailDoor
profilewr _MailRun _BBS "MailPrompt" MailPrompt
profilewr _MailRun _BBS "ReceiveQWKPrompt" ReceiveQWKPrompt
profilewr _MailRun _BBS "MailDLPrompt" MailDLPrompt
profilewr _MailRun _BBS "MailULPrompt" MailULPrompt
if FLAGS & DEFAULTS
_MailRun = MailRun
_BBS = "DEFAULT"
endif
profilewr _MailRun _BBS "QWKArchiver" QWKArchiver
profilewr _MailRun _BBS "MailXferProt" MailXferProt
endproc

#endif


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

OPENERROR()

Calls cleanup()

Displays an error message and returns a value of 1 if a
file could not be successfully opened.

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

proc openerror
strparm errorfile
if FAILURE
errormsg "Unable to open file %s;`r`nscript aborted...." errorfile
cleanup()
endif
endproc


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

READBBS()

Reads the BBS associated with a BBS coordinate in the
current mailrun.

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

func readbbs : string
intparm i
string BBS_X, BBSi
strfmt BBS_X "BBS_%d" i
profilerd MailRun "MailRun" BBS_X BBSi
return BBSi
endfunc


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

READITEM()

Reads the Item associated with a BBS coordinate in the
current mailrun.

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

func readitem : string
intparm i
string Item_X, Itemi
strfmt Item_X "Item_%d" i
profilerd MailRun BBS Item_X Itemi
return Itemi
endfunc


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

WRITEBBS()

Writes a BBS ID to the given coordinate in the current
mailrun.

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

proc writebbs
intparm i
strparm BBSi
string BBS_X
strfmt BBS_X "BBS_%d" i
profilewr MailRun "MailRun" BBS_X BBSi

endproc


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

WRITEITEM()

Writes an Item to the given Item coordinate for the
current BBS and MailRun.

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

proc writeitem
intparm i
strparm Itemi
string Item_X
strfmt Item_X "Item_%d" i
profilewr MailRun BBS Item_X Itemi
endproc


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

GETBBSCOORD()

Calls readbbs()

Gets the BBS coordinate for a given BBS ID.

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

func getbbscoord : integer
integer i
string BBSi
i = 1
BBSi = readbbs(i)
while not strcmpi BBS BBSi
i++
BBSi = readbbs(i)
endwhile
return i
endfunc


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

GETITEMCOORD()

Calls readitem()

Gets the Item coordinate for a given Item in the current
BBS.

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

func getitemcoord : integer
integer i
i = 1
Item = readitem(i)
while not NULLSTR Item
i++
Item = readitem(i)
endwhile
i--
Item = readitem(i)
return i
endfunc


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

GETBBSI()

Calls readbbs()

Gets the BBS ID associated with the currently selected
item in the task list. Returns the integer value of the
BBS coordinate.

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

func getbbsi : integer
string char
integer i
strextract char TaskItem "`t" 3
atoi char i
BBS = readbbs(i)
return i
endfunc


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

GETITEMI()

Calls readitem()

Gets the Item associated with the currently selected item
in the task list. Returns the integer value of the Item
coordinate.

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

func getitemi : integer
string char
integer i
strextract char TaskItem "`t" 4
atoi char i
Item = readitem(i)
return i
endfunc


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

GETFIRSTITEM()

Highlights the first item in the task list.

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

proc getfirstitem
profilerd MailRun "MailRun" "BBS_1" BBS
if not NULLSTR BBS
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName 1 0
else
TaskItem = ""
endif
endproc


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

UPDATEMRN()

Calls makefullname()

Saves the current mailrun from TempDir to MailRunDir.

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

proc updatemrn
string LastRun
findfirst MailRun
LastRun = makefullname(MailRunDir, $FILENAME)
if not NULLSTR $FILENAME
delfile LastRun
endif
copyfile MailRun LastRun
endproc

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

COPYMRN()

Calls makefullname()

Copies a mailrun from MailRunDir to TempDir.

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

proc copymrn
string LastRun
delfile MailRun
LastRun = makefullname(MailRunDir, MailRunTrunc)
MailRun = makefullname(TempDir, MailRunTrunc)
copyfile LastRun MailRun
endproc


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

FVERIFY()

Checks for a valid DOS filename (sans extension).
Returns 1 if valid, 0 if invalid.

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

func fverify : integer
strparm LookString
string DOSChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&()-_{}"
string char
integer i, j
strlen LookString i
if (i > 8) || (i == 0)
return 0
else
i = 0
strpeek LookString i j
while j != 0
strfmt char "%c" j
if not strfind DOSChars char
return 0
endif
i++
strpeek LookString i j
endwhile
return 1
endif
endfunc


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

CLEARDIR()

Called by initialize(), getmail(), cleanup()

Deletes the contents of a directory.

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

proc cleardir
strparm DirName
string DeadFile, DirFiles
DirFiles = makefullname(DirName, "*.*")
findfirst DirFiles
while FOUND
DeadFile = makefullname(DirName, $FILENAME)
delfile DeadFile
findnext
endwhile
endproc


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

CLEARFILEDESC()

Clears the current file description box by creating a
new file with a single space character.

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

proc clearfiledesc
fopen FileDescFile FileDesc CREATE
openerror(FileDesc)
fputs FileDescFile " "
fclose FileDescFile
endproc


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

INSERTITEM()

Calls readitem(), writeitem()

Inserts a new item into the *.MRN file and updates the task
list. TaskItem is the currently selected item in the
task list.

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

proc insertitem
intparm i
strparm NovumItem
integer j, k
j = i - 1
Item = readitem(i)
while not NULLSTR Item
i++
Item = readitem(i)
endwhile
k = i - 1
while k > j
Item = readitem(k)
writeitem(i, Item)
i--
k--
endwhile
writeitem(i, NovumItem)
Item = NovumItem
endproc


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

DELETEITEM()

Called by parsedialog(), parsekeystate(), addbbs()

Calls getbbsi(), getitemi(), readbbs(), readitem(),
writebbs(), writeitem(), maketasklist(), makebbslist(),
gettaskstring()

Deletes a BBS or item from the mailrun. TaskItem is the
currently selected item in the task list.

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

proc deleteitem
integer i, j, k, l
i = getbbsi()
j = getitemi()
;If the current TaskItem is a BBS...
if j == 0
l = i
k = l + 1
BBS = readbbs(k)

;Decrement the BBS coordinate of each BBS after the one selected

while not NULLSTR BBS
writebbs(l, BBS)
l++
k++
BBS = readbbs(k)
endwhile
writebbs(l, "")
;Update the task list
maketasklist()
makebbslist()

;Reset the TaskItem. If the selected BBS was the last one
;in the list, set TaskItem to the previous BBS; otherwise,
;set it to the next BBS

BBS = readbbs(i)
if NULLSTR BBS
i--
BBS = readbbs(i)
if NULLSTR BBS
TaskItem = ""
else
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName i 0
endif
else
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName i 0
endif

else
;If the current TaskItem is an Item
l = j
k = l + 1

;Decrement the Item coordinate of each item after the one selected

Item = readitem(k)
while not NULLSTR Item
writeitem(l, Item)
l++
k++
Item = readitem(k)
endwhile
writeitem(l, "")
;Update the task list
maketasklist()

;Reset the TaskItem to the next Item for that BBS. If the selected
;Item was the last one for that BBS, set TaskItem to the previous
;Item. If it was the only item for that BBS, set it to the BBS name.

BBS = readbbs(i)
Item = readitem(j)
if not NULLSTR Item
;If it wasn't the last item...
TaskItem = gettaskstring(i, j)
elseif j == 1
;If it was the only item...
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName i 0
else
;If it was the last of multiple items...
j--
Item = readitem(j)
TaskItem = gettaskstring(i, j)
endif
endif
endproc


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

CHANGEMAILRUN()

Calls updatemrn(), copymrn(), loadsettings()

Saves the last mailrun and loads a new one.

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

proc changemailrun
;Update the last mailrun
updatemrn()
;Get the next mailrun and copy it to the temp directory
copymrn()
#ifndef MRUN200G
loadsettings()
#endif
endproc


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

RESETMAILRUN()

Calls readbbs(), readitem(), writeitem()

Resets completed permenant items to pending. Deletes
completed temporary items.

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

proc resetmailrun
string Pending, Perm
integer p1, p2, i, j, k
i = 1
BBS = readbbs(i)
;Loop through each BBS
while not NULLSTR BBS
j = 1
k = 1
Item = readitem(j)
;Loop through each Item
while not NULLSTR Item
;Clear the old item
writeitem(j, "")
strextract pending Item "," 0
strextract perm Item "," 1
atoi pending p1
atoi perm p2

;Items that are completed and temporary will not be updated
;The second counter "k" is required to avoid gaps where items
;are deleted.

if (p1 != 0) || (p2 != 0)
strupdt Item "1" 0 1
writeitem(k, Item)
k++
endif
j++
Item = readitem(j)
endwhile
i++
BBS = readbbs(i)
endwhile
endproc


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

CHANGESTATUS()

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

Changes the pending/complete permanent/temporary status
of the selected item on the task list. Responds to user
double-clicking on the item.

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

proc changestatus
string Pending, Perm, LastBBS, LastItem
integer i, j
i = getbbsi()
j = getitemi()
LastBBS = BBS
LastItem = Item
if j == 0
;If the item is a BBS
;Check for pending items
Pending = checkpending()
if strcmpi Pending "0"
;If no items are pending, set all to pending status
Pending = "1"
else
;If at least one item is pending, set all to completed status
Pending = "0"
endif
j = 1
Item = readitem(j)
;Update all items
while not NULLSTR Item
strupdt Item Pending 0 1
writeitem(j, Item)
j++
Item = readitem(j)
endwhile
maketasklist()
READNAME
strfmt TaskItem "%s`t`t`t%d`t%d" BBSName i 0
else
;If it is not a BBS
Item = readitem(j)
strextract Pending Item "," 0
strextract Perm Item "," 1
if not strcmpi Pending "1"
Pending = "1"
Perm = "0"
elseif strcmpi Perm "0"
Perm = "1"
else
Pending = "0"
endif
strupdt Item Pending 0 1
strupdt Item Perm 2 1
writeitem(j, Item)
maketasklist()
TaskItem = gettaskstring(i, j)
endif
if FLAGS & RUNNING
BBS = LastBBS
Item = LastItem
READNAME
endif
endproc


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

CHECKPENDING()

Calls readitem()

Checks a BBS for currently pending items. Returns "1" if
items are pending, "0" if none are pending.

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

func checkpending : string
string Pending = "0"
integer i
i = 1
Item = readitem(i)
while not NULLSTR Item
strextract pending Item "," 0
if strcmpi Pending "1"
exitwhile
endif
i++
Item = readitem(i)
endwhile
return Pending
endfunc


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

CHECKPERM()

Checks the Temporary/Permanent radiobutton set; returns
1 if Permanent (button 1) is selected, 0 if Temporary
(button 2).

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

func checkperm : string
string Perm
if PermRadio == 1
Perm = "1"
else
Perm = "0"
endif
return Perm
endfunc


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

CHECKCHILD()

Halts the script if the current script has not been
called by another script.

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

proc checkchild
if not ($CHILD || $CHAINED)
errormsg "This script can only be run from MAILRUN.WAX."
halt
endif
endproc


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

CHECKRUNNING()

Checks whether a mailrun is executing. Returns 0 and
generates a message if running, returns 1 if not.

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

func checkrunning : integer
if FLAGS & RUNNING
usermsg "You cannot create a new mailrun while a mailrun is executing."
return 0
else
return 1
endif
endfunc


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

CHECKCHANGED()

Checks whether the contents of the current dialog box
have changed and generates a warning. Returns 1 if
user elects to proceed or if there has been no change,
0 if user cancels.

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

func checkchanged : integer
integer Response
if FLAGS & CHANGED
sdlgmsgbox "MailRun Message" "Discard Changes?" QUESTION YESNO \
Response 2
switch Response
case 6
FLAGS &= UNCHANGED
return 1
endcase
case 7
return 0
endcase
endswitch
else
return 1
endif
endfunc


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

CHECKFILE()

Checks for a file's existence. Returns 1 if the file is
found, 0 if not found.

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

func checkfile : integer
strparm FileNom
if isfile FileNom
return 1
else
return 0
endif
endfunc


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

CHECKTASK()

Returns 1 if the specified application is already running;
otherwise returns 0.

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

func checktask : integer
strparm Called
string AppName
integer i
firsttask i
while i
taskname i AppName
if strfind Called AppName
return i
endif
nexttask i
endwhile
return 0
endfunc


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

CHECKNEW()

Returns 0 if the current mailrun is empty; else returns 1.

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

func checknew : integer
if NULLSTR TaskItem
usermsg "You must add a BBS before selecting this function!"
return 0
else
return 1
endif
endfunc


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

MENUDIM()

Enables all menu controls, then disables those which
cannot be used.

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

proc menudim
enable MENU 1 29
#ifndef MRUN200AG
disable MENU 3 6
disable MENU 22
#endif
#ifdef MRUN200G
disable MENU 1 3
disable MENU 5
#endif
endproc


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

CLEANUP()

Called by parsedialog(), openerror(), newmailrun(), dobbs()

Calls updatemrn(), cleardir()

Restores system settings, deletes temporary files, and
halts script.

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

proc cleanup
string StateCapPath, StateCapFile, StateDnldPath, StateUpldPath
integer StateAutoDL, StateActionBar, StateMetaKeys

;Update the last mailrun
profilewr MailRunIni "MailRun" "MailRun" MailRunTrunc
updatemrn()

;Retrieve the previous system state from the cleanup file
profilerd CleanupFile "Cleanup" "StateAutoDL" StateAutoDL
profilerd CleanupFile "Cleanup" "StateCapPath" StateCapPath
profilerd CleanupFile "Cleanup" "StateCapFile" StateCapFile
profilerd CleanupFile "Cleanup" "StateDnldPath" StateDnldPath
profilerd CleanupFile "Cleanup" "StateUpldPath" StateUpldPath
profilerd CleanupFile "Cleanup" "StateActionBar" StateActionBar
profilerd CleanupFile "Cleanup" "StateMetaKeys" StateMetaKeys

;Restore the settings
capture OFF
set capture path StateCapPath
set capture file StateCapFile
set dnldpath StateDnldPath
set upldpath StateUpldPath
set aspect rangechk ON
if StateAutoDL != 0
set autodnld ON
endif
if StateActionBar != 0
actionbar ON
endif
if StateMetaKeys != 0
metakeys ON
endif

cleardir(TempDir)
chdir MailRunDir
rmdir TempDir
statmsg ""
remove USERWIN
#ifdef MRUN200A
if PostRun == 3
closepw
endif
#endif
halt
endproc

#ifndef MRUN200G

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

SORTIDX()

Calls fieldcompare(), makefullname(), openerror(),
interfaceoff(), interfaceon()

Sorts an index file for display in the upload or download
dialog box. This routine uses two temp files to sort the
contents of the referenced file. It is used to sort an
index file that has not been previously sorted. The
method used is too slow when only a couple of new items
need to be sorted in the file.

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

proc sortidx
strparm idxName
intparm SortField
string temp1, temp2, Line1, Line2, LastLine
integer Unsorted, Readidx, Writeidx, i, counter
SortField -=2
if SortField < 0
return
endif
interfaceoff()
counter = 0
temp1 = makefullname(TempDir, "temp1.tmp")
temp2 = makefullname(TempDir, "temp2.tmp")
Unsorted = 0
Readidx = 1
Writeidx = 2
fopen Unsorted idxName READ TEXT
openerror(idxName)
fgets Unsorted Line1
statmsg "Sorting... %d" counter
if feof Unsorted
;if the index is empty, return
fclose Unsorted
interfaceon()
return
else
;otherwise, open temp files and sort
fopen Readidx temp1 CREATE TEXT
openerror(temp1)
fopen Writeidx temp2 CREATE TEXT
openerror(temp2)
;put the first line into the read file
fputs Readidx Line1
rewind Readidx
;get the next line of the unsorted file
fgets Unsorted Line1
counter++
statmsg "Sorting... %d" counter
fgets Readidx Line2
if feof Unsorted
;prevents a single file from being deleted
fputs Writeidx Line2
endif
while not feof Unsorted
while not feof Readidx
if fieldcompare(Line1, Line2, SortField)
exitwhile
endif
fputs Writeidx Line2
fgets Readidx Line2
endwhile
fputs Writeidx Line1
LastLine = Line1
fgets Unsorted Line1
counter++
statmsg "Sorting... %d" counter
if feof Unsorted
while not feof Readidx
fputs Writeidx Line2
fgets Readidx Line2
endwhile
exitwhile
elseif !(fieldcompare(Line1, LastLine, SortField))
loopwhile
endif
while not feof Readidx
fputs Writeidx Line2
fgets Readidx Line2
endwhile
rewind Readidx
rewind Writeidx
i = Readidx
Readidx = Writeidx
Writeidx = i
fgets Readidx Line2
endwhile
fclose Unsorted
fclose Readidx
fclose Writeidx
delfile idxName
if Writeidx == 1
copyfile temp1 idxName
else
copyfile temp2 idxName
endif
delfile temp1
delfile temp2
endif
statmsg ""
interfaceon()
endproc


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

BUBBLESORT()

Calls fieldcompare()

Sorts one new line into an already sorted file, the open
file index of which is received as a parameter.

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

proc bubblesort
intparm SortFile, SortField
string Line1, Line2
long i
SortField -= 2
ftell SortFile i
i = (i / 100) - 2

if (SortField < 0) || (i < 0)
return
endif
;get the last 2 lines of the file
fseek SortFile -200 2
fgets SortFile Line2
fgets SortFile Line1
while 1
fseek SortFile -200 1
if fieldcompare(Line1, Line2, SortField)
fputs SortFile Line1
fputs SortFile Line2
i -= 1
if i >= 0
fseek SortFile -300 1
fgets SortFile Line2
fgets SortFile Line1
else
exitwhile
endif
else
exitwhile
endif
endwhile
fseek SortFile 0 2
endproc


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

FIELDCOMPARE()

Called by sortidx()

Compares two fields. Returns 0 if Field1 > Field2,
1 if Field1 <= Field2.

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

func fieldcompare : integer
strparm Line1, Line2
intparm FieldType
string Field1, Field2
integer i, char1, char2
long number1, number2, Date1, Date2
strextract Field1 Line1 "`t" FieldType
strextract Field2 Line2 "`t" FieldType
switch FieldType
case ALPHA
i = 0
while i < 12
strpeek Field1 i char1
strpeek Field2 i char2
if (char1 > char2) || ((char1 == 0) && (char2 == 0))
return 0
elseif (char1 < char2)
return 1
endif
i++
endwhile
return 1
endcase
case NUMERIC
atol Field1 number1
atol Field2 number2
if number1 >= number2
return 0
else
return 1
endif
endcase
case MMDDYY
strsltime Field1 "00:00:00" Date1
strsltime Field2 "00:00:00" Date2
if Date1 >= Date2
return 0
else
return 1
endif
endcase
endswitch
endfunc

#endif


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

INTERFACEON()
INTERFACEOFF()

Activate and deactivate the menu and iconbar.

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

proc interfaceon
when menu call parsemenu
when object call parseobject
endproc

proc interfaceoff
clearwhen menu
clearwhen object
endproc


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

findstring()

Called by getconfprompt(), respond()

Returns a value of 1 if the second string is contained
in the first string; otherwise returns 0.

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

func findstring : integer
strparm String1, String2
integer i = 0
if not NULLSTR String2
if strfind String1 String2
i = 1
endif
endif
return i
endfunc


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

PARSEMENU()

Parses a selection from the MailRun menu.

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

proc parsemenu
integer menustatus
menustatus = $MENU
switch menustatus
case 1
;User selected file.new
filenewmrun()
endcase
case 2
;User selected file.save
filesave()
endcase
case 3
;User selected file.save_as
filesaveas()
endcase
case 4
;User selected file.reset
filereset()
endcase
case 5
;User selected file.delete_mailrun
filedelmrun()
endcase
case 6
;User selected delete_item
filedelitem()
endcase
case 7
;User selected file.exit
fileexit()
endcase
case 8
;User selected configure.mailrun_settings
cfgmrun()
endcase
case 9
;User selected configure.bbs_settings
cfgbbs()
endcase
case 10
;User selected configure.bbs_prompts
cfgprompts()
endcase
case 11
;User selected configure.bbs_mail_door
cfgmaildoor()
endcase
case 12
;User selected configure.defaults.mailrun
defaultsmailrun()
endcase
case 13
;User selected configure.defaults.bbs
defaultsbbs()
endcase
case 14
;User selected configure.defaults.prompts
defaultsprompts()
endcase
case 15
;User selected configure.defaults.maildoor
defaultsdoor()
endcase
case 16
;User selected add.new_bbs
addnewbbs()
endcase
case 17
;User selected add.get/send_mail
addgetsend()
endcase
case 18
;User selected add.upload_file
addupload()
endcase
case 19
;User selected add.download_file
adddownload()
endcase
case 20
;User selected add.send_command
addsendcmd()
endcase
case 21
;User selected add.execute_script
addscript()
endcase
case 22
;User selected execute.mailrun
executemailrun()
endcase
case 23
;User selected execute.qwk_reader
executeqwkreader()
endcase
case 24
;User selected execute.archiver
executearchiver()
endcase
case 25
;User selected execute.view_log_file
executelogviewer()
endcase
case 26
;User selected help.contents
helpcontents()
endcase
case 27
;User selected help.current_window
helpcontext()
endcase
case 28
;User selected help.about
helpabout()
endcase
endswitch
endproc


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

PARSEOBJECT()

Parses a selection from the MailRun icon bar.

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

proc parseobject
integer objectstatus
objectstatus = $OBJECT
switch objectstatus
case 1
;User selected icon for execute.mailrun
executemailrun()
endcase
case 2
;User selected icon for file.reset
filereset()
endcase
case 3
;User selected icon for file.new
filenewmrun()
endcase
case 4
;User selected icon for configure.bbs
cfgbbs()
endcase
case 5
;User selected icon for add.new_bbs
addnewbbs()
endcase
case 6
;User selected icon for add.get/send_mail
addgetsend()
endcase
case 7
;User selected icon for add.upload_file
addupload()
endcase
case 8
;User selected icon for add.download_file
adddownload()
endcase
case 9
;User selected icon for add.send_command
addsendcmd()
endcase
case 10
;User selected icon for add.execute_script
addscript()
endcase
case 11
;User selected icon for file.delete_item
filedelitem()
endcase
case 12
;User selected icon for execute.view_log_file
executelogviewer()
endcase
case 13
;User selected icon for execute.qwk_reader
executeqwkreader()
endcase
case 14
;User selected icon for execute.archiver
executearchiver()
endcase
case 15
;User selected icon for file.exit
fileexit()
endcase
case 16
;User selected icon for context sensitive help
helpcontext()
endcase
endswitch
endproc


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

The following procedures correspond to menu selections
and are called from parsemenu() and parseobject().

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

proc filenewmrun
#ifndef MRUN200G
if checkrunning() && checkchanged()
FLAGS = FLAGS & (ALLFLAGS - DEFAULTS)
FLAGS |= NEW
callscript(changesettings)
endif
#endif
endproc

proc filesave
#ifndef MRUN200G
updatemrn()
#endif
endproc

proc filesaveas
#ifdef MRUN200A
string NewRun, temp
integer Response
;Make sure the entered MailRun ID is the correct length
;and that it doesn't already exist
while 1
NewRun = ""
sdlginput "New MailRun" \
"Save the current mailrun as:" NewRun
if FAILURE
exit
endif
strlwr NewRun
if not fverify(NewRun)
usermsg \
"A mailrun ID must be a valid DOS file name without the extension."
else
exitwhile
endif
strfmt temp "%s.mrn" NewRun
NewRun = makefullname(MailRunDir, temp)
if isfile NewRun
sdlgmsgbox "MailRun Message" \
"%s already exists!`r`n`r`nReplace it?" QUESTION YESNO Response 2
if Response == 7
;if user selected "No"
NewRun = ""
loopwhile
endif
endif
exitwhile
endwhile
delfile NewRun
MailRunTrunc = temp
copyfile MailRun NewRun
copymrn()
makemailrunlist()
updatedlg 512
#endif
endproc

proc filereset
#ifdef MRUN200AG
resetmailrun()
maketasklist()
getfirstitem()
updatedlg 80
#endif
endproc

proc filedelmrun
#ifdef MRUN200A
string LastMRun
findfirst MailRun
LastMRun = makefullname(MailRunDir, $FILENAME)
delfile LastMRun
LastMRun = makefullname(MailRunDir, "*.MRN")
findfirst LastMRun
MailRunTrunc = $FILENAME
copymrn()
makemailrunlist()
maketasklist()
getfirstitem()
updatedlg -1
#endif
endproc

proc filedelitem
#ifdef MRUN200AG
string LastBBS, LastItem
LastBBS = BBS
LastItem = Item
deleteitem()
if FLAGS & RUNNING
BBS = LastBBS
Item = LastItem
READNAME
endif
updatedlg 80
#endif
endproc

proc fileexit
cleanup()
endproc

proc cfgmrun
if checkchanged()
FLAGS &= RUNNING
configmrun()
endif
endproc

proc configmrun
#ifdef MRUN200B
main()
#else
callscript(changesettings)
#endif
endproc

proc cfgbbs
if checkchanged() && checknew()
FLAGS &= RUNNING
configbbs()
endif
endproc


proc configbbs
#ifndef MRUN200C
FLAGS = (FLAGS & CLEARCMD) | USR
callscript(changebbs)
#else
changeuserinfo()
#endif
endproc

proc cfgprompts
if checkchanged() && checknew()
FLAGS &= RUNNING
configprompts()
endif
endproc

proc configprompts
#ifndef MRUN200C
FLAGS = (FLAGS & CLEARCMD) | PRMPT
callscript(changebbs)
#else
changeprompts()
#endif
endproc

proc cfgmaildoor
if checkchanged() && checknew()
FLAGS &= RUNNING
configmaildoor()
endif
endproc

proc configmaildoor
#ifndef MRUN200C
FLAGS = (FLAGS & CLEARCMD) | QMD
callscript(changebbs)
#else
changemaildoor()
#endif
endproc

proc defaultsmailrun
#ifdef MRUN200B
if FLAGS & DEFAULTS
return
endif
#endif
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configmrun()
endif
endproc

proc defaultsbbs
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configbbs()
endif
endproc

proc defaultsprompts
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configprompts()
endif
endproc

proc defaultsdoor
if checkchanged()
FLAGS &= RUNNING
FLAGS |= DEFAULTS
configmaildoor()
endif
endproc

proc addnewbbs
if checkchanged()
FLAGS &= RUNNING
FLAGS |= NEW
#ifndef MRUN200C
FLAGS = (FLAGS & CLEARCMD) | USR
callscript(changebbs)
#else
changeuserinfo()
#endif
endif
endproc

proc addgetsend
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN200F
FLAGS = (FLAGS & CLEARCMD) | AGM
callscript(othercmds)
#else
addgetmail()
#endif
endif
endproc

proc adddownload
#ifndef MRUN200D
if checkchanged() && checknew()
FLAGS &= RUNNING
callscript(adddlfile)
endif
#endif
endproc

proc addupload
#ifndef MRUN200E
if checkchanged() && checknew()
FLAGS &= RUNNING
callscript(addulfile)
endif
#endif
endproc

proc addsendcmd
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN200F
FLAGS = (FLAGS & CLEARCMD) | CMD
callscript(othercmds)
#else
addsendcommand()
#endif
endif
endproc

proc addscript
if checkchanged() && checknew()
FLAGS &= RUNNING
#ifndef MRUN200F
FLAGS = (FLAGS & CLEARCMD) | SCR
callscript(othercmds)
#else
adddoscript()
#endif
endif
endproc


proc executemailrun
#ifdef MRUN200G
hangup
FLAGS &= IDLE
capture OFF
exit
#endif
#ifdef MRUN200A
if FLAGS & RUNNING
FLAGS &= IDLE
else
FLAGS |= RUNNING
endif
#endif
endproc

proc executearchiver
integer i
#ifdef MRUN200G
string Archiver
profilerd MailRun "MailRun" "Archiver" Archiver
#endif
if not NULLSTR Archiver
i = checktask(Archiver)
if i
activatetask i
else
run Archiver
endif
if FAILURE
usermsg "Unable to run Archive Utility %s .`r`n\
The file does not exist or is not in your DOS path." Archiver
endif
else
usermsg "You must specify an Archive Utility in`r`n\
the MailRun Settings dialog box."
endif
endproc

proc executeqwkreader
integer i
#ifdef MRUN200G
string QWKReader
profilerd MailRun "MailRun" "QWKReader" QWKReader
#endif
if not NULLSTR QWKReader
i = checktask(QWKReader)
if i
activatetask i
else
run QWKReader
endif
if FAILURE
usermsg "Unable to run QWK Mail Reader %s.`r`n\
The file does not exist or is not in your DOS path." QWKReader
endif
else
usermsg "You must specify a QWK Mail Reader in`r`n\
the MailRun Settings dialog box."
endif
endproc

proc executelogviewer
string CapFile, RunLine, WinTitle
integer i, j
#ifdef MRUN200G
string LogViewer
profilerd MailRun "MailRun" "LogViewer" LogViewer
#endif
if not NULLSTR LogViewer
if not NULLSTR MailRunTrunc
CapFile = makefullname(MailRunDir, MailRunTrunc)
strlwr CapFile
strreplace CapFile ".mrn" ".cap"
else
CapFile = ""
endif
i = checktask(LogViewer)
if i
taskwin i j
getwintext j WinTitle
if strfind WinTitle CapFile
activatetask i
return
endif
endif
strfmt RunLine "%s %s" LogViewer CapFile
run RunLine
if FAILURE
usermsg "Unable to run Log File Viewer %s.`r`n\
The file does not exist or is not in your DOS path." LogViewer
endif
else
usermsg "You must specify a Log File Viewer in`r`n\
the MailRun Settings dialog box."
endif
endproc

proc helpcontents
help 1
endproc

proc helpcontext
help HelpPage
endproc

proc helpabout
if checkchanged()
FLAGS &= RUNNING
#ifndef MRUN200F
FLAGS = (FLAGS & CLEARCMD) | ABT
callscript(othercmds)
#else
showabout()
#endif
endif
endproc


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

CALLSCRIPT()

Called by parsedialog()

Calls addbbs(), cleanup(), mailrunbox()

Executes the specified portion of MailRun.

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

proc callscript
strparm ScriptTitle
#ifndef MRUN200AG
chain ScriptTitle
#else
string LastMRun
LastMRun = MailRun
execute ScriptTitle
menudim()
FLAGS &= RUNNING
#ifdef MRUN200G
READNAME
profilerd MailRun "MailRun" "LogRun" LogRun
if LogRun
profilerd MailRun "MailRun" "AnsiInLog" AnsiInLog
if AnsiInLog
set capture mode append RAW
else
set capture mode append VISUAL
endif
capture ON
else
capture OFF
endif
#endif
findfirst MailRun
MailRunTrunc = $FILENAME
makemailrunlist()
makebbslist()
maketasklist()
if not strcmpi LastMRun MailRun
getfirstitem()
endif
mailrunbox()
statmsg ""
#endif
endproc





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

  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/