 Rem File: Editcmd3 for Dndbbs Version v5.0a Release r2.0
 Rem $Include: 'edit.inc'

 On Error Goto ErrMain0
 If Chained2=False Then
    Call Open.Arrays
    Call Get.Config
    Call Increase.Files
    Call Make.FileNames
    Call Open.Files
    Call Reset.Cursor
    Call Detect.Share
    Call Save.Screen2(0)
    Call Passwrd9(Var,"3")
    If Var=False Then
       Call Terminate.Program
       End
    Endif
 Endif
 Call Edit.Mail
MainExit0:
 End
ErrMain0:
 Resume MainExit0
 End

Sub Edit.Mail
 On Local Error Goto ErrResume126
 Call Edit.Status.Line
 Redim Temp.ArrayS(1 To 19) As String
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Email Edit utility v"+Left$(Version$,4)+" menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(145,"[A]")+"dd"
       Call IO.O
       Strng=RT$(146,"[C]")+"hange"
       Call IO.O
       Strng=RT$(147,"[D]")+"elete"
       Call IO.O
       Strng=RT$(148,"[E]")+"dit"
       Call IO.O
       Strng=RT$(149,"[L]")+"ist"
       Call IO.O
       Strng=RT$(150,"[P]")+"ack"
       Call IO.O
       Strng=RT$(151,"[S]")+"earch"
       Call IO.O
       Strng=RT$(152,"[U]")+"ndelete"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(584,"[V]")+"Print"
          Call IO.O
       Endif
       Graphics.Off=False
    Endif
    Strng="Message base edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(145,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Add.Base
       Endif
    Case "C"
       If RT$(146,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Change.Base
       Endif
    Case "D"
       If RT$(147,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Delete.Base
       Endif
    Case "E"
       If RT$(148,"[E]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Edit.Messages
       Endif
    Case "L"
       If RT$(149,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call List.Bases(True)
       Endif
    Case "P"
       If RT$(150,"[P]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Pack.Bases
       Endif
    Case "S"
       If RT$(151,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Search.Bases
       Endif
    Case "U"
       If RT$(152,"[U]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Undelete.Base
       Endif
    Case "V"
       If Local.Mode Then
          If RT$(584,"[V]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Print.Bases
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Erase Temp.ArrayS
 Close
 Call Clear.Status.Line
 If Chained2 Then
    Chain DND.Path+"EDIT.EXE"
 Endif
 Call Terminate.Program
ErrExit126:
 Exit Sub
ErrResume126:
 Resume ErrExit126
End Sub

Sub Display.BaseTypes(Var)
 On Local Error Goto ErrResume127
 If TempC Then
    Exit Sub
 Endif
 Graphics.Off=True
 Strng="[1]Public"
 If (Var And Public.Base)=Public.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[2]Private"
 If (Var And Private.Base)=Private.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[3]Dungeon Master"
 If (Var And DM.Base)=DM.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[4]Sysop"
 If (Var And Sysop.Base)=Sysop.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[5]Town Mayor"
 If (Var And TownMayor.Base)=TownMayor.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[6]Governor"
 If (Var And Governor.Base)=Governor.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[7]Guild Master"
 If (Var And GuildMaster.Base)=GuildMaster.Base Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[8]Assistant DM"
 If (Var And 128)=128 Then
    Strng=Strng+" (yes)"
 Else
    Strng=Strng+" (no)"
 Endif
 Call IO.O
 Strng="[9]Clear types"
 Call IO.O
 Strng="[10]Set all types"
 Call IO.O
 Graphics.Off=False
ErrExit127:
 Exit Sub
ErrResume127:
 Resume ErrExit127
End Sub

Sub List.Bases(Var)
 On Local Error Goto ErrResume128
 Graphics.Off=True
 If Var Then
    Strng=Mask$+"1: Public, Type: (public)"
    Call IO.O
    If Break Then
       Exit Sub
    Endif
    Strng=Mask$+"2: Private, Type: (private)"
    Call IO.O
    If Break Then
       Exit Sub
    Endif
 Endif
 Allow.Break=True
 Break=False
 Continuous=False
 If Var Then
    Temp1=2
 Else
    Temp1=False
 Endif
 For Temp!=1! To Lof(MessBaseFile)/MessBaseRecLen
    Call Read.Record(MessBaseFile,Temp!)
    If Var Then
       Temp2!=Temp!+2!
    Else
       Temp2!=Temp!
    Endif
    If MessageBaseRecord.BaseDeleted Then
       Strng=Mask$+Mid$(Str$(Temp2!),2)+": "+Deleted$
       Call IO.O
       If Break Then
	  Exit For
       Endif
    Else
       Out2=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
       If Len(Out2) Then
          Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
       Endif
       If Len(Out2)>40 Then
          Out2=Left$(Out2,40)+".."
       Endif
       Strng=Mask$+Mid$(Str$(Temp2!),2)+": "+Out2
       Strng=Strng+", Type: "
       If MessageBaseRecord.BaseType And Public.Base Then
	  Strng=Strng+"(public) "
       Endif
       If MessageBaseRecord.BaseType And Private.Base Then
	  Strng=Strng+"(private) "
       Endif
       If MessageBaseRecord.BaseType And DM.Base Then
	  Strng=Strng+"(DMs only) "
       Endif
       If MessageBaseRecord.BaseType And Sysop.Base Then
	  Strng=Strng+"(Sysops only) "
       Endif
       If MessageBaseRecord.BaseType And TownMayor.Base Then
	  Strng=Strng+"(Town Mayor) "
       Endif
       If MessageBaseRecord.BaseType And Governor.Base Then
	  Strng=Strng+"(Governor) "
       Endif
       If MessageBaseRecord.BaseType And GuildMaster.Base Then
	  Strng=Strng+"(Guild Master) "
       Endif
       If MessageBaseRecord.BaseType And 128 Then
          Strng=Strng+"(Assistant DM) "
       Endif
       Strng=Rtrim$(Strng)
       Call IO.O
       If Break Then
	  Exit For
       Endif
       Temp1=Temp1+1
       If Temp1>=User.Pagelength-2 Then
	  Temp1=False
	  If Continuous=False Then
	     Call More.Prompt
	     If No Or Quit Then
		Exit For
	     Endif
	  Endif
       Endif
    Endif
 Next
 Allow.Break=False
 Break=False
 If Temp1 Then
    Call More.Prompt
 Endif
 If Var=False Then
    If Lof(MessBaseFile)/MessBaseRecLen=SFalse Then
       Strng="No extended message bases to edit."
       Call IO.O
    Endif
 Endif
ErrExit128:
 Exit Sub
ErrResume128:
 Resume ErrExit128
End Sub

Sub Print.Bases
 On Local Error Goto ErrResume128a
 Strng="Printer port(1-3)? "
 Call IO.I
 VarP=Int(Val(Out2))
 If VarP>=1 And VarP<=3 Then
    Close #TempFile1
    VarP$="LPT"+Mid$(Str$(VarP),2)+":"
    Open VarP$ For Output As #TempFile1
    Graphics.Off=True
    Strng=Mask$+"1: Public, Type: (public)"
    Print #TempFile1,Strng
    Strng=Mask$+"2: Private, Type: (private)"
    Print #TempFile1,Strng
    Temp1=2
    For Temp!=1! To Lof(MessBaseFile)/MessBaseRecLen
    Call Read.Record(MessBaseFile,Temp!)
       Temp2!=Temp!+2!
       If MessageBaseRecord.BaseDeleted Then
          Strng=Mask$+Mid$(Str$(Temp2!),2)+": "+Deleted$
          Print #TempFile1,Strng
       Else
          Out2=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
          If Len(Out2) Then
             Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
          Endif
          If Len(Out2)>40 Then
             Out2=Left$(Out2,40)+".."
          Endif
          Strng=Mask$+Mid$(Str$(Temp2!),2)+": "+Out2
          Strng=Strng+", Type: "
          If MessageBaseRecord.BaseType And Public.Base Then
             Strng=Strng+"(public) "
          Endif
          If MessageBaseRecord.BaseType And Private.Base Then
             Strng=Strng+"(private) "
          Endif
          If MessageBaseRecord.BaseType And DM.Base Then
             Strng=Strng+"(DMs only) "
          Endif
          If MessageBaseRecord.BaseType And Sysop.Base Then
             Strng=Strng+"(Sysops only) "
          Endif
          If MessageBaseRecord.BaseType And TownMayor.Base Then
             Strng=Strng+"(Town Mayor) "
          Endif
          If MessageBaseRecord.BaseType And Governor.Base Then
             Strng=Strng+"(Governor) "
          Endif
          If MessageBaseRecord.BaseType And GuildMaster.Base Then
             Strng=Strng+"(Guild Master) "
          Endif
          If MessageBaseRecord.BaseType And 128 Then
             Strng=Strng+"(Assistant DM) "
          Endif
          Strng=Rtrim$(Strng)
          Print #TempFile1,Strng
          Temp1=Temp1+1
          If Temp1>58 Then
             Temp1=False
             Print #TempFile1,Chr$(12);
          Endif
       Endif
    Next
    If Temp1 Then
       Print #TempFile1,Chr$(12);
    Endif
 Endif
ErrExit128a:
 Close #TempFile1
 Exit Sub
ErrResume128a:
 Resume ErrExit128a
End Sub

Sub Add.Base
 On Local Error Goto ErrResume129
 Do While Lost.Carrier=False
    Graphics.Off=True
    Strng="Message base topic name? "
    No.Input.Out=Nul
    Call IO.I
    Out3=Out2
    Var = 1
    Do
       TempX$="BASE"+Mid$(Str$(Var),2)
       FileName=Data.Path4+TempX$+".TBL"
       If Dir$(FileName)=Nul Then
          FileName=Data.Path4+TempX$+".DAT"
          If Dir$(FileName)=Nul Then
             FileName=Data.Path4+TempX$+".NEW"
             If Dir$(FileName)=Nul Then
                Exit Do
             Endif
          Endif
       Endif
       Var = Var + 1
       If Var = 10000 Then ' base9999
          TempX$=Nul
          Strng="No available base filenames."
          Call IO.O
          Exit Do
       Endif
    Loop
    If TempX$<>Nul Then
       FileName=Data.Path4+TempX$+".TBL"
       Close TempFile1
       Open FileName For Output As #TempFile1
       FileName=Data.Path4+TempX$+".DAT"
       Close TempFile1
       Open FileName For Output As #TempFile1
       FileName=Data.Path4+TempX$+".NEW"
       Close TempFile1
       Open FileName For Output As #TempFile1
       Close TempFile1
    Endif
    Do
       If TempX$=Nul Then
          Strng="Message base filename(8 letters DOS)? "
          No.Input.Out=Nul
          Call IO.I
       Else
          Strng="Message base filename("+TempX$+")? "
          No.Input.Out=TempX$
          Call IO.I
       Endif
       If Out2=Nul Then
          Strng="Missing filename."
          Call IO.O
       Else
          If Instr(Out2,":") Or Instr(Out2,"/") Or Instr(Out2,".") Or _
          Instr(Out2,"\") Or Instr(Out2,"?") Or Instr(Out2,"*") Then
             Strng="Illegal characters."
             Call IO.O
          Else
             Out4=Ucase$(Out2)
             Exit Do
          Endif
       Endif
    Loop
    Temp2=False
    Do While Lost.Carrier=False
       Call Display.BaseTypes(Temp2)
       Strng="Message base type option(q to quit)? "
       Line.Length=TempD
       No.Input.Out="Q"
       Call IO.I
       If Ucase$(Out2)="Q" Then
	  Exit Do
       Endif
       Temp=Int(Val(Out2))
       Select Case Temp
       Case 1 To 8
          Temp2=Temp2 Xor 2^(Temp-1)
       Case 9
          Temp2=False
       Case 10
          Temp2=255
       End Select
    Loop
    Graphics.Off=False
    Strng="Add to message base file(y/n)? "
    Line.Length=TempD
    No.Input.Out="Y"
    Call IO.I
    If Yes Then
       TempX$=Out4
       Call Test.Mail(VarX)
       If VarX Then
          Strng="Illegal base filename."
          Call IO.O
       Else
          Temp!=Lof(MessBaseFile)/MessBaseRecLen+1!
          MessageBaseRecord.BaseDeleted=False
          MessageBaseRecord.BaseMessName=Out3
          MessageBaseRecord.BaseFileName=Out4
          MessageBaseRecord.BaseType=Temp2
          Call Write.Record(MessBaseFile,Temp!)
       Endif
    Endif
    Strng="Add another message base(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If No Then
       Exit Do
    Endif
 Loop
ErrExit129:
 Exit Sub
ErrResume129:
 Resume ErrExit129
End Sub

Sub Change.Base
 On Local Error Goto ErrResume130
 Call List.Bases(False)
 Temp3!=Lof(MessBaseFile)/MessBaseRecLen
 If Temp3!=SFalse Then
    Strng="Message base not found."
    Call IO.O
    Exit Sub
 Endif
 Strng="Message base number"
 Call Get.Record.Range4(0!,Temp3!,Temp5!)
 If Temp5!=SFalse Then
    Strng="Message base not found."
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(MessBaseFile,Temp5!)
 Do While Lost.Carrier=False
    Graphics.Off=False
    Strng=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
    If Len(Strng)>40 Then
       Strng=Left$(Strng,40)+".."
    Endif
    If Len(Strng) Then
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
    Else
       Strng="<none>"
    Endif
    Strng="Editing "+Chr$(34)+Strng+Chr$(34)+" message base."
    Call IO.O
    Graphics.Off=True
    If TempC=False Then
       Strng=RT$(153,"[C]")+"lasstype"
       Call IO.O
       Strng=RT$(154,"[F]")+"ilename"
       Call IO.O
       Strng=RT$(155,"[T]")+"opic"
       Call IO.O
       Graphics.Off=False
    Endif
    Strng="Message base change option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "C"
       If RT$(153,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Temp2=MessageBaseRecord.BaseType
          Do While Lost.Carrier=False
             Call Display.BaseTypes(Temp2)
             Strng="Message base type option(q to quit)? "
             Line.Length=TempD
             No.Input.Out="Q"
             Call IO.I
             If Ucase$(Out2)="Q" Then
                Exit Do
             Endif
             Temp=Int(Val(Out2))
             Select Case Temp
             Case 1 To 8
                Temp2=Temp2 Xor 2^(Temp-1)
             Case 9
                Temp2=False
             Case 10
                Temp2=255
             End Select
          Loop
          MessageBaseRecord.BaseType=Temp2
       Endif
    Case "F"
       If RT$(154,"[F]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng2=Rtrim$(MessageBaseRecord.BaseFileName)
          If Len(Strng2)=0 Then
             Strng="Message base filename(8 letters DOS)? "
          Else
             Strng="Message base filename("+Strng2+")? "
          Endif
          No.Input.Out=Strng2
          Call IO.I
          MessageBaseRecord.BaseFileName=Ucase$(Out2)
       Endif
    Case "T"
       If RT$(155,"[T]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng3=Rtrim$(MessageBaseRecord.BaseMessName)
          Strng2=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
          If Len(Strng2)>40 Then
             Strng2=Left$(Strng2,40)+".."
          Endif
          If Len(Strng2) Then
             Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
          Endif
          If Strng2=Nul Then
             Strng="Message base topic name:"
          Else
             Strng="Message base topic name("+Strng2+")"
          Endif
          Call IO.O
          Strng="?"
          No.Input.Out=Nul
          Call IO.I
          If Out2=Nul Then
             Out2=Strng3
          Endif
          MessageBaseRecord.BaseMessName=Out2
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 TempX$=MessageBaseRecord.BaseFileName
 Call Test.Mail(VarX)
 If VarX Then
    Strng="Illegal base filename."
 Else
    Call Write.Record(MessBaseFile,Temp5!)
    Strng="Message base changed."
 Endif
 Call IO.O
ErrExit130:
 Exit Sub
ErrResume130:
 Resume ErrExit130
End Sub

Sub Test.Mail(Var)
 On Local Error Goto ErrResume130a
 Var=False
 ' check control characters
 For VarX=1 To Len(TempX$)
    VarZ=Asc(Mid$(TempX$,VarX,1))
    If VarZ>=0 And VarZ<=31 Then
       Var=True
       Exit Sub
    Endif
 Next

 ' check filename characters
 If Instr(TempX$,":") Or Instr(TempX$,"/") Or Instr(TempX$,".") Or _
 Instr(TempX$,"\") Or Instr(TempX$,"?") Or Instr(TempX$,"*") Then
    Var=True
    Exit Sub
 Endif

 Close #TableFile, #MessageFile, #NewFile
 FileName=Data.Path4+TempX$+".TBL"
 Open FileName For Random Shared As #TableFile Len=TableRecLen
 FileName=Data.Path4+TempX$+".DAT"
 Open FileName For Random Shared As #MessageFile Len=MessageRecLen
 FileName=Data.Path4+TempX$+".NEW"
 Open FileName For Random Shared As #NewFile Len=NewMessRecLen
ErrExit130a:
 Exit Sub
ErrResume130a:
 Var=True
 Resume ErrExit130a
End Sub

Sub Delete.Base
 On Local Error Goto ErrResume131
 Call List.Bases(False)
 Temp3!=Lof(MessBaseFile)/MessBaseRecLen
 If Temp3!=SFalse Then
    Exit Sub
 Endif
 Strng="Delete base number"
 Call Get.Record.Range2(1!,Temp3!,Temp5!)
 If Temp5!>2! Then
    Call Read.Record(MessBaseFile,Temp5!-2!)
    If MessageBaseRecord.BaseDeleted Then
       Strng="Message base already deleted."
    Else
       MessageBaseRecord.BaseDeleted=True
       Call Write.Record(MessBaseFile,Temp5!-2!)
       Strng="Message base deleted."
    Endif
 Else
    Strng="Cannot delete mess base."
 Endif
 Call IO.O
ErrExit131:
 Exit Sub
ErrResume131:
 Resume ErrExit131
End Sub

Sub Undelete.Base
 On Local Error Goto ErrResume132
 Call List.Bases(False)
 Temp3!=Lof(MessBaseFile)/MessBaseRecLen
 If Temp3!=SFalse Then
    Exit Sub
 Endif
 Strng="Undelete base number"
 Call Get.Record.Range2(1!,Temp3!,Temp5!)
 If Temp5!>2! Then
    Call Read.Record(MessBaseFile,Temp5!-2!)
    If MessageBaseRecord.BaseDeleted=False Then
       Strng="Message base not deleted."
    Else
       MessageBaseRecord.BaseDeleted=False
       Call Write.Record(MessBaseFile,Temp5!-2!)
       Strng="Message base undeleted."
    Endif
 Else
    Strng="Cannot undelete mess base."
 Endif
 Call IO.O
ErrExit132:
 Exit Sub
ErrResume132:
 Resume ErrExit132
End Sub

Sub Pack.Bases
 On Local Error Goto ErrResume133
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't pack while node/user online."
    Call IO.O
    Exit Sub
 Endif
 Strng="Delete empty message bases(y/n)? "
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 If Yes Then
    Graphics.Off=True
    Carriage.Return=True
    Strng="Making backup of message bases file"
    Call IO.O
    FileName=Left$(Message.Base.Filename,Instr(Message.Base.Filename,"."))+"bak"
    Close #TempFile1
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TempFile1 Len=MessBaseRecLen
    VarD=False
    VarE=False
    VarF!=Timeit!
    For Temp3!=1! To Lof(MessBaseFile)/MessBaseRecLen
       Call Read.Record(MessBaseFile,Temp3!)
       Call Write.TempFile(6,Temp3!)
       Call Dot.Display(VarD,VarE,VarF!)
    Next
    Call IO.O
    FileName=Message.Base.Filename
    Close #MessBaseFile
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #MessBaseFile Len=MessBaseRecLen
    Graphics.Off=True
    Carriage.Return=True
    Strng="Deleting message bases"
    Call IO.O
    VarD=False
    VarE=False
    VarF!=Timeit!
    Temp1!=SFalse
    For Temp3!=1! To Lof(TempFile1)/MessBaseRecLen
       Call Read.TempFile(6,Temp3!)
       Call Dot.Display(VarD,VarE,VarF!)
       If MessageBaseRecord.BaseDeleted Then
          ' nul
       Else
          Temp1!=Temp1!+1!
          Call Write.Record(MessBaseFile,Temp1!)
       Endif
    Next
    Call IO.O
 Endif
 Close #TempFile1
 Graphics.Off=False
 Strng="Message base file packed."
 Call IO.O
 Call More.Prompt
ErrExit133:
 Exit Sub
ErrResume133:
 Resume ErrExit133
End Sub

Sub Search.Bases
 On Local Error Goto ErrResume64
 TempA=False
 TempA$=Nul
 TempB$=Nul
 Do While Lost.Carrier=False
    Graphics.Off=True
    If TempC=False Then
       Strng="[A]message base name"
       If TempA$<>Nul Then
          Strng=Strng+Space$(30-Len(Strng))
          Strng=Strng+"("+TempA$+")"
       Endif
       Call IO.O
       Strng="[B]message base filename"
       If TempB$<>Nul Then
          Strng=Strng+Space$(30-Len(Strng))
          Strng=Strng+"("+TempB$+")"
       Endif
       Call IO.O
       Strng="[C]message base type"
       If TempA Then
          Strng=Strng+Space$(30-Len(Strng))
          Strng=Strng+"(type:"+Str$(TempA)+")"
       Endif
       Call IO.O
       Graphics.Off=False
    Endif
    Strng="Message base search option(S to search, Q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Graphics.Off=False
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       Strng="Message base name substring? "
       Call IO.I
       TempA$=Ucase$(Out2)
    Case "B"
       Strng="Message base filename(8 letter DOS)? "
       Call IO.I
       TempB$=Ucase$(Out2)
    Case "C"
       Do While Lost.Carrier=False
          Call Display.BaseTypes(TempA)
          Strng="Message base type option(q to quit)? "
          Line.Length=TempD
          No.Input.Out="Q"
          Call IO.I
          If Ucase$(Out2)="Q" Then
             Exit Do
          Endif
          Temp=Int(Val(Out2))
          Select Case Temp
          Case 1 To 8
             TempA=TempA Xor 2^(Temp-1)
          Case 9
             TempA=False
          Case 10
             TempA=255
          End Select
       Loop
    Case "S"
       Strng="Searching message bases."
       Call IO.O
       Temp6=False
       Graphics.Off=True
       Allow.Break=True
       Break=False
       Continuous=False
       VarZ1!=0!
       VarZ2!=0!
       If TempA$<>Nul Then
          VarZ=Instr(TempA$,"#")
          If VarZ Then
             VarZ2!=Int(Val(Mid$(TempA$,VarZ+1)))
             TempA$=Left$(TempA$,VarZ-1)
          Endif
       Endif
       VarZ3!=0!
       VarZ4!=0!
       If TempB$<>Nul Then
          VarZ=Instr(TempB$,"#")
          If VarZ Then
             VarZ4!=Int(Val(Mid$(TempB$,VarZ+1)))
             TempB$=Left$(TempB$,VarZ-1)
          Endif
       Endif
       For Temp!=1! To Lof(MessBaseFile)/MessBaseRecLen
          Call Read.Record(MessBaseFile,Temp!)
          Temp2=False
          If TempA$<>Nul Then
             Out3=Rtrim$(MessageBaseRecord.BaseMessName)
             Call InstrSUB(VarX,Out3,TempA$)
             If VarX Then
                VarZ1!=VarZ1!+1!
                If VarZ2!=0! Or VarZ1!=VarZ2! Then
                   Temp2=True
                Endif
             Endif
          Endif
          If TempB$<>Nul Then
             Out3=Rtrim$(MessageBaseRecord.BaseFileName)
             Call InstrSUB(VarX,Out3,TempB$)
             If VarX Then
                VarZ3!=VarZ3!+1!
                If VarZ4!=0! Or VarZ3!=VarZ4! Then
                   Temp2=True
                Endif
             Endif
          Endif
          If TempA Then
             If (MessageBaseRecord.BaseType And TempA)=TempA Then
                Temp2=True
             Endif
          Endif
          If Temp2 Then
             Graphics.Off=True
             Out2=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
             If Len(Out2) Then
                Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
             Endif
             If Len(Out2)>40 Then
                Out2=Left$(Out2,40)+".."
             Endif
             Strng="Message base number"+Str$(Temp!+2!)+": "+Out2
             If MessageBaseRecord.BaseDeleted Then
                Strng=Strng+" "+Deleted$
             Endif
             Call IO.O
             If Break Then
                Exit For
             Endif
             If Lost.Carrier Then
                Exit For
             Endif
             Temp6=Temp6+1
             If Temp6>=User.Pagelength-2 Then
                Temp6=False
                If Continuous=False Then
                   Call More.Prompt
                   If No Or Quit Then
                      Exit For
                   Endif
                Endif
             Endif
          Endif
       Next
       Allow.Break=False
       Break=False
       If Temp6 Then
          Call More.Prompt
       Endif
       TempA=False
       TempA$=Nul
       TempB$=Nul
    Case "Q"
       Exit Do
    End Select
 Loop
ErrExit64:
 Exit Sub
ErrResume64:
 Resume ErrExit64
End Sub

Sub Edit.Messages
 On Local Error Goto ErrResume70
 Call List.Bases(True)
 Strng="Edit base number"
 Call Get.Base(Var!)
 If Var!=SFalse Then
    Exit Sub
 Endif
 Temp5!=Var!
 Var$="Editing "+Chr$(34)+TempA$+Chr$(34)+" message base."
 Call Open.Mail
 Do While Lost.Carrier=False
    Graphics.Off=False
    Strng=Var$
    Call IO.O
    Graphics.Off=True
    If TempC=False Then
       Strng=RT$(156,"[A]")+"dd"
       Call IO.O
       Strng=RT$(157,"[C]")+"hange"
       Call IO.O
       Strng=RT$(158,"[D]")+"elete"
       Call IO.O
       Strng=RT$(159,"[L]")+"ist"
       Call IO.O
       Strng=RT$(160,"[M]")+"ove"
       Call IO.O
       Strng=RT$(161,"[P]")+"ack"
       Call IO.O
       Strng=RT$(162,"[S]")+"earch"
       Call IO.O
       Strng=RT$(163,"[U]")+"ndelete"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(584,"[V]")+"Print"
          Call IO.O
       Endif
       Graphics.Off=False
    Endif
    Strng="Message edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(156,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Add.Message
       Endif
    Case "C"
       If RT$(157,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Change.Message
       Endif
    Case "D"
       If RT$(158,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Delete.Message
       Endif
    Case "L"
       If RT$(159,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call List.Messages
       Endif
    Case "M"
       If RT$(160,"[M]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Move.Message
       Endif
    Case "P"
       If RT$(161,"[P]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Pack.Messages
       Endif
    Case "S"
       If RT$(162,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Search.Messages
       Endif
    Case "U"
       If RT$(163,"[T]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Undelete.Message
       Endif
    Case "V"
       If Local.Mode Then
          If RT$(584,"[V]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Print.Messages
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
ErrExit70:
 Exit Sub
ErrResume70:
 Resume ErrExit70
End Sub

Sub Get.Base(Var2!)
 On Local Error Goto ErrResume70a
 Graphics.Off=True
 Var2!=SFalse
 Temp3!=Lof(MessBaseFile)/MessBaseRecLen+2!
 Call Get.Record.Range4(0!,Temp3!,Var!)
 Select Case Var!
 Case 1!
    Var2!=1!
    TempA$="Public"
    TempX$=Public.Filename
 Case 2!
    Var2!=2!
    TempA$="Private"
    TempX$=Private.Filename
 Case 3! To Var!
    If Var!<=Temp3! Then
       Call Read.Record(MessBaseFile,Var!-2!)
       If MessageBaseRecord.BaseDeleted Then
          Strng="Deleted message base."
          Call IO.O
          Exit Sub
       Endif
       Var2!=Var!
       TempA$=Lcase$(Rtrim$(MessageBaseRecord.BaseMessName))
       If Len(TempA$) Then
          Mid$(TempA$,1,1)=Ucase$(Mid$(TempA$,1,1))
       Endif
       TempX$=Rtrim$(MessageBaseRecord.BaseFileName)
    Else
       Strng="Message base not found."
       Call IO.O
       Var2!=0!
    Endif
 Case Else
    Strng="Message base not found."
    Call IO.O
    Var2!=0!
    Exit Sub
 End Select
ErrExit70a:
 Exit Sub
ErrResume70a:
 Resume ErrExit70a
End Sub

Sub Add.Message
 On Local Error Goto ErrResume71
 Redim Temp.ArrayS(1 To 19) As String
 Graphics.Off=True
 Strng="From(press "+Enter$+" for Sysop)? "
 No.Input.Out="Sysop"
 Call IO.I
 Var3$=Out2
 Strng="To(press "+Enter$+" for ALL)? "
 No.Input.Out="All"
 Call IO.I
 Message.To=Ucase$(Out2)
 Strng="Subject? "
 Call IO.I
 Subject=Lcase$(Out2)
 Strng="Enter message. Maximum 19 lines."
 Call IO.O
 Message.Length=False
 Do While Lost.Carrier=False
    If Message.Length=19 Then
       Strng="Message buffer full."
       Call IO.O
    Else
       Strng="Press "+Enter$+" on a blank line to edit."
       Call IO.O
       Do While Lost.Carrier=False
          Graphics.Off=True
          If Message.Length<19 Then
             Word.Wrap=True
          Else
             Word.Wrap=False
          Endif
          Strng="?"
          Call IO.I
          If No.Input Then
             Exit Do
          Endif
          Message.Length=Message.Length+1
          Temp.ArrayS(Message.Length)=Out2
          If Message.Length=19 Then
             Strng="Message buffer full."
             Call IO.O
             Exit Do
          Endif
       Loop
    Endif
    Call Edit.Message(VarX)
    Select Case VarX
    Case -1
       If Message.Length<19 Then
          Strng="Continue editing."
          Call IO.O
       Endif
    Case 0
       Exit Do
    Case 1
       Call Store.Message(Var3$)
       Exit Do
    End Select
 Loop
ErrExit71:
 Exit Sub
ErrResume71:
 Resume ErrExit71
End Sub

Sub Change.Message
 On Local Error Goto ErrResume72
 Do While Lost.Carrier=False
    Graphics.Off=False
    Temp3!=Lof(TableFile)/TableRecLen
    Strng="Message number to edit"
    Call Get.Record.Range2(1!,Temp3!,Temp!)
    If Temp!=0! Then
'       Strng="Cannot edit message."
'       Call IO.O
'       Exit Sub
       Temp!=1!
       TableRecord.ClassType=False
       TableRecord.Clock=Fclock2$
       TableRecord.Date=DateS$
       TableRecord.Flags=False
       TableRecord.From=Nul
       TableRecord.Killed=False
       TableRecord.Length=False
       TableRecord.Private=False
       TableRecord.Received=False
       TableRecord.Reply=False
       TableRecord.Start=SFalse
       TableRecord.Subject=Nul
       TableRecord.Time=Format$(Now,"hh:mm:ss")
       TableRecord.Timer=Timeit!
       TableRecord.TimesRead=DFalse
       TableRecord.To=Nul
       TableRecord.Thread=SFalse
       Call Write.Record(TableFile,Temp!)
    Endif
    Call Read.Record(TableFile,Temp!)
    Do While Lost.Carrier=False
       If TempC=False Then
          Graphics.Off=False
          Strng="Change message:"
          Graphics.Off=True
          Strng=RT$(649,"[H]")+"eader edit"
          Call IO.O
          Strng=RT$(650,"[T]")+"ext edit"
          Call IO.O
       Endif
       Graphics.Off=False
       Strng="Message edit option(q to quit)? "
       Line.Length=TempD
       No.Input.Out="Q"
       Call IO.I
       Select Case Ucase$(Out2)
       Case "H"
          If RT$(649,"[H]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Message.Header(Temp!)
             Graphics.Off=False
             Strng="Enter new message header:"
             Call IO.O
             Graphics.Off=True
             If TableRecord.From=String$(30,CHr$(0)) Then
                TableRecord.From=Nul
             Endif
             Var$=Lcase$(Rtrim$(TableRecord.From))
             If Len(Var$) Then
                Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
             Endif
             If Var$=Nul Then
                Strng="From? "
             Else
                Strng="From(press "+Enter$+" for "+Var$+")? "
             Endif
             No.Input.Out=Var$
             Call IO.I
             TableRecord.From=Ucase$(Out2)
             If TableRecord.To=String$(30,CHr$(0)) Then
                TableRecord.To=Nul
             Endif
             Var$=Rtrim$(TableRecord.To)
             If Len(Var$) Then
                Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
             Endif
             If Var$=Nul Then
                Strng="To(press "+Enter$+" for ALL)? "
             Else
                Strng="To(press "+Enter$+" for "+Var$+")? "
             Endif
             No.Input.Out=Var$
             Call IO.I
             TableRecord.To=Ucase$(Out2)
             Strng="Subject(<enter>=default)? "
             Call IO.I
             If Out2<>Nul Then
                TableRecord.Subject=Lcase$(Out2)
             Endif
             If TempC=False Then
                Graphics.Off=False
                Strng="Classtype status(<enter>=default): "
                Call IO.O
                Graphics.Off=True
                Strng="#0: <none>"
                Call IO.O
                For Temp5=1 To 10
                   Strng="#"+Mid$(Str$(Temp5),2)+": "+Rtrim$(Class.Name(Temp5))
                   Call IO.O
                Next
             Endif
             Graphics.Off=False
             No.Input.Out=Nul
             Strng="Enter classtype number(0-10,<enter>=default)? "
             Call IO.I
             If Out2<>Nul Then
                Temp5=Int(Val(Out2))
                If Temp5>=False And Temp5<=10 Then
                   TableRecord.ClassType=Temp5
                Endif
             Endif
             Do While Lost.Carrier=False
                If TempC=False Then
                   Graphics.Off=False
                   Strng="Character status:"
                   Graphics.Off=True
                   Strng=RT$(164,"[A]")+"Town Mayor"
                   Call IO.O
                   Strng=RT$(165,"[B]")+"Governor"
                   Call IO.O
                   Strng=RT$(166,"[C]")+"Guild Master"
                   Call IO.O
                   Strng=RT$(167,"[D]")+"Sysop"
                   Call IO.O
                   Strng=RT$(168,"[E]")+"None"
                   Call IO.O
                Endif
                Graphics.Off=False
                Strng="Character type option(q to quit)? "
                Line.Length=TempD
                No.Input.Out="Q"
                Call IO.I
                Select Case Ucase$(Out2)
                Case "A"
                   If RT$(164,"[A]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TableRecord.Flags=TableRecord.Flags Or Special.Char1
                   Endif
                Case "B"
                   If RT$(165,"[B]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TableRecord.Flags=TableRecord.Flags Or Special.Char2
                   Endif
                Case "C"
                   If RT$(166,"[C]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TableRecord.Flags=TableRecord.Flags Or Special.Char3
                   Endif
                Case "D"
                   If RT$(167,"[D]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TableRecord.Flags=TableRecord.Flags Or Special.Char4
                   Endif
                Case "E"
                   If RT$(168,"[E]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TableRecord.Flags=TableRecord.Flags And Not Special.Char1
                      TableRecord.Flags=TableRecord.Flags And Not Special.Char2
                      TableRecord.Flags=TableRecord.Flags And Not Special.Char3
                      TableRecord.Flags=TableRecord.Flags And Not Special.Char4
                   Endif
                Case "Q"
                   Exit Do
                End Select
             Loop
             Call Write.Record(TableFile,Temp!)
          Endif
       Case "T"
          If RT$(650,"[T]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Read.Message(Temp!)
             Call More.Prompt
             Redim Temp.ArrayS(1 To 19) As String
             Message.Length=TableRecord.Length
             For TempY=1 To Message.Length
                TempQ!=TableRecord.Start+Csng(TempY)-1!
                If TempQ!>SFalse And TempQ!<=Lof(MessageFile)/MessageRecLen Then
                   Call Read.Record(MessageFile,TempQ!)
                   Strng=BufferRecord.Buffer
                   Call Crypto(Strng)
                   Strng=Rtrim$(Strng)
                   Temp.ArrayS(TempY)=Strng
                Endif
             Next
             Do While Lost.Carrier=False
                Call Edit.Message(VarX)
                Select Case VarX
                Case -1
                   If Message.Length=19 Then
                      Strng="Message buffer full."
                      Call IO.O
                   Else
                      Strng="Continue editing. Press "+Enter$+" on a blank line to edit."
                      Call IO.O
                      Do While Lost.Carrier=False
                         Graphics.Off=True
                         If Message.Length<19 Then
                            Word.Wrap=True
                         Else
                            Word.Wrap=False
                         Endif
                         Strng="?"
                         Carriage.Return=-1
                         Call IO.O
                         Call IO.I
                         If No.Input Then
                            Exit Do
                         Endif
                         Message.Length=Message.Length+1
                         Temp.ArrayS(Message.Length)=Out2
                         If Message.Length=19 Then
                            Strng="Message buffer full."
                            Call IO.O
                            Exit Do
                         Endif
                      Loop
                   Endif
                Case 0
                   Exit Do
                Case 1
                   Call Store.Message2
                   Exit Do
                End Select
             Loop
          Endif
       Case "Q"
          Exit Do
       End Select
    Loop
    Graphics.Off=False
    Strng="Edit another message(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If No Then
       Exit Do
    Endif
 Loop
ErrExit72:
 Exit Sub
ErrResume72:
 Resume ErrExit72
End Sub

Sub Delete.Message
 On Local Error Goto ErrResume73
 Do While Lost.Carrier=False
    Temp3!=Lof(TableFile)/TableRecLen
    Strng="Message number to delete"
    Call Get.Record.Range2(1!,Temp3!,Temp!)
    Graphics.Off=True
    Call Read.Record(TableFile,Temp!)
    If TableRecord.Killed Then
       Strng="Message"+Str$(Temp!)+" is already deleted."
    Else
       TableRecord.Killed=True
       Call Write.Record(TableFile,Temp!)
       Strng="Message"+Str$(Temp!)+" deleted."
    Endif
    Call IO.O
    Graphics.Off=False
    Strng="Delete more messages(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If No Then
       Exit Do
    Endif
 Loop
ErrExit73:
 Exit Sub
ErrResume73:
 Resume ErrExit73
End Sub

Sub List.Messages
 On Local Error Goto ErrResume74
 Temp2!=Lof(TableFile)/TableRecLen
 Call Get.Record.Range(Temp!,Temp1!,Temp2!)
 Allow.Break=True
 Break=False
 Graphics.Off=True
 For Temp3!=Temp! To Temp1!
    Call Read.Record(TableFile,Temp3!)
    Call Read.Message(Temp3!)
    If Break Then
       Exit For
    Endif
    If Continuous=False Then
       Call More.Prompt
       If No Or Quit Then
          Exit For
       Endif
    Endif
 Next
 Allow.Break=False
ErrExit74:
 Exit Sub
ErrResume74:
 Resume ErrExit74
End Sub

Sub Move.Message
 On Local Error Goto ErrResume74a
 VarY$=TempA$
 VarX$=TempX$
 Temp3!=Lof(TableFile)/TableRecLen
 Strng="Message number to move"
 Call Get.Record.Range2(1!,Temp3!,Var3!)
 Graphics.Off=True
 Call Read.Record(TableFile,Var3!)
 If TableRecord.Killed Then
    Strng="Message"+Str$(Var3!)+" is deleted."
    Call IO.O
    Do While Lost.Carrier=False
       Line.Length=TempD
       No.Input.Out="N"
       Strng="Move anyway(y/n)? "
       Call IO.I
       If Ucase$(Out2)="Y" Then
          Exit Do
       Endif
       If Ucase$(Out2)="N" Then
          Exit Sub
       Endif
    Loop
 Endif
 Call List.Bases(True)
 Strng="Enter message base to move message to:"
 Call Get.Base(Var!)
 If Var!=SFalse Then
    Exit Sub
 Endif
 VarX=False
 If Var!=Temp5! Then
    Do While Lost.Carrier=False
       If TempC=False Then
          Graphics.Off=False
          Strng="Message move type:"
          Graphics.Off=True
          Strng="[C]opy message"
          Call IO.O
          Strng="[M]ove message"
          Call IO.O
       Endif
       Graphics.Off=False
       Strng="Move message type(Q=quit)? "
       Line.Length=TempD
       No.Input.Out="Q"
       Call IO.I
       Select Case Ucase$(Out2)
       Case "C"
          VarX=True
          Exit Do
       Case "M"
          Exit Do
       Case "Q"
          Exit Sub
       End Select
    Loop
    If Lost.Carrier Then
       Exit Sub
    Endif
 Endif
 Redim Temp.ArrayS(1 To 19) As String
 Message.Length=False
 TempS!=TableRecord.Start
 TempT!=TempS!+Csng(TableRecord.Length)-1!
 For Var2!=TempS! To TempT!
    If Var2!>SFalse And Var2!<=Lof(MessageFile)/MessageRecLen Then
       Call Read.Record(MessageFile,Var2!)
       Strng=BufferRecord.Buffer
       Call Crypto(Strng)
       Strng=Rtrim$(Strng)
       Message.Length=Message.Length+1
       Temp.ArrayS(Message.Length)=Strng
    Endif
 Next
 VarZ=TableRecord.Killed
 If VarZ=False Then
    VarZ=True
    If Var!=Temp5! Then
       If VarX Then
          VarZ=False
       Endif
    Endif
 Endif
 TableRecord.Killed=VarZ
 Call Write.Record(TableFile,Var3!)
 Call Open.Mail
 Call Store.Message3(Var!,VarX)
 Strng2="moved"
 If VarX Then
    Strng2="copied"
 Endif
 Strng="Message "+Strng2+" to message base "+Chr$(34)+TempA$+Chr$(34)+"."
 Call IO.O
 TempA$=VarY$
 TempX$=VarX$
 Call Open.Mail
ErrExit74a:
 Exit Sub
ErrResume74a:
 Resume ErrExit74a
End Sub

Sub Print.Messages
 On Local Error Goto ErrResume74b
 Strng="Printer port(1-3)? "
 Call IO.I
 VarP=Int(Val(Out2))
 If VarP>=1 And VarP<=3 Then
    Close #TempFile1
    VarP$="LPT"+Mid$(Str$(VarP),2)+":"
    Open VarP$ For Output As #TempFile1
    Temp2!=Lof(TableFile)/TableRecLen
    Call Get.Record.Range(Temp!,Temp1!,Temp2!)
    For Temp3!=Temp! To Temp1!
       Call Read.Record(TableFile,Temp3!)
       Call Print.Message(Temp3!)
       Print #TempFile1,Chr$(12);
    Next
 Endif
ErrExit74b:
 Close #TempFile1
 Exit Sub
ErrResume74b:
 Resume ErrExit74b
End Sub

Sub Undelete.Message
 On Local Error Goto ErrResume75
 Do While Lost.Carrier=False
    Temp3!=Lof(TableFile)/TableRecLen
    Strng="Message number to undelete"
    Call Get.Record.Range2(1!,Temp3!,Temp!)
    Call Read.Record(TableFile,Temp!)
    If TableRecord.Killed=False Then
       Strng="Message"+Str$(Temp!)+" is not deleted."
    Else
       TableRecord.Killed=False
       Call Write.Record(TableFile,Temp!)
       Strng="Message"+Str$(Temp!)+" undeleted."
    Endif
    Call IO.O
    Graphics.Off=False
    Strng="Undelete more messages(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If No Then
       Exit Do
    Endif
 Loop
ErrExit75:
 Exit Sub
ErrResume75:
 Resume ErrExit75
End Sub

Sub Store.Message(Var3$)
 On Local Error Goto ErrResume82
 If Message.Length=False Then
    Strng="No message text to store.."
    Call IO.O
    Exit Sub
 Endif
 Strng="Storing message.."
 Call IO.O
Start.Store1:
 If Share.Installed Then
    Lock #MessageFile
 Endif
 TempX!=Lof(MessageFile)/MessageRecLen+1!
 TableRecord.ClassType=False
 TableRecord.Clock=Fclock2$
 TableRecord.Date=DateS$
 TableRecord.Flags=False
 TableRecord.From=Var3$
 TableRecord.Killed=False
 TableRecord.Length=Message.Length
 TableRecord.Private=Private.Message
 TableRecord.Received=False
 TableRecord.Reply=False
 TableRecord.Start=TempX!
 TableRecord.Subject=Subject
 TableRecord.Time=Format$(Now,"hh:mm:ss")
 TableRecord.Timer=Timeit!
 TableRecord.TimesRead=DFalse
 TableRecord.To=Message.To
 TableRecord.Thread=SFalse
 Temp!=Lof(TableFile)/TableRecLen+1!
 Call Write.Record(TableFile,Temp!)
 For Temp=1 To Message.Length
    Strng=Temp.ArrayS(Temp)
    Strng=Left$(Strng,80)
    Call Valid(Strng,80)
    Call Crypto(Strng)
    BufferRecord.Buffer=Strng
    Put MessageFile,TempX!,BufferRecord
    TempX!=TempX!+1!
 Next
 If Share.Installed Then
    Unlock #MessageFile
 Endif
 Strng="Lines stored:"+Str$(Message.Length)+"."
 Call IO.O
ErrExit82:
 Exit Sub
ErrResume82:
 Data.Error=Err
 If Share.Installed Then
    If Data.Error=70 Then
       Resume Start.Store1
    Endif
 Endif
 Resume ErrExit82
End Sub

Sub Store.Message2
 On Local Error Goto ErrResume82a
 If Message.Length=False Then
    Strng="No message text to store.."
    Call IO.O
    Exit Sub
 Endif
 Strng="Storing message.."
 Call IO.O
Start.Store2:
 Lock #MessageFile
 TableRecord.Length=Message.Length
 TempX!=Lof(MessageFile)/MessageRecLen+1!
 TableRecord.Start=TempX!
 Call Write.Record(TableFile,Temp!)
 For Temp=1 To Message.Length
    Strng=Temp.ArrayS(Temp)
    Strng=Left$(Strng,80)
    Call Valid(Strng,80)
    Call Crypto(Strng)
    BufferRecord.Buffer=Strng
    Put MessageFile,TempX!,BufferRecord
    TempX!=TempX!+1!
 Next
 Unlock #MessageFile
 Strng="Lines stored:"+Str$(Message.Length)+"."
 Call IO.O
ErrExit82a:
 Exit Sub
ErrResume82a:
 Data.Error=Err
 If Data.Error=70 Then
    Resume Start.Store2
 Endif
 Resume ErrExit82a
End Sub

Sub Store.Message3(Var!,VarX)
 On Local Error Goto ErrResume82b
Start.Store3:
 Lock #MessageFile
 TempX!=Lof(MessageFile)/MessageRecLen+1!
 TableRecord.Killed=False
 TableRecord.Reply=False
 TableRecord.Start=TempX!
 If Var!=Temp5! Then
    If VarX=False Then
       TableRecord.Thread=SFalse
    Endif
 Else
    TableRecord.Thread=SFalse
 Endif
 Temp!=Lof(TableFile)/TableRecLen+1!
 Call Write.Record(TableFile,Temp!)
 For Temp=1 To Message.Length
    Strng=Temp.ArrayS(Temp)
    Strng=Left$(Strng,80)
    Call Valid(Strng,80)
    Call Crypto(Strng)
    BufferRecord.Buffer=Strng
    Put MessageFile,TempX!,BufferRecord
    TempX!=TempX!+1!
 Next
 Unlock #MessageFile
 Strng="Lines stored:"+Str$(Message.Length)+"."
 Call IO.O
ErrExit82b:
 Exit Sub
ErrResume82b:
 Data.Error=Err
 If Data.Error=70 Then
    Resume Start.Store2
 Endif
 Resume ErrExit82b
End Sub

Sub Open.Mail
 On Local Error Goto ErrResume83
 Close #TableFile, #MessageFile, #NewFile
 FileName=Data.Path4+TempX$+".TBL"
 Open FileName For Random Shared As #TableFile Len=TableRecLen
 FileName=Data.Path4+TempX$+".DAT"
 Open FileName For Random Shared As #MessageFile Len=MessageRecLen
 FileName=Data.Path4+TempX$+".NEW"
 Open FileName For Random Shared As #NewFile Len=NewMessRecLen
ErrExit83:
 Exit Sub
ErrResume83:
 Resume ErrExit83
End Sub

Sub Read.Message(Var!)
 On Local Error Goto ErrResume84
 If Var!>SFalse And Var!<=Lof(TableFile)/TableRecLen Then
    Call Read.Record(TableFile,Var!)
    Graphics.Off=True
    Allow.Break=True
    Break=False
    Call Message.Header(Var!)
    TempS!=TableRecord.Start
    TempT!=TempS!+Csng(TableRecord.Length)-1!
    For Var2!=TempS! To TempT!
       If Var2!>SFalse And Var2!<=Lof(MessageFile)/MessageRecLen Then
          Call Read.Record(MessageFile,Var2!)
          Strng=BufferRecord.Buffer
          Call Crypto(Strng)
          Strng=Rtrim$(Strng)
          Call IO.O
          If Break Then
             Exit For
          Endif
       Endif
    Next
    Allow.Break=False
    Break=False
 Endif
ErrExit84:
 Exit Sub
ErrResume84:
 Resume ErrExit84
End Sub

Sub Print.Message(Var!)
 On Local Error Goto ErrResume84a
 If Var!>SFalse And Var!<=Lof(TableFile)/TableRecLen Then
    Call Read.Record(TableFile,Var!)
    Call Print.Message.Header(Var!)
    TempS!=TableRecord.Start
    TempT!=TempS!+Csng(TableRecord.Length)-1!
    For Var2!=TempS! To TempT!
       If Var2!>SFalse And Var2!<=Lof(MessageFile)/MessageRecLen Then
          Call Read.Record(MessageFile,Var2!)
          Strng=BufferRecord.Buffer
          Call Crypto(Strng)
          Strng=Rtrim$(Strng)
          Print #TempFile1,Strng
       Endif
    Next
 Endif
ErrExit84a:
 Exit Sub
ErrResume84a:
 Resume ErrExit84a
End Sub

Sub Message.Header(Var2!)
 On Local Error Goto ErrResume85
 Call Sub.Header(Var2!)
 Strng="Rcvd:  "
 If TableRecord.Received Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Strng=Strng+Space$(35-Len(Strng))
 Var#=TableRecord.TimesRead
 Select Case Var#
 Case 1#
    Strng=Strng+"Read: once"
 Case Else
    Strng=Strng+"Read: "+Form$(Var#)+" times"
 End Select
 Call IO.O
 If Break Then
    Exit Sub
 Endif
 Strng="Reply: "
 If TableRecord.Reply Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Thread:"
 If TableRecord.Reply Then
    If TableRecord.Thread=SFalse Then
       Strng=Strng+" (forward)"
    Else
       Strng=Strng+Str$(TableRecord.Thread)
    Endif
 Else
    Strng=Strng+" None"
 Endif
 Call IO.O
 If Break Then
    Exit Sub
 Endif
 Strng="Stat:  "
 Var3=TableRecord.ClassType
 Select Case Var3
 Case 1 To 10
    Strng=Strng+Rtrim$(Class.Name(Var3))
 End Select
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Type: "
 Strng2=Nul
 If TableRecord.Flags And Special.Char1 Then
    Strng2=Strng2+"Town Mayor "
 Endif
 If TableRecord.Flags And Special.Char2 Then
    Strng2=Strng2+"Governor "
 Endif
 If TableRecord.Flags And Special.Char3 Then
    Strng2=Strng2+"Guild Master "
 Endif
 If TableRecord.Flags And Special.Char4 Then
    Strng2=Strng2+"Sysop "
 Endif
 If Strng2=Nul Then
    Strng2="None"
 Endif
 Strng=Strng+Strng2
 Strng=Left$(Strng,79)
 Strng=Rtrim$(Strng)
 Call IO.O
 If Break Then
    Exit Sub
 Endif
ErrExit85:
 Exit Sub
ErrResume85:
 Resume ErrExit85
End Sub

Sub Print.Message.Header(Var2!)
 On Local Error Goto ErrResume85a
 Call Print.Sub.Header(Var2!)
 Strng="Rcvd:  "
 If TableRecord.Received Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Strng=Strng+Space$(35-Len(Strng))
 Var#=TableRecord.TimesRead
 Select Case Var#
 Case 1#
    Strng=Strng+"Read: once"
 Case Else
    Strng=Strng+"Read: "+Form$(Var#)+" times"
 End Select
 Print #TempFile1,Strng
 Strng="Reply: "
 If TableRecord.Reply Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Thread:"
 If TableRecord.Reply Then
    If TableRecord.Thread=SFalse Then
       Strng=Strng+" (forward)"
    Else
       Strng=Strng+Str$(TableRecord.Thread)
    Endif
 Else
    Strng=Strng+" None"
 Endif
 Print #TempFile1,Strng
 Strng="Stat:  "
 Var3=TableRecord.ClassType
 Select Case Var3
 Case 1 To 10
    Strng=Strng+Rtrim$(Class.Name(Var3))
 End Select
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Type: "
 Strng2=Nul
 If TableRecord.Flags And Special.Char1 Then
    Strng2=Strng2+"Town Mayor "
 Endif
 If TableRecord.Flags And Special.Char2 Then
    Strng2=Strng2+"Governor "
 Endif
 If TableRecord.Flags And Special.Char3 Then
    Strng2=Strng2+"Guild Master "
 Endif
 If TableRecord.Flags And Special.Char4 Then
    Strng2=Strng2+"Sysop "
 Endif
 If Strng2=Nul Then
    Strng2="None"
 Endif
 Strng=Strng+Strng2
 Strng=Left$(Strng,79)
 Strng=Rtrim$(Strng)
 Print #TempFile1,Strng
ErrExit85a:
 Exit Sub
ErrResume85a:
 Resume ErrExit85a
End Sub

Sub Sub.Header(Var1!)
 On Local Error Goto ErrResume86
 Graphics.Off=False
 Strng="Msg#:"+Str$(Var1!)+" of"+Str$(Lof(TableFile)/TableRecLen)
 If TableRecord.Private Then
    Strng=Strng+" (private)"
 Endif
 If TableRecord.Killed Then
    Strng=Strng+" (deleted)"
 Endif
 Call IO.O
 If Break Then
    Exit Sub
 Endif
 Graphics.Off=True
 Strng2=TableRecord.From
 Strng2=Lcase$(Rtrim$(Strng2))
 If Len(Strng2) Then
    Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Endif
 Strng="From:  "+Strng2
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng2=Rtrim$(TableRecord.Subject)
 If Len(Strng2) Then
    Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Endif
 Strng=Strng+"Subj: "+Strng2
 Call IO.O
 If Break Then
    Exit Sub
 Endif
 Strng2=TableRecord.To
 Strng2=Rtrim$(Strng2)
 If Strng2=Nul Then
    Strng2="ALL"
 Endif
 Strng2=Lcase$(Strng2)
 Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Strng="To:    "+Strng2
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Time: "+TableRecord.Clock
 Call IO.O
 If Break Then
    Exit Sub
 Endif
ErrExit86:
 Exit Sub
ErrResume86:
 Resume ErrExit86
End Sub

Sub Print.Sub.Header(Var1!)
 On Local Error Goto ErrResume86a
 Graphics.Off=False
 Strng="Msg#:"+Str$(Var1!)+" of"+Str$(Lof(TableFile)/TableRecLen)
 If TableRecord.Private Then
    Strng=Strng+" (private)"
 Endif
 If TableRecord.Killed Then
    Strng=Strng+" (deleted)"
 Endif
 Print #TempFile1,Strng
 Graphics.Off=True
 Strng2=TableRecord.From
 Strng2=Lcase$(Strng2)
 Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Strng="From:  "+Strng2
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng2=Rtrim$(TableRecord.Subject)
 Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Strng=Strng+"Subj: "+Strng2
 Print #TempFile1,Strng
 Strng2=TableRecord.To
 Strng2=Rtrim$(Strng2)
 If Strng2=Nul Then
    Strng2="ALL"
 Endif
 Strng2=Lcase$(Strng2)
 Mid$(Strng2,1,1)=Ucase$(Mid$(Strng2,1,1))
 Strng="To:    "+Strng2
 Strng=Left$(Strng,35)
 Strng=Strng+Space$(35-Len(Strng))
 Strng=Strng+"Time: "+TableRecord.Clock
 Print #TempFile1,Strng
ErrExit86a:
 Exit Sub
ErrResume86a:
 Resume ErrExit86a
End Sub

Sub Pack.Messages
 On Local Error Goto ErrResume139
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't pack while node/user online."
    Call IO.O
    Exit Sub
 Endif
 Strng="Pack messages(y/n)? "
 No.Input.Out="N"
 Line.Length=TempD
 Call IO.I
 If Yes Then
    Graphics.Off=True
    Carriage.Return=True
    Strng="Updating new message pointers"
    Call IO.O
    Var!=Lof(NewFile)/NewMessRecLen
    If Var!=SFalse Then
       Var!=1!
    Endif
    Redim Temp.Array3(1 To Var!) As Single
    For Var1!=1! To Var!
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(NewFile,Var1!)
       Temp.Array3(Var1!)=NewMessages.LastMessage
    Next
    For VarX!=1! To Lof(TableFile)/TableRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TableFile,VarX!)
       If TableRecord.Killed Then
          For Var1!=1! To Var!
             TempZ!=Temp.Array3(Var1!)
             If TempZ!<=VarX! Then
                TempZ!=TempZ!-1!
                Temp.Array3(Var1!)=TempZ!
             Endif
          Next
       Endif
    Next
    For Var1!=1! To Var!
       Call Dot.Display(VarD,VarE,VarF!)
       NewMessages.LastMessage=Temp.Array3(Var1!)
       Call Write.Record(NewFile,Var1!)
    Next
    Call IO.O
    Var3!=Lof(TableFile)/TableRecLen
    If Var3!=SFalse Then
       Var3!=1!
    Endif
    Redim Temp.Array3(1 To Var3!) As Single
    Graphics.Off=True
    Carriage.Return=True
    Strng="Updating message thread pointers"
    Call IO.O
    VarD=False
    VarE=False
    VarF!=Timeit!
    For VarX!=1! To Var3!
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TableFile,VarX!)
       Temp.Array3(VarX!)=TableRecord.Thread
    Next
    For VarX!=1! To Var3!
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TableFile,VarX!)
       If TableRecord.Killed Then
          VarZ!=Temp.Array3(VarX!)
          For TempY!=VarX!+1! To Var3!
             If Temp.Array3(TempY!)=VarX! Then
                Temp.Array3(TempY!)=VarZ!
                If VarZ!=SFalse Then
                   For TempZ!=TempY!+1! To Var3!
                      If Temp.Array3(TempZ!)=TempY! Then
                         Exit For
                      Endif
                   Next
                   If TempZ!>Var3! Then
                      Call Read.Record(TableFile,TempY!)
                      TableRecord.Reply=False
                      Call Write.Record(TableFile,TempY!)
                   Endif
                Endif
             Endif
          Next
          For TempY!=VarX!+1! To Var3!
             VarZ!=Temp.Array3(TempY!)
             If VarZ!>=VarX! Then
                VarZ!=VarZ!-1!
                Temp.Array3(TempY!)=VarZ!
             Endif
          Next
       Endif
    Next
    For VarX!=1! To Var3!
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TableFile,VarX!)
       TableRecord.Thread=Temp.Array3(VarX!)
       Call Write.Record(TableFile,VarX!)
    Next
    Call IO.O
    Close #TempFile1
    FileName=Data.Path4+TempX$+".bk1"
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TempFile1 Len=TableRecLen
    For VarX!=1! To Lof(TableFile)/TableRecLen
       Call Read.Record(TableFile,VarX!)
       Call Write.TempFile(1,VarX!)
    Next
    Close #TempFile2
    FileName=Data.Path4+TempX$+".bk2"
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TempFile2 Len=MessageRecLen
    For VarX!=1! To Lof(MessageFile)/MessageRecLen
       Call Read.Record(MessageFile,VarX!)
       Call Write.TempFile(2,VarX!)
    Next
    Close #TableFile, #MessageFile, #TempFile1, #TempFile2
    FileName=Data.Path4+TempX$+".tbl"
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    FileName=Data.Path4+TempX$+".dat"
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    FileName=Data.Path4+TempX$+".tbl"
    Open FileName For Random Shared As #TableFile Len=TableRecLen
    FileName=Data.Path4+TempX$+".dat"
    Open FileName For Random Shared As #MessageFile Len=MessageRecLen
    FileName=Data.Path4+TempX$+".bk1"
    Open FileName For Random Shared As #TempFile1 Len=TableRecLen
    FileName=Data.Path4+TempX$+".bk2"
    Open FileName For Random Shared As #TempFile2 Len=MessageRecLen
    Strng="Copying messages"
    Graphics.Off=True
    Carriage.Return=True
    Call IO.O
    VarQ!=SFalse
    TempB!=SFalse
    VarD=False
    VarE=False
    VarF!=Timeit!
    For VarX!=1! To Lof(TempFile1)/TableRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.TempFile(1,VarX!)
       If TableRecord.Killed=False Then
          Temp8!=TableRecord.Start
          Temp9!=Temp8!+Csng(TableRecord.Length)-1!
          VarQ!=VarQ!+1!
          TableRecord.Start=TempB!+1!
          Call Write.Record(TableFile,VarQ!)
          For TempA!=Temp8! To Temp9!
             Call Read.TempFile(2,TempA!)
             TempB!=TempB!+1!
             Call Write.Record(MessageFile,TempB!)
          Next
       Endif
    Next
    Close #TempFile1, #TempFile2
    Call IO.O
    Graphics.Off=False
 Endif
 Call More.Prompt
 Call Open.Mail
 Erase Temp.Array3
ErrExit139:
 Exit Sub
ErrResume139:
 Resume ErrExit139
End Sub

Sub Search.Messages
 On Local Error Goto ErrResume63
 Do While Lost.Carrier=False
    TempA$=Nul
    TempB$=Nul
    TempC$=Nul
    TempE$=Nul
    TempF$=Nul
    TempG$=Nul
    TempH$=Nul
    TempI$=Nul
    Do While Lost.Carrier=False
       Graphics.Off=True
       If TempC=False Then
          Strng="[A]From user"
          If TempA$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempA$+")"
          Endif
          Call IO.O
          Strng="[B]Subject header"
          If TempB$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempB$+")"
          Endif
          Call IO.O
          Strng="[C]Date range of message"
          If TempC$<>Nul And TempF$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempC$+" - "+TempF$+")"
          Endif
          Call IO.O
          Strng="[D]Time range of message"
          If TempG$<>Nul And TempH$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempG$+" - "+TempH$+")"
          Endif
          Call IO.O
          Strng="[E]To user"
          If TempE$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempE$+")"
          Endif
          Call IO.O
          Strng="[F]Message text"
          If TempI$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+TempI$+")"
          Endif
          Call IO.O
          Graphics.Off=False
       Endif
       Strng="Message search option(S to search, Q to quit)? "
       Line.Length=TempD
       No.Input.Out="Q"
       Graphics.Off=False
       Call IO.I
       Select Case Ucase$(Out2)
       Case "A"
          Strng="Username? "
          Call IO.I
          TempA$=Ucase$(Out2)
       Case "B"
          Strng="Subject substring? "
          Call IO.I
          TempB$=Ucase$(Out2)
       Case "C"
          Strng="Search date from? "
          Call IO.I
          TempC$=Ucase$(Out2)
          Strng="Search date to? "
          Call IO.I
          TempF$=Ucase$(Out2)
       Case "D"
          Strng="Search time from? "
          Call IO.I
          TempG$=Ucase$(Out2)
          Strng="Search time to? "
          Call IO.I
          TempH$=Ucase$(Out2)
       Case "E"
          Strng="Username(<enter>=ALL)? "
          Call IO.I
          If Out2=Nul Then
             TempE$="ALL"
          Else
             TempE$=Ucase$(Out2)
          Endif
       Case "F"
          Strng="Message text(?,* allowed): "
          Call IO.I
          TempI$=Out2
          TmpS=0
          Do While Lost.Carrier=False
             Line.Length=1
             No.Input.Out="N"
             Strng="Case sensitive(y/n)? "
             Call IO.I
             If Ucase$(Out2)="Y" Then
                TmpS=-1
                Exit Do
             Endif
             If Ucase$(Out2)="N" Then
                TmpS=0
                Exit Do
             Endif
          Loop
       Case "S"
          Strng="Searching messages."
          Call IO.O
          Allow.Break=True
          Break=False
          Continuous=False
          VarZ1!=0!
          VarZ2!=0!
          If TempA$<>Nul Then
             VarZ=Instr(TempA$,"#")
             If VarZ Then
                VarZ2!=Int(Val(Mid$(TempA$,VarZ+1)))
                TempA$=Left$(TempA$,VarZ-1)
             Endif
          Endif
          VarZ3!=0!
          VarZ4!=0!
          If TempB$<>Nul Then
             VarZ=Instr(TempB$,"#")
             If VarZ Then
                VarZ4!=Int(Val(Mid$(TempB$,VarZ+1)))
                TempB$=Left$(TempB$,VarZ-1)
             Endif
          Endif
          VarZ5!=0!
          VarZ6!=0!
          If TempE$<>Nul Then
             VarZ=Instr(TempE$,"#")
             If VarZ Then
                VarZ6!=Int(Val(Mid$(TempE$,VarZ+1)))
                TempE$=Left$(TempE$,VarZ-1)
             Endif
          Endif
          VarZ7!=0!
          VarZ8!=0!
          If TempI$<>Nul Then
             VarZ=Instr(TempI$,"#")
             If VarZ Then
                VarZ8!=Int(Val(Mid$(TempI$,VarZ+1)))
                TempI$=Left$(TempI$,VarZ-1)
             Endif
          Endif
          For Temp!=1! To Lof(TableFile)/TableRecLen
             Call Read.Record(TableFile,Temp!)
             Redim Temp.ArrayS(1 To 19) As String
             Message.Length=TableRecord.Length
             For TempY=1 To Message.Length
                TempQ!=TableRecord.Start+Csng(TempY)-1!
                If TempQ!>SFalse And TempQ!<=Lof(MessageFile)/MessageRecLen Then
                   Call Read.Record(MessageFile,TempQ!)
                   Strng=BufferRecord.Buffer
                   Call Crypto(Strng)
                   Strng=Rtrim$(Strng)
                   Temp.ArrayS(TempY)=Strng
                Endif
             Next
             Temp2=False
             Temp3=False
             If TempA$<>Nul Then
                Out3=Rtrim$(TableRecord.From)
                Call InstrSUB(VarX,Out3,TempA$)
                If VarX Then
                   VarZ1!=VarZ1!+1!
                   If VarZ2!=0! Or VarZ1!=VarZ2! Then
                      Temp2=True
                   Endif
                Endif
             Endif
             If TempB$<>Nul Then
                Out3=Rtrim$(TableRecord.Subject)
                Call InstrSUB(VarX,Out3,TempB$)
                If VarX Then
                   VarZ3!=VarZ3!+1!
                   If VarZ4!=0! Or VarZ3!=VarZ4! Then
                      Temp2=True
                   Endif
                Endif
             Endif
             If TempC$<>Nul And TempF$<>Nul Then
                If DateValue(TableRecord.Date)>=DateValue(TempC$) Then
                   If DateValue(TableRecord.Date)<=DateValue(TempF$) Then
                      Temp2=True
                   Endif
                Endif
             Endif
             If TempG$<>Nul And TempH$<>Nul Then
                If TimeValue(TableRecord.Time)>=TimeValue(TempG$) Then
                   If TimeValue(TableRecord.Time)<=TimeValue(TempH$) Then
                      Temp2=True
                   Endif
                Endif
             Endif
             If TempE$<>Nul Then
                If Rtrim$(TableRecord.To)=Nul Then
                   If TempE$="ALL" Then
                      Temp2=True
                   Endif
                Else
                   Out3=Rtrim$(TableRecord.To)
                   Call InstrSUB(VarX,Out3,TempE$)
                   If VarX Then
                      VarZ5!=VarZ5!+1!
                      If VarZ6!=0! Or VarZ5!=VarZ6! Then
                         Temp2=True
                      Endif
                   Endif
                Endif
             Endif
             Temp3=False
             If TempI$<>Nul Then
                VarZ7!=0!
                For VarX=1 To Message.Length
                   Out3=Rtrim$(Temp.ArrayS(VarX))
                   Call InstrSUB(VarX2,Out3,TempI$)
                   If VarX2 Then
                      VarZ7!=VarZ7!+1!
                      If VarZ8!=0! Or VarZ7!=VarZ8! Then
                         Temp2=True
                         Temp3=VarX
                         Exit For
                      Endif
                   Endif
                Next
             Endif
             If Temp2 Then
                Call Sub.Header(Temp!)
                If Temp3 Then
                   If TempI$<>Nul Then
                      VarZ7!=0!
                      For VarX=1 To Message.Length
                         Out3=Rtrim$(Temp.ArrayS(VarX))
                         ' see if TempI$ matches in Out3 case-sensitive
                         V1$=Out3
                         V2$=TempI$
                         If Len(V1$)>0 And Len(V2$)>0 Then
                            Var3$=TempI$
                            Strng=Out3
                            Call InstrSUB(VarX2,Out3,TempI$)
                            If VarX2 Then
                               VarX$=Nul
                               VarZ7!=VarZ7!+1!
                               If VarZ8!=0! Or VarZ7!=VarZ8! Then
                                  Temp2=True
                                  Temp3=VarX
                                  Strng="Text found in line:"+Str$(Temp3)
                                  If VarX2>0 Then
                                     Strng=Strng+", position"+Str$(VarX2)
                                  Endif
                                  Strng=Strng+"."
                                  Call IO.O
                               Endif
                            Endif
                         Endif
                      Next
                   Endif
                Endif
                If Break Then
                   Exit For
                Endif
                If Lost.Carrier Then
                   Exit For
                Endif
                If Continuous=False Then
                   Call More.Prompt
                   If No Or Quit Then
                      Exit For
                   Endif
                Endif
             Endif
          Next
          Allow.Break=False
          Break=False
          Exit Do
       Case "Q"
          Exit Sub
       End Select
    Loop
 Loop
 Exit Sub
ErrExit63:
 Exit Sub
ErrResume63:
 Resume ErrExit63
End Sub

Sub Get.Record.Range4(Var1!,Var2!,VarX!)
 On Local Error Goto ErrResume137a
 Var1$=Mid$(Str$(Var1!),2)
 Var2$=Mid$(Str$(Var2!),2)
 Strng=Strng+"("+Var1$+"-"+Var2$+")?"
 Call IO.I
 VarX!=Int(Val(Out2))
 If VarX!<Var1! Then
    VarX!=Var1!
 Endif
 If VarX!>Var2! Then
    VarX!=SFalse
 Endif
ErrExit137a:
 Exit Sub
ErrResume137a:
 Resume ErrExit137a
End Sub

