 Rem File: Dndsub6 for Dndbbs Version v5.0a Release r2.0 Tweak t5.0a
 Rem $Include: 'dndbbs.inc'

Sub Update.Mess(Var)
 On Local Error Goto ErrorTrap2
 VarX2=Node+1
 Call Read.Message.Record(MessWorkFile1,VarX2)
 Select Case Var
 Case 1
    Strng="Login"
 Case 2
    Strng="Relogin"
 Case 3
    Strng="Logoff"
 Case Else
    Strng=UserRecord.CodeName
    Call Read.Node7
    Call Update.Node7
    Call Write.User.Record
 End Select
 Call Make.Mess.Work1
 VarX2=Node+1
 Call Write.Message.Record(MessWorkFile1,VarX2)
 If Next.Room>False Then
    Strng="You are teleported elsewhere!"
    Call IO.O
    Call Teleport
    Action.Recurse=0
    Call Enter.Room
 Endif
ErrorResume2:
 Exit Sub
ErrorTrap2:
 Resume ErrorResume2
End Sub

Sub Make.Mess.Work1
 On Local Error Goto ErrorTrap3
 Call Get.Machine.Name(Var$)
 MessWorkRecord1.MachineName=Var$
 MessWorkRecord1.ActiveNode=True
 If Local.Mode Then
    MessWorkRecord1.PortNumber=0
 Else
    MessWorkRecord1.PortNumber=Port+1
 Endif
 MessWorkRecord1.UserName=Strng
 MessWorkRecord1.ClassName=UserRecord.ClassName
 MessWorkRecord1.ClassType=UserRecord.ClassType
 MessWorkRecord1.Invisible=UserRecord.Invisible
 VarQ!=UserRecord.Weapon(8).Index
 If VarQ! Then
    Call Read.Record(TreasureFile,VarQ!)
    If TreasureRecord.Invisible Then
       MessWorkRecord1.Invisible=True
    Endif
 Endif
 MessWorkRecord1.Hidden=UserRecord.Hidden
 MessWorkRecord1.LastCommand=Last.Command
 MessWorkRecord1.Level=UserRecord.Level
 MessWorkRecord1.RoomNumber=Room
 MessWorkRecord1.Score1=Players.Killed
 MessWorkRecord1.Score2=Monsters.Killed
 MessWorkRecord1.Score3=Permanent.Killed
 MessWorkRecord1.TimeOn=Time.On
 MessWorkRecord1.UserIndex=User.Index
 MessWorkRecord1.Monitor=Monitor.Mode
 MessWorkRecord1.Chatting=Chat.Mode
 MessWorkRecord1.Gold=UserRecord.Gold
 MessWorkRecord1.Exp=UserRecord.Experience
 MessWorkRecord1.LastMonster=Monster.Attacked
 MessWorkRecord1.LastUser=User.Attacked
 MessWorkRecord1.Fatigue=UserRecord.Fatigue
 MessWorkRecord1.Vitality=UserRecord.Vitality
ErrorResume3:
 Exit Sub
ErrorTrap3:
 Resume ErrorResume3
End Sub

Sub Update.Node7
 On Local Error Goto ErrorTrap4
 MessWorkRecord7.CodeName=UserRecord.CodeName
 MessWorkRecord7.PassWord=UserRecord.PassWord3
 MessWorkRecord7.Level=UserRecord.Level
 MessWorkRecord7.ClassType=UserRecord.ClassType
 MessWorkRecord7.Proficiency=UserRecord.Proficiency
 MessWorkRecord7.Weapon1=UserRecord.Weapons(1)
 MessWorkRecord7.Weapon2=UserRecord.Weapons(2)
 MessWorkRecord7.Weapon3=UserRecord.Weapons(3)
 MessWorkRecord7.Weapon4=UserRecord.Weapons(4)
 MessWorkRecord7.Classname=UserRecord.Classname
 MessWorkRecord7.Stat1=UserRecord.Stats(1)
 MessWorkRecord7.Stat2=UserRecord.Stats(2)
 MessWorkRecord7.Stat3=UserRecord.Stats(3)
 MessWorkRecord7.Stat4=UserRecord.Stats(4)
 MessWorkRecord7.Stat5=UserRecord.Stats(5)
 MessWorkRecord7.Stat6=UserRecord.Stats(6)
 MessWorkRecord7.Stat7=UserRecord.Stats(7)
 MessWorkRecord7.Stat8=UserRecord.Beauty
 MessWorkRecord7.Stat9=UserRecord.Glamour
 MessWorkRecord7.Experience=UserRecord.Experience
 MessWorkRecord7.Gold=UserRecord.Gold
 MessWorkRecord7.Room=Room
 MessWorkRecord7.TimeLimit=UserRecord.TimeLimit
 MessWorkRecord7.MaxCalls=UserRecord.MaxCalls
 MessWorkRecord7.FromHour=UserRecord.FromHour
 MessWorkRecord7.FromMin=UserRecord.FromMin
 MessWorkRecord7.ToHour=UserRecord.ToHour
 MessWorkRecord7.ToMin=UserRecord.ToMin
 MessWorkRecord7.SpecialFlags=UserRecord.Flags
 MessWorkRecord7.Race=UserRecord.Race
 MessWorkRecord7.FatigueMax=UserRecord.FatigueMax
 MessWorkRecord7.VitalityMax=UserRecord.VitalityMax
 MessWorkRecord7.MagicMax=UserRecord.MagicMax
 MessWorkRecord7.PsionicMax=UserRecord.PsionicMax
 MessWorkRecord7.Align1=UserRecord.Align1
 MessWorkRecord7.Align2=UserRecord.Align2
 MessWorkRecord7.First2=UserRecord.First2
 MessWorkRecord7.Last2=UserRecord.Last2
 MessWorkRecord7.Weight=False
 MessWorkRecord7.Vehicle=SFalse
 MessWorkRecord7.NodeList=UserRecord.NodeList2
 MessWorkRecord7.WishesLeft=UserRecord.WishsLeft
 MessWorkRecord7.NodeList2=UserRecord.NodeList
 MessWorkRecord7.Prefix1=UserRecord.Prefix1
 MessWorkRecord7.Prefix2=UserRecord.Prefix2
 For VarQ=1 To 10
    MessWorkRecord7.ObjCreated(VarQ)=UserRecord.ObjectsCreated(VarQ)
 Next
 MessWorkRecord7.Flags1=False
 MessWorkRecord7.Flags2=False
 MessWorkRecord7.Flags3=False
 MessWorkRecord7.Flags4=False
 MessWorkRecord7.Flags5=False
 VarX=Node+1
 Call Write.Message.Record(MessWorkFile7,VarX)
ErrorResume4:
 Exit Sub
ErrorTrap4:
 Resume ErrorResume4
End Sub

Sub Read.Node7
 On Local Error Goto ErrorTrap5
 Next.Room=SFalse
 VarX=Node+1
 Call Read.Message.Record(MessWorkFile7,VarX)
 Var1=MessWorkRecord7.Flags1
 Var2=MessWorkRecord7.Flags2
 Var3=MessWorkRecord7.Flags3
 Var4=MessWorkRecord7.Flags4
 Var5=MessWorkRecord7.Flags5
 If Var1=False And Var2=False And Var3=False And Var4=False And Var5=False Then
    Exit Sub
 Endif
 If Var1 Then
    For VarQ=1 To 10
       If (Var1 And 2^VarQ)=2^VarQ Then
          Select Case VarQ
          Case 1
             UserRecord.CodeName=MessWorkRecord7.CodeName
             If Rtrim$(UserRecord.CodeName)=Deleted$ Then
                'Call Write.Record(UserFile,User.Index)
                Call Hang.Up(4)
             Endif
          Case 2
             Strng2=MessWorkRecord7.PassWord
             Strng2=Rtrim$(Strng2)
             Call Crypto(Strng2)
             UserRecord.PassWord3=Strng2

             Strng2=MessWorkRecord7.PassWord
             Strng2=Rtrim$(Strng2)
             Call Cryptograph(Strng2)
             UserRecord.PassWord=Strng2

             UserRecord.Password2=Nul
          Case 3
             UserRecord.Level=MessWorkRecord7.Level
          Case 4
             UserRecord.ClassType=MessWorkRecord7.ClassType
          Case 5
             UserRecord.Proficiency=MessWorkRecord7.Proficiency
          Case 6
             UserRecord.Weapons(1)=MessWorkRecord7.Weapon1
          Case 7
             UserRecord.Weapons(2)=MessWorkRecord7.Weapon2
          Case 8
             UserRecord.Weapons(3)=MessWorkRecord7.Weapon3
          Case 9
             UserRecord.Weapons(4)=MessWorkRecord7.Weapon4
          Case 10
             UserRecord.Classname=MessWorkRecord7.Classname
          End Select
       Endif
    Next
 Endif
 If Var2 Then
    For VarQ=1 To 10
       If (Var2 And 2^VarQ)=2^VarQ Then
          Select Case VarQ
          Case 1
             UserRecord.Stats(1)=MessWorkRecord7.Stat1
          Case 2
             UserRecord.Stats(2)=MessWorkRecord7.Stat2
          Case 3
             UserRecord.Stats(3)=MessWorkRecord7.Stat3
          Case 4
             UserRecord.Stats(4)=MessWorkRecord7.Stat4
          Case 5
             UserRecord.Stats(5)=MessWorkRecord7.Stat5
          Case 6
             UserRecord.Stats(6)=MessWorkRecord7.Stat6
          Case 7
             UserRecord.Stats(7)=MessWorkRecord7.Stat7
          Case 8
             UserRecord.Experience=MessWorkRecord7.Experience
          Case 9
             UserRecord.Gold=MessWorkRecord7.Gold
          Case 10
             Next.Room=MessWorkRecord7.Room
          End Select
       Endif
    Next
 Endif
 If Var3 Then
    For VarQ=1 To 10
       If (Var3 And 2^VarQ)=2^VarQ Then
          Select Case VarQ
          Case 1
             UserRecord.TimeLimit=MessWorkRecord7.TimeLimit
          Case 2
             UserRecord.MaxCalls=MessWorkRecord7.MaxCalls
          Case 3
             UserRecord.FromHour=MessWorkRecord7.FromHour
          Case 4
             UserRecord.FromMin=MessWorkRecord7.FromMin
          Case 5
             UserRecord.ToHour=MessWorkRecord7.ToHour
          Case 6
             UserRecord.ToMin=MessWorkRecord7.ToMin
          Case 7
             UserRecord.Flags=MessWorkRecord7.SpecialFlags
          Case 8
             UserRecord.Race=MessWorkRecord7.Race
          Case 9
             UserRecord.Fatigue=MessWorkRecord7.FatigueMax
             UserRecord.FatigueMax=MessWorkRecord7.FatigueMax
          CAse 10
             UserRecord.Vitality=MessWorkRecord7.VitalityMax
             UserRecord.VitalityMax=MessWorkRecord7.VitalityMax
          End Select
       Endif
    Next
 Endif
 If Var4 Then
    For VarQ=1 To 10
       If (Var4 And 2^VarQ)=2^VarQ Then
          Select Case VarQ
          Case 1
             UserRecord.Magic=MessWorkRecord7.MagicMax
             UserRecord.MagicMax=MessWorkRecord7.MagicMax
          Case 2
             UserRecord.Psionic=MessWorkRecord7.PsionicMax
             UserRecord.PsionicMax=MessWorkRecord7.PsionicMax
          Case 3
             UserRecord.Align1=MessWorkRecord7.Align1
          Case 4
             UserRecord.Align2=MessWorkRecord7.Align2
          Case 5
             Monster.Attacked=False
          Case 6
             User.Attacked=False
          Case 7
             UserRecord.Encumbrance=MessWorkRecord7.Encumbrance
          Case 8
             UserRecord.First2=MessWorkRecord7.First2
             UserRecord.Last2=MessWorkRecord7.Last2
             Weight=Weight-MessWorkRecord7.Weight
             If Weight<DFalse Then
                Weight=DFalse
             Endif
          Case 9
             UserRecord.First2=MessWorkRecord7.First2
             UserRecord.Last2=MessWorkRecord7.Last2
             Weight=Weight+MessWorkRecord7.Weight
          Case 10
             Vehicle1=MessWorkRecord7.Vehicle
          End Select
       Endif
    Next
 Endif
 If Var5 Then
    For VarQ=1 To 8
       If (Var5 And 2^VarQ)=2^VarQ Then
          Select Case VarQ
          Case 1
             UserRecord.Beauty=MessWorkRecord7.Stat8
          Case 2
             UserRecord.Glamour=MessWorkRecord7.Stat9
          Case 3
             UserRecord.NodeList2=MessWorkRecord7.NodeList
          Case 4
             UserRecord.WishsLeft=MessWorkRecord7.WishesLeft
          Case 5
             UserRecord.NodeList=MessWorkRecord7.NodeList2
          Case 6
             UserRecord.Prefix1=MessWorkRecord7.Prefix1
          Case 7
             UserRecord.Prefix2=MessWorkRecord7.Prefix2
          Case 8
             For VarZ=1 To 10
                UserRecord.ObjectsCreated(VarZ)=MessWorkRecord7.ObjCreated(VarZ)
             Next
          End Select
       Endif
    Next
 Endif
ErrorResume5:
 Exit Sub
ErrorTrap5:
 Resume ErrorResume5
End Sub

Sub Zero.Node(Var)
 On Local Error Goto ErrorTrap6
 Var2=Var
 If Var2<>-1 Then
    Var2=0
 Endif
 Call Clear.Node(Var2)
 VarX=Node+1
 Call Write.Message.Record(MessWorkFile1,VarX)
 Call Clear.Node7
 Call Write.Message.Record(MessWorkFile7,VarX)
ErrorResume6:
 Exit Sub
ErrorTrap6:
 Resume ErrorResume6
End Sub

Sub Init.Node
 On Local Error Goto ErrorTrap7
 Var1=Lof(MessWorkFile1)/MessWorkRecLen1
 If Var1<MaxNodes+1 Then
    Var1=Var1+1
    For Var2=Var1 To MaxNodes+1
       Call Clear.Node(False)
       Call Write.Message.Record(MessWorkFile1,Var2)
    Next
 Endif
 Call Init.Node7
ErrorResume7:
 Exit Sub
ErrorTrap7:
 Resume ErrorResume7
End Sub

Sub Init.Node7
 On Local Error Goto ErrorTrap8
 Var1=Lof(MessWorkFile7)/MessWorkRecLen7
 If Var1<MaxNodes+1 Then
    Var1=Var1+1
    For Var2=Var1 To MaxNodes+1
       Call Clear.Node7
       Call Write.Message.Record(MessWorkFile7,Var2)
    Next
 Endif
ErrorResume8:
 Exit Sub
ErrorTrap8:
 Resume ErrorResume8
End Sub

Sub Clear.Node(Var)
 On Local Error Goto ErrorTrap9
 Call Get.Machine.Name(Var$)
 MessWorkRecord1.MachineName=Var$
 If Local.Mode Then
    MessWorkRecord1.PortNumber=0
 Else
    If Var Then
       MessWorkRecord1.PortNumber=Port+1
    Else   
       MessWorkRecord1.PortNumber=False
    Endif
 Endif
 MessWorkRecord1.ActiveNode=Var
 MessWorkRecord1.Monitor=False
 MessWorkRecord1.Chatting=False
 MessWorkRecord1.RoomNumber=SFalse
 MessWorkRecord1.UserIndex=SFalse
 MessWorkRecord1.UserName=Offline$
 MessWorkRecord1.ClassName=Offline$
 MessWorkRecord1.OfferTime=SFalse
 MessWorkRecord1.GoldFor=DFalse
 MessWorkRecord1.ItemFor=SFalse
 MessWorkRecord1.ForCharges=False
 MessWorkRecord1.GoldOffer=DFalse
 MessWorkRecord1.ItemOffer=SFalse
 MessWorkRecord1.OfferCharges=False
 MessWorkRecord1.ContainerOffer=False
 MessWorkRecord1.ContainerFor=False
 MessWorkRecord1.LastMonster=SFalse
 MessWorkRecord1.LastUser=SFalse
 MessWorkRecord1.SendFlags=String$(MaxNodes+1,"1")
 MessWorkRecord1.ReceiveFlags=String$(MaxNodes+1,"1")
ErrorResume9:
 Exit Sub
ErrorTrap9:
 Resume ErrorResume9
End Sub

Sub Clear.Node7
 On Local Error Goto ErrorTrap10
 MessWorkRecord7.Flags1=False
 MessWorkRecord7.Flags2=False
 MessWorkRecord7.Flags3=False
 MessWorkRecord7.Flags4=False
 MessWorkRecord7.Flags5=False
ErrorResume10:
 Exit Sub
ErrorTrap10:
 Resume ErrorResume10
End Sub

Sub Valid.Node
 On Local Error Goto ErrorTrap11
 If Node>=False And Node<=MaxNodes Then
    VarX2=Node+1
    Call Read.Message.Record(MessWorkFile1,VarX2)
    If MessWorkRecord1.ActiveNode Then
       Graphics.Off=True
       Locate ,,1
       Strng="Dndbbs main menu:"+Chr$(13)+Chr$(10)
       Call Scroll.Row(1)
       Strng=Nul
       Call Scroll.Row(1)
       If Rtrim$(NodeX)=Nul Then
          Out2="Node -, already active."
       Else
          Out2="Node "+NodeX+", already active."
       Endif
       If Rtrim$(NodeX)=Nul Then
          Out3="Close partition, or run dndutil /c"
       Else
          Out3="Close partition, or run dndutil /n:"+NodeX+"/c"
       Endif
       Port=-1
       Call Terminate.Program(0)
    Else
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          Graphics.Off=True
          Locate ,,1
          Strng="Dndbbs main menu:"+Chr$(13)+Chr$(10)
          Call Scroll.Row(1)
          Strng=Nul
          Call Scroll.Row(1)
          If Rtrim$(NodeX)=Nul Then
             Out2="Node -, active codename."
          Else
             Out2="Node "+NodeX+", active codename."
          Endif
          If Rtrim$(NodeX)=Nul Then
             Out3="Close partition, or run dndutil /c"
          Else
             Out3="Close partition, or run dndutil /n:"+NodeX+"/c"
          Endif
          Port=-1
          Call Terminate.Program(0)
       Endif
    Endif
 Else
    Graphics.Off=True
    Locate ,,1
    Strng="Dndbbs main menu:"+Chr$(13)+Chr$(10)
    Call Scroll.Row(1)
    Strng=Nul
    Call Scroll.Row(1)
    Out2="Node '"+NodeX+"' is not a valid node number."
    If Rtrim$(NodeX)=Nul Then
       Out3="Use another node, or run dndutil /c"
    Else
       Out3="Use another node, or run dndutil /n:"+NodeX+"/c"
    Endif
    Port=-1
    Call Terminate.Program(0)
 Endif
ErrorResume11:
 Exit Sub
ErrorTrap11:
 Resume ErrorResume11
End Sub

Sub Valid.Port
 On Local Error Goto ErrorTrap11z
 If Local.Mode Then
    Exit Sub
 Endif
 If Check.Machine.Name=False Then
    Exit Sub
 Endif
 Call Get.Machine.Name(Var$)
 For Var=0 To MaxNodes
    If Var<>Node Then
       Call Read.Message.Record(MessWorkFile1,Var+1)
       If Rtrim$(MessWorkRecord1.MachineName)=Rtrim$(Var$) Then
          If MessWorkRecord1.ActiveNode Then
             If MessWorkRecord1.PortNumber>0 Then
                If MessWorkRecord1.PortNumber=Port+1 Then
                   Graphics.Off=True
                   Locate ,,1
                   Strng="Dndbbs main menu:"+Chr$(13)+Chr$(10)
                   Call Scroll.Row(1)
                   Strng=Nul
                   Call Scroll.Row(1)
                   Out2="Warning: Communications Conflict!"
                   Out3="COM"+Mid$(Str$(Port+1),2)+": on node"
                   Select Case Var
                   Case 0
                      Out3=Out3+" -"
                   Case 1 To 10 ' 0-9
                      Out3=Out3+Str$(Var-1)
                   Case 11 To 36 ' A-Z
                      Out3=Out3+" "+Chr$(Var+54) ' 11-05-2018
                   Case 37 To 126 ' 10-99
                      Out3=Out3+Str$(Var-27)
                   End Select
                   Out3=Out3+", already active."
                   Port=-1
                   Call Terminate.Program(0)
                Endif
             Endif
          Endif
       Endif
    Endif
 Next
ErrorResume11z:
 Exit Sub
ErrorTrap11z:
 Resume ErrorResume11z
End Sub

' store default server name
Sub Get.Machine.Name(VarX$)
 On Local Error Goto ErrorTrap19z
 DIM Default.Net AS STRING * 16
 VarX$ = Nul
 Default.Net = Nul
 InregsX.AX = &H5E00
 InregsX.DS = VARSEG(Default.Net)
 InregsX.DX = VARPTR(Default.Net)
 CALL InterruptX(&H21, InregsX, OutregsX)
 ' check error flag.
 IF (OutregsX.Flags AND &H1) = &H0 THEN
    ' read CH
    VarS = (OutregsX.CX AND &HFF00) / 256
    IF VarS > 0 THEN ' valid name.
       VarX$ = Default.Net
       Imbedded = INSTR(VarX$, CHR$(0))
       IF Imbedded THEN
          VarX$ = LEFT$(VarX$, Imbedded - 1)
       END IF
       VarX$ = UCASE$(RTRIM$(VarX$))
       EXIT SUB
    END IF
 END IF
 ' check net path.
 If VarX$ = Nul Then
    Var$ = Environ$("COMPUTERNAME")
    If Len(Var$) Then
       VarX$ = Var$
    Endif
 Endif
ErrorResume19z:
 Exit Sub
ErrorTrap19z:
 Resume ErrorResume19z
End Sub

Sub Clear.Container.Swap
 On Local Error Goto ErrorTrp32z
 Temp5!=UserRecord.First2
 If Temp5! Then
    Do
       Call Read.Record(ContainerFile,Temp5!)
       Var6!=ContainerRecord.Next
       ContainerRecord.SwapFlag=False
       Call Write.Record(ContainerFile,Temp5!)
       If Var6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Var6!
    Loop
 Endif
ErrorRsm32z:
 Exit Sub
ErrorTrp32z:
 Resume ErrorRsm32z
End Sub

Sub Clear.Mess
 On Local Error Goto ErrorTrap14
 For Var!=1! To Lof(MessWorkFile2)/MessWorkRecLen2
    Call Read.Record(MessWorkFile2,Var!)
    Mid$(MessWorkRecord2.Flags,Node+1,1)="1"
    Call Write.Record(MessWorkFile2,Var!)
 Next
ErrorResume14:
 Exit Sub
ErrorTrap14:
 Resume ErrorResume14
End Sub

' Var1 = message type
' Var2! = User.Index
' Var3! = Room.Number
' Var1$ = Message
Sub Send.Mess(Var1,Var2!,Var3!,Var1$)
 On Local Error Goto ErrorTrap15
 Temp$=String$(MaxNodes+1,"0")
 For Temp4=False To MaxNodes
    VarX3=Temp4+1
    Call Read.Message.Record(MessWorkFile1,VarX3)
    HiddenMess=False
    If Temp4=Node Then
       HiddenMess=True
       If Var1=7 Then
          Strng="Whisper sent."
          Call IO.O
       Endif
       If Echo Then
          Select Case Var1
          Case 1, 2, 3, 6
             Strng="Message sent."
             Call IO.O
          Case 10, 11
             Strng="Telepathic message sent."
             Call IO.O
          Case 12, 14
             Strng="Program abort sent."
             Call IO.O
          Case 32, 33
             Strng="Program shutdown sent."
             Call IO.O
          End Select
       Endif
    Endif
    If Var2!>SFalse And MessWorkRecord1.UserIndex<>Var2! Then
       HiddenMess=True
    Endif
    If Var3!>SFalse And MessWorkRecord1.RoomNumber<>Var3! Then
       HiddenMess=True
    Endif
    If Var3!<SFalse Then
       HiddenMess=True
       If MessWorkRecord1.RoomNumber=Room Then
          HiddenMess=False
       Endif
       For Temp5=1 To MaxDirections
          If RoomRecord.Direct(Temp5)>False Then
             If MessWorkRecord1.RoomNumber=RoomRecord.Direct(Temp5) Then
                HiddenMess=False
                Exit For
             Endif
          Endif
       Next
    Endif
    If Temp4<>Node Then
       If Chat.Mode Then
          If MessWorkRecord1.Chatting=False Then
             HiddenMess=True
          Endif
       Endif
       If MessWorkRecord1.Monitor Then
          HiddenMess=True
       Endif
    Endif
    If MessWorkRecord1.UserIndex=SFalse Then
       If MessWorkRecord1.RoomNumber=SFalse Then
          HiddenMess=True
       Endif
    Endif
    If HiddenMess Then
       Mid$(Temp$,Temp4+1,1)="1"
    Endif
    If Temp4<>Node Then
       Select Case Var1
       Case 1, 2, 3, 6, 7, 10, 11, 25, 26
          VarX3=Temp4+1
          Call Read.Message.Record(MessWorkFile1,VarX3)
          If Mid$(MessWorkRecord1.ReceiveFlags,Node+1,1)="0" Then
             Mid$(Temp$,Temp4+1,1)="1"
          Endif
          VarX2=Node+1
          Call Read.Message.Record(MessWorkFile1,VarX2)
          If Mid$(MessWorkRecord1.SendFlags,Temp4+1,1)="0" Then
             Mid$(Temp$,Temp4+1,1)="1"
          Endif
       End Select
    Endif
 Next
 Mid$(Temp$,Node+1,1)="1"
 If Temp$=String$(MaxNodes+1,"1") Then
    Select Case Var1
    Case 1, 2, 3, 6, 7, 10, 11, 26
       Strng="Nobody hears you!"
       Call IO.O
    End Select
 Endif
 If Echo=False Then
    Select Case Var1
    Case 1, 2, 3, 26
       Mid$(Temp$,Node+1,1)="0"
    End Select
 Endif
 For Temp4=False To MaxNodes
    If Temp4<>Node Then
       VarX3=Temp4+1
       Call Read.Message.Record(MessWorkFile1,VarX3)
       If MessWorkRecord1.Monitor Then
          Select Case Var1
          Case 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 20, 25, 26, 32
             Mid$(Temp$,Temp4+1,1)="0"
          Case 8
             If MessWorkRecord1.RoomNumber=Room Then
                Mid$(Temp$,Temp4+1,1)="0"
             Endif
          Case 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 33, 37, 38, 39, 40
             If MessWorkRecord1.UserIndex=Var2! Then
                Mid$(Temp$,Temp4+1,1)="0"
             Endif
          End Select
       Endif
    Endif
 Next
 For Var!=1! To Lof(MessWorkFile2)/MessWorkRecLen2
    Call Read.Record(MessWorkFile2,Var!)
    If MessWorkRecord2.Flags=String$(MaxNodes+1,"1") Then
       Exit For
    Endif
    VarX!=Csng(Config2(132))
    If VarX!>SFalse Then
       If Time.Elapsed(MessWorkRecord2.MessageTime,VarX!) Then
          Exit For
       Endif
    Endif
 Next
 If Var!>Csng(Config2(133)) Then
    Exit Sub
 Endif
 If User.Index=SFalse Then
    Strng=Codename.Temp
 Else
    Strng=UserRecord.CodeName
 Endif
 MessWorkRecord2.Flags=Temp$
 MessWorkRecord2.Message=Var1$
 MessWorkRecord2.MessageTime=Timeit!
 MessWorkRecord2.MessageType=Var1
 MessWorkRecord2.Node=Node
 MessWorkRecord2.RoomNumber=Room
 MessWorkRecord2.UserIndex=User.Index
 MessWorkRecord2.UserName=Strng
 If Var1=25 Then
    MessWorkRecord2.Message2=Str$(TempX)+TempA$
 Else
    MessWorkRecord2.Message2=Out4
 Endif
 Call Write.Record(MessWorkFile2,Var!)
ErrorResume15:
 Exit Sub
ErrorTrap15:
 Resume ErrorResume15
End Sub

Sub Update.LastUser
 On Local Error Goto ErrorTrap18
 Strng=UserRecord.CodeName
 Strng=Lcase$(Strng)
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Strng3=Format$(Now,"hh:mm:ss")
 Strng=Strng+" "+Time.On+" "+Strng3
 OnTime#=TimeValue(Strng3)-TimeValue(Time.On)
 If OnTime#<False Then
    OnTime#=OnTime#+TimeValue("12:00:00")*2
 Endif
 Temp$=Format$(OnTime#,"hh:mm:ss")
 Strng=Strng+" "+Temp$
 Var#=Permanent.Killed*UserRecord.Level*10+ _
    Players.Killed*UserRecord.Level*2+ _
    Monsters.Killed*UserRecord.Level
 If Var#=DFalse Then
    Strng=Strng+" Zero"
 Else
    Strng=Strng+Str$(Var#)
 Endif
 Call Update.DayFile(Strng,UnTrue,0)
ErrorResume18:
 Exit Sub
ErrorTrap18:
 Resume ErrorResume18
End Sub

Sub Out.File(Var$)
 On Local Error Goto ErrorTrap23
 If Lost.Carrier Then
    Exit Sub
 Endif
 If Dir$(Var$)=Nul Then
    If Local.Mode And Debug.Mode Then
       Strng="Filename "+Chr$(34)+Var$+Chr$(34)+" not found."
       Call IO.O
    Endif
    Exit Sub
 Endif
 Call Playwav(11)
 Call Modem.ANSI(1,37,15)
 Call ScreenANSI(1,37,15)
 Carriage.Return=False
 Graphics.On=False
 Graphics.Off=True

 If Environ$("FILELISTHEADER")<>"" Then
    Strng=Environ$("FILELISTHEADER")
    If Left$(Strng,1)=Chr$(34) Then
       If Right$(Strng,1)=Chr$(34) Then
          Strng=Left$(Strng,Len(Strng)-1)
          Strng=Mid$(Strng,2)
       Endif
    Endif
    Select Case Ucase$(Strng)
    Case "OFF","FALSE","0"
       Eat$=Nul
    Case Else
       Call IO.O
       Var=1
    End Select
 Else
    Strng="File list. "
    If Local.Mode Then
       Var2$="Press <ctrl-break>/<ctrl-c> to interrupt."
    Else
       Var2$="Press <control-c>/<control-k> to interrupt."
    Endif
    Strng=Strng+Var2$
    Call IO.O
    Var=1
 Endif

 Allow.Break=True
 Break=False
 Continuous=False
 Graphics.Off=True
 VarQ=False
 VarR=False
 Close #TempFile1
 Open Var$ For Input Shared As #TempFile1
 Call Modem.ANSI(4,37,15)
 Call ScreenANSI(4,37,15)
 Do While Lost.Carrier=False
    Allow.Break=True
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1,Strng
    If Lcase$(Strng)="[eof]" Then
       Exit Do
    Endif
    If Left$(Strng,1)<>";" Then
       If Len(Strng) Then
          Var2$=ANSIPrefixChar
          If Len(Var2$) Then
             ' reset moreprompt
             For VarZ=1 To 5
                Var3$=Var2$+"M"+Ltrim$(Str$(VarZ))
                If Instr(Ucase$(Strng),Var3$) Then
                   Var=False
                   Exit For
                Endif
             Next
             Var3$=Var2$+"MO"
             If Instr(Ucase$(Strng),Var3$) Then
                Var=False
             Endif
             Var3$=Var2$+"CS"
             If Instr(Ucase$(Strng),Var3$) Then
                Var=False
             Endif
          Endif
       Endif
       No=0:Quit=0
       Strng2=Strng
       Call Convert.String
       Call Convert.ANSI(False,VarQ,VarR)
       If No Or Quit Then ' possible moreprompt
          Strng=Nul:Out2=Nul
          Exit Do
       Endif
       Graphics.On=True
       Call IO.O
       Graphics.On=False
       If Break Then
          Exit Do
       Endif
       Select Case Lcase$(Strng2)
       Case "[xon]", "[xoff]", "[bell]"
          Eat$=Nul
       Case Else
          Var=Var+1
          If Var>=User.Pagelength-2 Then
             Var=False
             If Continuous=False Then
                Gosub MorePrompt
                Call Modem.ANSI(4,37,15)
                Call ScreenANSI(4,37,15)
                If No Or Quit Then
                   Exit Do
                Endif
             Endif
          Endif
       End Select
    Endif
 Loop
 If Var>1 Then
    If Break=False Then
       Graphics.Off=False
       Gosub MorePrompt
    Endif
 Endif
 If Break=1 Then ' cancel
    Call Redisplay.Prompt
 Endif
 Allow.Break=False
 Break=False
 Graphics.Off=True
 Call Modem.ANSI(1,37,15)
 Call ScreenANSI(1,37,15)
 Call Modem.ANSI(4,37,15)
 Call ScreenANSI(4,37,15)
 Strng="[xon]"
 Call Convert.String
 Call Playwav(15) ' turn on playwav
 Exit Sub
MorePrompt:
 If Break Then
    Return
 Endif
 Buffer=Nul
 Line.Length=1
 No.Echo=True
 Type.Ahead=Nul
 Out2=Nul
 No.Input.Out=Nul
 If Environ$("MOREPROMPT")<>"" Then
    Strng=Environ$("MOREPROMPT")
    If Left$(Strng,1)=Chr$(34) Then
       If Right$(Strng,1)=Chr$(34) Then
          Strng=Left$(Strng,Len(Strng)-1)
          Strng=Mid$(Strng,2)
       Endif
    Endif
    Graphics.On=False
    Word.Wrap=-1
    Call IO.I
    Word.Wrap=0
 Else
    Strng=More$
    Graphics.On=False
    Call IO.I
 Endif
 If Out2="?" Then
    Strng=" (Y)es"
    Call IO.O
    Strng=" (N)o"
    Call IO.O
    Strng=" (Q)uit"
    Call IO.O
    Strng=" (C)ontinuous"
    Call IO.O
    Call Modem.ANSI(4,33,15)
    Call ScreenANSI(4,33,15)
    Goto MorePrompt
 Endif
 If Out2=Nul Then
    VarX$=Environ$("MOREPROMPTDEFAULT")
    If Len(VarX$) Then
       Select Case VarX$
       Case "Y", "YES"
          Yes=-1 : No=0 : Quit=0 : Continuous=0
       Case "N", "NO"
          Yes=0 : No=-1 : Quit=0 : Continuous=0
       Case "Q", "QUIT"
          Yes=0 : No=0 : Quit=-1 : Continuous=0
       Case "C", "CONTINUOUS"
          Yes=0 : No=0 : Quit=0 : Continuous=-1
       Case Else
          Yes=-1 : No=0 : Quit=0 : Continuous=0
       End Select
    Endif
 Endif
 Strng=Nul
 Out2=Nul
 Color.Code=VarQ
 Avatar.Code=VarR
 Return
ErrorResume23:
 Exit Sub
ErrorTrap23:
 Resume ErrorResume23
End Sub

' Var: -1=dayfile, 0=daylog, 1=lastuser
Sub Update.Dayfile(Var$,Var,Var3)
 On Local Error Goto ErrorTrap26
 Select Case Var
 Case 0
    If Config2(70) Then
       FileName=Day.Log.FileName
       Call Clean.UpdateFile(1)
    Endif
 Case -1
    If Config2(71) Then
       FileName=Day.File.FileName
       Call Clean.UpdateFile(2)
    Endif
 Case 1
    FileName=LastUser.FileName
    Call Clean.UpdateFile(3)
 End Select
 If User.Index=SFalse Then
    Temp$="(prelogin)"
 Else
    Call Read.Record(UserFile,User.Index)
    Temp$=Lcase$(Rtrim$(UserRecord.CodeName))
    If Temp$=String$(30,0) Then
       Temp$="(invalid)"
    Else
       If Temp$=Nul Then
          Temp$="(unknown)"
       Endif
    Endif
 Endif
 Mid$(Temp$,1,1)=Ucase$(Mid$(Temp$,1,1))
 Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
 Select Case Var
 Case True
    FileName=Day.File.FileName
    Strng3=Format$(Now,"hh:mm:ss")
    TempX$=DateS$+" "+Strng3+" "+Temp$+": "+Var$
 Case False
    FileName=Day.Log.FileName
    Select Case Var3
    Case 1
       Temp$="***"+Temp$
    Case 2
       Temp$="**"+Temp$
    Case 3
       Temp$="*"+Temp$
    Case Else
       Temp$="**"+Temp$
    End Select
    Strng3=Format$(Now,"hh:mm:ss")
    TempX$=DateS$+" "+Strng3+" "+Temp$+": "+Var$
 Case UnTrue
    FileName=LastUser.FileName
    TempX$=DateS$+" "+Var$
 End Select
 If Var<=0 Then
    If Right$(TempX$,1)<>"!" Then
       If Right$(TempX$,1)<>"." Then
          TempX$=TempX$+"."
       Endif
    Endif
 Endif
 Close #DayFile1
 Open FileName For Random Shared As #DayFile1 Len=DayFileRecLen
 Temp!=Lof(DayFile1)/DayFileRecLen+1!
 BufferRecord.Buffer=TempX$
 Call Write.Record(DayFile1,Temp!)
 Close #DayFile1
ErrorResume26:
 Exit Sub
ErrorTrap26:
 Resume ErrorResume26
End Sub

' Var: 1=dndbbs.log, 2=dndbbs.day, 3=lastuser.dat
Sub Clean.UpdateFile(Var)
 On Local Error Goto ErrorTrap20
 Close #DayFile1
 Open FileName For Random Shared As #DayFile1 Len=DayFileRecLen
 If Lof(DayFile1)=0 Then
    Exit Sub
 Endif
 Call Read.Record(DayFile1,1!)
 Temp$=BufferRecord.Buffer
 ' check last date write
 Var$=DateS$
 If Left$(Temp$,10)<>Var$ Then
    ' backup file
    Close #TempFile1
    Select Case Var
    Case 1
       FileName2$=Data.Path1+"dndlog.bak"
    Case 2
       FileName2$=Data.Path1+"dndday.bak"
    Case 3
       FileName2$=Data.Path1+"lastuser.bak"
    End Select
    Open FileName2$ For Append Shared As #TempFile1
    For Var2=1 To Lof(DayFile1)/DayFileRecLen
       Get #DayFile1,Var2,BufferRecord
       Var$=Rtrim$(BufferRecord.Buffer)
       Print #TempFile1,Var$
    Next
    Close #TempFile1
    ' kill/reopen file
    Close #DayFile1
    Kill FileName
    Open FileName For Random Shared As #DayFile1 Len=DayFileRecLen
 Endif
ErrorResume20:
 Exit Sub
ErrorTrap20:
 Resume ErrorResume20
End Sub

Sub Add.Room(Var)
 On Local Error Goto ErrorTrap30
 Var=False
 Graphics.Off=True
 Strng="No room exists in that direction."
 Call IO.O
 Var2$=DND.Path+"CMD159.EXE"
 If Dir$(Var2$)=Nul Then
    Exit Sub
 Endif
 Strng="You may create a room there."
 Call IO.O
 Graphics.Off=False
 No.Input.Out="N"
 Strng="Add new room(y/n)? "
 Call IO.I
 If Yes Then
    Call Clear.Room
    TempX!=Next.Room
    Remote=-1
    Call Chain.Command(159) ' Call Edit.Room(TempX!)
 Endif
 Strng="Room not added."
 Call IO.O
ErrorResume30:
 Exit Sub
ErrorTrap30:
 Resume ErrorResume30
End Sub

Sub Clear.UserInv
 On Local Error Goto ErrorTrap30a
 For Var4!=1! To Lof(UserInvFile)/MessWorkRecLen6
    Call Read.Record(UserInvFile,Var4!)
    If MessWorkRecord6.User=User.Index Then
       MessWorkRecord6.User=SFalse
       MessWorkRecord6.Room=SFalse
       MessWorkRecord6.Index=SFalse
       MessWorkRecord6.Charges=False
       MessWorkRecord6.Plus=False
       MessWorkRecord6.Prev=SFalse
       MessWorkRecord6.Next=SFalse
       Call Write.Record(UserInvFile,Var4!)
    Endif
 Next
ErrorResume30a:
 Exit Sub
ErrorTrap30a:
 Resume ErrorResume30a
End Sub

Sub Clear.UserWeapons
 On Local Error Goto ErrorTrap30b
 For Temp6=1 To 10
    If UserRecord.Weapon(Temp6).Index Then
       Var1!=UserRecord.Weapon(Temp6).Index
       Var2=UserRecord.Weapon(Temp6).Charges
       UserRecord.Weapon(Temp6).Index=SFalse
       UserRecord.Weapon(Temp6).Plus=False
       Call Read.Record(TreasureFile,Var1!)
       Call Add.Inventory(Var1!,Var2)
    Endif
 Next
 Call Write.Record(UserFile,User.Index)
ErrorResume30b:
 Exit Sub
ErrorTrap30b:
 Resume ErrorResume30b
End Sub

Sub Clear.Room
 On Local Error Goto ErrorTrap31
 Next.Room=Lof(RoomFile)/RoomRecLen+1!
 RoomRecord.Action=SFalse
 RoomRecord.Custom1=Nul
 RoomRecord.Custom2=Nul
 For Var2=1 To MaxDirections
    RoomRecord.Direct(Var2)=SFalse
 Next
 RoomRecord.Direct(13)=SFalse
 RoomRecord.Direct(14)=SFalse
 For Var2=1 To 19
    RoomRecord.LongDesc(Var2)=SFalse
 Next
 RoomRecord.ShortDesc=Nul
 RoomRecord.MonClass=SFalse
 RoomRecord.First=SFalse
 RoomRecord.Last=SFalse
 RoomRecord.First2=SFalse
 RoomRecord.Last2=SFalse
 Call Write.Record(RoomFile,Next.Room)
ErrorResume31:
 Exit Sub
ErrorTrap31:
 Resume ErrorResume31
End Sub

Sub Clear.TeamFile
 On Local Error Goto ErrorTrap32
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For Var2=1 To 5
       If TeamRecord.UserIndex(Var2)=User.Index Then
          TeamRecord.Member(Var2)=Nul
          TeamRecord.UserIndex(Var2)=SFalse
          TeamRecord.Activated(Var2)=False
          Call Write.Record(TeamFile,Var!)
          If Local.Mode Then
             Strng="Team record deleted."
             Call IO.O
          Endif
          Exit Sub
       Endif
    Next
 Next
ErrorResume32:
 Exit Sub
ErrorTrap32:
 Resume ErrorResume32
End Sub

Sub Clear.LogFile
 On Local Error Goto ErrorTrap33
 Close #LogFile
 Open Log.FileName For Random Shared As #LogFile Len=LogRecLen
 For Temp1!=1! To Lof(LogFile)/LogRecLen
    Call Read.Record(LogFile,Temp1!)
    If LogRecord.User=User.Index Then
       LogRecord.User=SFalse
       Call Write.Record(LogFile,Temp1!)
    Endif
 Next
 Close #LogFile
 FileName=DND.Path+"writing.log"
 Open FileName For Random Shared As #LogFile Len=LogRecLen
 For Temp1!=1! To Lof(LogFile)/LogRecLen
    Call Read.Record(LogFile,Temp1!)
    If LogRecord.User=User.Index Then
       LogRecord.User=SFalse
       Call Write.Record(LogFile,Temp1!)
    Endif
 Next
 Close #LogFile
ErrorResume33:
 Exit Sub
ErrorTrap33:
 Resume ErrorResume33
End Sub

Sub Clear.ScrollFile
 On Local Error Goto ErrorTrap33b
 Close #LogFile
 FileName=DND.Path+"writing.log"
 Open FileName For Random Shared As #LogFile Len=LogRecLen
 For Temp1!=1! To Lof(LogFile)/LogRecLen
    Call Read.Record(LogFile,Temp1!)
    If LogRecord.User=User.Index Then
       LogRecord.User=SFalse
       Call Write.Record(LogFile,Temp1!)
    Endif
 Next
ErrorResume33b:
 Exit Sub
ErrorTrap33b:
 Resume ErrorResume33b
End Sub

Sub Clear.Bank
 On Local Error Goto ErrorTrap33a
 Close #TempFile1
 FileName=Data.Path1+Bank.FileName+File.Extension1
 Open FileName For Random As #TempFile1 Len=BankRecLen
 For Var!=1! To Lof(TempFile1)/BankRecLen
    Call Read.Record(BankFile,Var!)
    If BankRecord.UserIndex=User.Index THEN
       BankRecord.UserIndex=SFalse
       Call Write.Record(BankFile,Var!)
    Endif
 Next
ErrorResume33a:
 Exit Sub
ErrorTrap33a:
 Resume ErrorResume33a
End Sub

Sub Display.LogFile
 On Local Error Goto ErrorTrap34
 Close #LogFile
 Open Log.FileName For Random Shared As #LogFile Len=LogRecLen
 VarX=False
 For Temp1!=1! To Lof(LogFile)/LogRecLen
    Call Read.Record(LogFile,Temp1!)
    If LogRecord.User=User.Index Then
       Strng=Rtrim$(LogRecord.Message)
       Strng=Strng+" on "+LogRecord.Clock+"."
       Graphics.Off=True
       Call IO.O
       LogRecord.User=SFalse
       Call Write.Record(LogFile,Temp1!)
       VarX=VarX+1
       If VarX>=User.PageLength-2 Then
          VarX=False
          Call More.Prompt
       Endif
    Endif
 Next
 If VarX Then
    Call More.Prompt
 Endif
ErrorResume34:
 Exit Sub
ErrorTrap34:
 Resume ErrorResume34
End Sub

Sub Clean.Room.Node(Var1!)
 On Local Error Goto ErrorTrap35
 If Var1!<=SFalse Or Var1!>Lof(RoomFile)/RoomRecLen Then
    Exit Sub
 Endif
 For VarX=False To MaxNodes
    If VarX<>Node Then
       Call Read.Message.Record(MessWorkFile1,VarX+1)
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          If MessWorkRecord1.RoomNumber=Var1! Then
             Exit Sub
          Endif
       Endif
    Endif
 Next
 Call Read.Record(RoomFile,Var1!)
 If Config2(58)=False Then
    Temp5!=RoomRecord.First
    If Temp5! Then
       Do While Lost.Carrier=False
          Call Read.Record(RoomInvFile,Temp5!)
          If MessWorkRecord6.Room=SFalse Then
             Exit Do
          Endif
          Temp6!=MessWorkRecord6.Next
          If MessWorkRecord6.Plus=False Then
             Temp2!=MessWorkRecord6.Index
             If Temp2!>SFalse And Temp2!<=Lof(TreasureFile)/TreasureRecLen Then
                Call Read.Record(TreasureFile,Temp2!)
                If TreasureRecord.StaysInRoom=False Then
                   Call Delete.List.Node(Temp5!)
                   Call Clear.List.Node
                   Call Write.Record(RoomInvFile,Temp5!)
                Endif
             Endif
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp5!=Temp6!
       Loop
    Endif
 Endif
 For Temp5!=1! To Lof(MessWorkFile3)/MessWorkRecLen3
    Call Read.Record(MessWorkFile3,Temp5!)
    If MessWorkRecord3.IsAutomaton=False Then
       If MessWorkRecord3.Monster.RemainsInRoom=False Then
          If MessWorkRecord3.Room=Var1! Then
             MessWorkRecord3.Room=SFalse
             Call Write.Record(MessWorkFile3,Temp5!)
          Endif
       Endif
    Endif
 Next
 For Temp5!=1! To Lof(MessWorkFile4)/MessWorkRecLen4
    Call Read.Record(MessWorkFile4,Temp5!)
    If MessWorkRecord4.Room=Var1! Then
       MessWorkRecord4.Room=SFalse
       Call Write.Record(MessWorkFile4,Temp5!)
    Endif
 Next
 For Temp5!=1! To Lof(MessWorkFile5)/MessWorkRecLen5
    Call Read.Record(MessWorkFile5,Temp5!)
    If MessWorkRecord5.Room=Var1! Then
       MessWorkRecord5.Room=SFalse
       Call Write.Record(MessWorkFile5,Temp5!)
    Endif
 Next
ErrorResume35:
 Exit Sub
ErrorTrap35:
 Resume ErrorResume35
End Sub

Sub Reset.Cursor
 On Local Error Goto ErrorTrap39
 Call ScreenANSI(1,37,7)
 If MaxRow.Override=False Then
    Call Read.Rows(Max.Row)
 Else
    Max.Row=MaxRow.Override
 Endif
 Locate Max.Row-1,1,1
 If Chained=True Then
    Call Reset.Status.Line
 Endif
 Graphics.Off=False
 Line.Length=False
ErrorResume39:
 Exit Sub
ErrorTrap39:
 Resume ErrorResume39
End Sub
