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

 On Error Goto ErrMain0
 Call Stdin(Var)
 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,"9")
    If Var=False Then
       Call Terminate.Program
       End
    Endif
 Endif
 Call Edit.Teams
MainExit0:
 End
ErrMain0:
 Resume MainExit0
 End

Function ValidDate(Var$)
 On Local Error Goto DateError
 Var$=Rtrim$(Var$)
 If Len(Var$)=10 Then ' mm-dd-yyyy
    For Var=1 To 10
       V$=Mid$(Var$,Var,1)
       Select Case Var
       Case 1, 2, 4, 5, 7, 8, 9, 10
          If V$>="0" And V$<="9" Then
             Eat$ = Nul
          Else
             Goto DateResume
          Endif
       Case Else
          If V$ <> "-" Then
             Goto DateResume
          Endif
       End Select
    Next
 Endif
 Temp#=DateValue(Var$)
 If Temp# Then
    TempC$=Var$
    ValidDate=True
    Exit Function
 Endif
DateResume:
 ValidDate=False
 Exit Function
DateError:
 Resume DateResume
End Function

Sub Edit.Teams
 On Local Error Goto ErrResume87
 Call Edit.Status.Line
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Team Edit utility v"+Left$(Version$,4)+" menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(314,"[A]")+"dd"
       Call IO.O
       Strng=RT$(315,"[C]")+"hange"
       Call IO.O
       Strng=RT$(316,"[D]")+"elete"
       Call IO.O
       Strng=RT$(317,"[L]")+"ist"
       Call IO.O
       Strng=RT$(318,"[P]")+"ack"
       Call IO.O
       Strng=RT$(319,"[R]")+"epair"
       Call IO.O
       Strng=RT$(320,"[S]")+"earch"
       Call IO.O
       Strng=RT$(321,"[T]")+"op ten"
       Call IO.O
       Strng=RT$(322,"[U]")+"ndelete"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(589,"[V]")+"Print"
          Call IO.O
       Endif
       Graphics.Off=False
    Endif
    Strng="Team edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(314,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Add.Team
          Temp5!=Lof(TeamFile)/TeamRecLen
          Call Change.Team
       Endif
    Case "C"
       If RT$(315,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Find.Team
          If Temp5! Then
             Call Change.Team
          Endif
       Endif
    Case "D"
       If RT$(316,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Delete.Team
       Endif
    Case "L"
       If RT$(317,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call List.Teams
       Endif
    Case "P"
       If RT$(318,"[P]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Pack.Teams
       Endif
    Case "R"
       If RT$(319,"[R]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Repair.Teams(True)
       Endif
    Case "S"
       If RT$(320,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Search.Teams
       Endif
    Case "T"
       If RT$(321,"[T]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Top.Ten.Teams
       Endif
    Case "U"
       If RT$(322,"[U]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Undelete.Team
       Endif
    Case "V"
       If Local.Mode Then
          If RT$(589,"[V]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Print.Teams
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Close
 Call Clear.Status.Line
 If Chained2 Then
    Chain DND.Path+"EDIT.EXE"
 Endif
 Call Terminate.Program
ErrExit87:
 Exit Sub
ErrResume87:
 Resume ErrExit87
End Sub

Sub Add.Team
 On Local Error Goto ErrResume88
 Temp5!=Lof(TeamFile)/TeamRecLen+1!
 TeamRecord.Name="<empty>"
 Temp2$=Deleted$
 Call Cryptograph(Temp2$)
 TeamRecord.Pass=Temp2$
 For Var2=1 To MaxTeamMembers
    TeamRecord.Member(Var2)=Nul
    TeamRecord.UserIndex(Var2)=SFalse
    TeamRecord.Activated(Var2)=False
 Next
 TeamRecord.Gold=False
 TeamRecord.Deleted=False
 TeamRecord.First=SFalse
 TeamRecord.Last=SFalse
 TeamRecord.First2=SFalse
 TeamRecord.Last2=SFalse
 TeamRecord.Prefix1=Nul
 For Var2!=1! To Lof(TeamInvFile)/MessWorkRecLen6
    Call Read.Record(TeamInvFile,Var2!)
    If MessWorkRecord6.User=Temp5! Then
       MessWorkRecord6.Room=SFalse
       MessWorkRecord6.User=SFalse
       MessWorkRecord6.Index=SFalse
       MessWorkRecord6.Charges=False
       MessWorkRecord6.Plus=False
       MessWorkRecord6.Prev=SFalse
       MessWorkRecord6.Next=SFalse
       Call Write.Record(TeamInvFile,Var2!)
    Endif
 Next
 Call Write.Record(TeamFile,Temp5!)
 UserRecord.ObjectsCreated(6)=UserRecord.ObjectsCreated(6)+1#
 If User.Index Then
    Call Write.Record(UserFile,User.Index)
 Endif
ErrExit88:
 Exit Sub
ErrResume88:
 Resume ErrExit88
End Sub

Sub Delete.Team
 On Local Error Goto ErrResume89
 Temp5!=Lof(TeamFile)/TeamRecLen
 Strng="Enter team number to delete"
 Call Get.Record.Range2(1!,Temp5!,Temp!)
 If Temp!>SFalse And Temp!<=Temp5! Then
    Call Read.Record(TeamFile,Temp!)
    If TeamRecord.Deleted Then
       Strng="Team already deleted."
       Call IO.O
       Exit Sub
    Endif
    Strng="Delete team"+Str$(Temp!)+"(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If Yes Then
       TeamRecord.Deleted=True
       Call Write.Record(TeamFile,Temp!)
       Strng="Team"+Str$(Temp!)+" deleted."
    Else
       Strng="Team not deleted."
    Endif
    Call IO.O
 Endif
ErrExit89:
 Exit Sub
ErrResume89:
 Resume ErrExit89
End Sub

Sub Undelete.Team
 On Local Error Goto ErrResume90
 Temp5!=Lof(TeamFile)/TeamRecLen
 Strng="Enter team number to delete"
 Call Get.Record.Range2(1!,Temp5!,Temp!)
 If Temp!>SFalse And Temp!<=Temp5! Then
    Call Read.Record(TeamFile,Temp!)
    If TeamRecord.Deleted=False Then
       Strng="Team not deleted."
       Call IO.O
       Exit Sub
    Endif
    Strng="Undelete team"+Str$(Temp!)+"(y/n)? "
    Line.Length=TempD
    No.Input.Out="N"
    Call IO.I
    If Yes Then
       TeamRecord.Deleted=False
       Call Write.Record(TeamFile,Temp!)
       Strng="Team"+Str$(Temp!)+" undeleted."
    Else
       Strng="Team not undeleted."
    Endif
    Call IO.O
 Endif
ErrExit90:
 Exit Sub
ErrResume90:
 Resume ErrExit90
End Sub

Sub Find.Team
 On Local Error Goto ErrResume91
 Temp5!=SFalse
 Graphics.Off=False
 Strng="Team name, or number"
 Strng=Strng+"(1-"+Mid$(Str$(Lof(TeamFile)/TeamRecLen),2)+")? "
 No.Input.Out="1"
 Call IO.I
 Temp7!=SFalse
 Out2=Lcase$(Out2)
 If Instr(Out2,"#") Then
    Temp7!=Val(Mid$(Out2,Instr(Out2,"#")+1))
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempX!=SFalse
 No.Input=False
 For Var2!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var2!)
    Strng=Lcase$(Rtrim$(TeamRecord.Name))
    Var3$=Out2
    Call InstrSUB4(VarX,Var3$,0)
    If VarX Then
       TempX!=TempX!+1!
       If Temp7!=SFalse Or TempX!=Temp7! Then
          No.Input=True
          Exit For
       Endif
    Endif
 Next
 If No.Input=False Then
    Var2!=Int(Val(Out2)+.5)
    If Var2!>SFalse And Var2!<=Lof(TeamFile)/TeamRecLen Then
       No.Input=True
    Endif
 Endif
 If No.Input=False Then
    Var2!=SFalse
    Strng="Team name not found."
    Call IO.O
    Goto Exit91
 Endif
 Call Read.Record(TeamFile,Var2!)
 If TeamRecord.Deleted Then
    Var2!=SFalse
    Strng="Deleted team record."
    Call IO.O
    Goto Exit91
 Endif
 Out3=TeamRecord.Name
 If Left$(Out3,9)=Deleted$ Then
    Var2!=SFalse
    Strng="Deleted team record."
    Call IO.O
    Goto Exit91
 Endif
 If Rtrim$(Out3)=Nul Then
    Var2!=SFalse
    Strng="Empty team record."
    Call IO.O
    Goto Exit91
 Endif
Exit91:
 Temp5!=Var2!
ErrExit91:
 Exit Sub
ErrResume91:
 Resume ErrExit91
End Sub

Sub Change.Team
 On Local Error Goto ErrResume92
 Do While Lost.Carrier=False
    Call Display.Team
    Graphics.Off=False
    Strng="Team change option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(323,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Enter team name? "
          Call IO.I
          TeamRecord.Name=Ucase$(Out2)
       Endif
    Case "B"
       If RT$(324,"[B]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Hidden=True
          Line.Length=20
          Strng="Enter team password? "
          Call IO.I
          Hidden=False
          If Len(Out2)>=3 Then
             Out3=Ucase$(Out2)
             Call Cryptograph(Out3)
             Hidden=True
             Line.Length=20
             Strng="Enter team password again? "
             Call IO.I
             Hidden=False
             If Len(Out2)>=3 Then
                Out2=Ucase$(Out2)
                Call Cryptograph(Out2)
                If Out2<>Out3 Then
                   Strng="Passwords don't match!"
                   Call IO.O
                Else
                   TeamRecord.Pass=Out2
                   Strng="Team password changed."
                   Call IO.O
                Endif
             Endif
          Endif
       Endif
    Case "C"
       If RT$(325,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Enter team Gold? "
          Call IO.I
          TeamRecord.Gold=Int(Val(Out2)+.5)
       Endif
    Case "D"
       If RT$(326,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
       Do While Lost.Carrier=False
          Graphics.Off=True
          VarZ1!=SFalse
          VarZ2!=SFalse
          Var2!=TeamRecord.First
          If Var2! Then
             Do While Lost.Carrier=False
                Call Read.Record(TeamInvFile,Var2!)
                Var3!=MessWorkRecord6.Next
                Temp!=MessWorkRecord6.Index
                If Temp!<SFalse Then
                   VarZ1!=VarZ1!+1!
                Else
                   VarZ2!=VarZ2!+1!
                Endif
                If Var3!=SFalse Then
                   Exit Do
                Endif
                Var2!=Var3!
             Loop
          Endif
          Strng=RT$(332,"[T]")+"reasure ("+Mid$(Str$(VarZ2!),2)+")"
          Call IO.O
          Strng=RT$(333,"[O]")+"bjects ("+Mid$(Str$(VarZ1!),2)+")"
          Call IO.O
          VarZ!=SFalse
          Var4!=TeamRecord.First2
          If Var4! Then
             Do While Lost.Carrier=False
                Call Read.Record(ContainerFile,Var4!)
                Var6!=ContainerRecord.Next
                If ContainerRecord.WithinContainer=SFalse Then
                   If ContainerRecord.DeletedContainer=False Then
                      VarZ!=VarZ!+1!
                   Endif
                Endif
                If Var6!=SFalse Then
                   Exit Do
                Endif
                Var4!=Var6!
             Loop
          Endif
          Strng=RT$(334,"[C]")+"ontainers ("+Mid$(Str$(VarZ!),2)+")"
          Call IO.O
          Graphics.Off=False
          Strng="Team inventory edit option(q to quit)? "
          Line.Length=TempD
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "T"
             If RT$(332,"[T]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
             Do
                If TempC=False Then
                   Graphics.Off=False
                   Strng="Team treasure inventory edit options:"
                   Call IO.O
                   Graphics.Off=True
                   Strng=RT$(335,"[A]")+"dd"
                   Call IO.O
                   Strng=RT$(336,"[D]")+"elete"
                   Call IO.O
                   Strng=RT$(337,"[L]")+"ist"
                   Call IO.O
                Endif
                Graphics.Off=False
                No.Input.Out="Q"
                Line.Length=TempD
                Strng="Enter inventory option(q to quit)? "
                Call IO.I
                Select Case Ucase$(Out2)
                Case "A"
                   If RT$(335,"[A]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      VarQ=False
                      Call Find.Treasure
                      If TreasureRecord.Container Then
                         TempC!=SFalse
                      Endif
                      If TempC! Then
                         Temp6=TreasureRecord.Charges
                      Else
                         Temp6=False
                      Endif
                      If TempC! Then
                         Temp2!=Lof(TeamInvFile)/MessWorkRecLen6+1!
                         MessWorkRecord6.Room=SFalse
                         MessWorkRecord6.User=Temp5!
                         MessWorkRecord6.Index=TempC!
                         MessWorkRecord6.Charges=Temp6
                         MessWorkRecord6.Plus=False
                         Call Add.List.Node4(Temp5!,Temp2!)
                         VarQ=True
                      Endif
                      If VarQ=True Then
                         Strng="Item added to inventory."
                      Else
                         Strng="Item not added to inventory."
                      Endif
                      Call IO.O
                   Endif
                Case "D"
                   If RT$(336,"[D]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      VarQ=False
                      Strng="Enter inventory number to delete? "
                      Call IO.I
                      TempX=False
                      Var!=Int(Val(Out2)+.5)
                      If Var!>SFalse And Var!<=Lof(TeamInvFile)/MessWorkRecLen6 Then
                         Temp7!=SFalse
                         Var2!=TeamRecord.First
                         If Var2! Then
                            Do While Lost.Carrier=False
                               Call Read.Record(TeamInvFile,Var2!)
                               Var3!=MessWorkRecord6.Next
                               Var4!=MessWorkRecord6.Index
                               If Var4!>SFalse Then
                                  Temp7!=Temp7!+1!
                                  If Temp7!=Var! Then
                                     TempX=True
                                     Exit Do
                                  Endif
                               Endif
                               If Var3!=SFalse Then
                                  Exit Do
                               Endif
                               Var2!=Var3!
                            Loop
                            If TempX Then
                               Call Delete.List.Node4(Var2!)
                               Call Clear.List.Node
                               Call Write.Record(TeamInvFile,Var2!)
                               VarQ=True
                            Endif
                         Endif
                      Endif
                      If VarQ=True Then
                         Strng="Item deleted from inventory."
                      Else
                         Strng="Item not deleted from inventory."
                      Endif
                      Call IO.O
                   Endif
                Case "L"
                   If RT$(337,"[L]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TempX=False
                      Graphics.Off=True
                      Temp7!=SFalse
                      Var2!=TeamRecord.First
                      If Var2! Then
                         Do While Lost.Carrier=False
                            Call Read.Record(TeamInvFile,Var2!)
                            Var3!=MessWorkRecord6.Next
                            Var!=MessWorkRecord6.Index
                            Out3=Nul
                            If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
                               Call Read.Record(TreasureFile,Var!)
                               Out3=Rtrim$(TreasureRecord.TreasureName)
                            Endif
                            If Len(Out3) Then
                               Out3=Lcase$(Out3)
                               Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
                               Temp7!=Temp7!+1!
                               Strng="["+Mid$(Str$(Temp7!),2)+"]"+Out3
                               Call IO.O
                               TempX=TempX+1
                               If TempX>=User.Pagelength-2 Then
                                  TempX=SFalse
                                  Call More.Prompt
                                  If No Or Quit Then
                                     Exit Do
                                  Endif
                               Endif
                            Endif
                            If Var3!=SFalse Then
                               Exit Do
                            Endif
                            Var2!=Var3!
                         Loop
                      Endif
                      If TempX Then
                         Call More.Prompt
                      Endif
                   Endif
                Case "Q"
                   Exit Do
                End Select
             Loop
             Endif
          Case "O"
             If RT$(333,"[O]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
             Do
                If TempC=False Then
                   Graphics.Off=False
                   Strng="Team object inventory edit options:"
                   Call IO.O
                   Graphics.Off=True
                   Strng=RT$(338,"[A]")+"dd"
                   Call IO.O
                   Strng=RT$(339,"[D]")+"elete"
                   Call IO.O
                   Strng=RT$(340,"[L]")+"ist"
                   Call IO.O
                Endif
                Graphics.Off=False
                Line.Length=TempD
                No.Input.Out="Q"
                Strng="Enter inventory option(q to quit)? "
                Call IO.I
                Select Case Ucase$(Out2)
                Case "A"
                   If RT$(338,"[A]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      VarQ=False
                      Call Find.Object
                      If TempD! Then
                         Temp2!=Lof(TeamInvFile)/MessWorkRecLen6+1!
                         MessWorkRecord6.Room=SFalse
                         MessWorkRecord6.User=Temp5!
                         MessWorkRecord6.Index=-TempD!
                         MessWorkRecord6.Charges=Temp6
                         MessWorkRecord6.Plus=False
                         Call Add.List.Node4(Temp5!,Temp2!)
                         VarQ=True
                      Endif
                      If VarQ=True Then
                         Strng="Item added to inventory."
                      Else
                         Strng="Item not added to inventory."
                      Endif
                      Call IO.O
                   Endif
                Case "D"
                   If RT$(339,"[A]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      VarQ=False
                      Strng="Enter inventory number to delete? "
                      Call IO.I
                      TempX=False
                      Var!=Int(Val(Out2)+.5)
                      If Var!>SFalse And Var!<=Lof(TeamInvFile)/MessWorkRecLen6 Then
                         Temp7!=SFalse
                         Var2!=TeamRecord.First
                         If Var2! Then
                            Do While Lost.Carrier=False
                               Call Read.Record(TeamInvFile,Var2!)
                               Var3!=MessWorkRecord6.Next
                               Var4!=MessWorkRecord6.Index
                               If Var4!<SFalse Then
                                  Temp7!=Temp7!+1!
                                  If Temp7!=Var! Then
                                     TempX=True
                                     Exit Do
                                  Endif
                               Endif
                               If Var3!=SFalse Then
                                  Exit Do
                               Endif
                               Var2!=Var3!
                            Loop
                            If TempX Then
                               Call Delete.List.Node4(Var2!)
                               Call Clear.List.Node
                               Call Write.Record(TeamInvFile,Var2!)
                               VarQ=True
                            Endif
                         Endif
                      Endif
                      If VarQ=True Then
                         Strng="Item deleted from inventory."
                      Else
                         Strng="Item not deleted from inventory."
                      Endif
                      Call IO.O
                   Endif
                Case "L"
                   If RT$(340,"[L]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      TempX=False
                      Graphics.Off=True
                      Temp7!=SFalse
                      Var2!=TeamRecord.First
                      If Var2! Then
                         Do While Lost.Carrier=False
                            Call Read.Record(TeamInvFile,Var2!)
                            Var3!=MessWorkRecord6.Next
                            Var!=MessWorkRecord6.Index
                            Out3=Nul
                            If Var!<SFalse Then
                               Var!=Abs(Var!)
                               If Var!>SFalse And Var!<=Lof(ObjectFile)/ObjectRecLen Then
                                  Call Read.Record(ObjectFile,Var!)
                                  Out3=Rtrim$(ObjectRecord.ObjectName)
                               Endif
                            Endif
                            If Len(Out3) Then
                               Out3=Lcase$(Out3)
                               Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
                               Temp7!=Temp7!+1!
                               Strng="["+Mid$(Str$(Temp7!),2)+"]"+Out3
                               Call IO.O
                               TempX=TempX+1
                               If TempX>=User.Pagelength-2 Then
                                  TempX=SFalse
                                  Call More.Prompt
                                  If No Or Quit Then
                                     Exit Do
                                  Endif
                               Endif
                            Endif
                            If Var3!=SFalse Then
                               Exit Do
                            Endif
                            Var2!=Var3!
                         Loop
                      Endif
                      If TempX Then
                         Call More.Prompt
                      Endif
                   Endif
                Case "Q"
                   Exit Do
                End Select
             Loop
             Endif
          Case "C"
             If RT$(334,"[C]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
             Do While Lost.Carrier=False
                If TempC=False Then
                   Graphics.Off=False
                   Strng="Team container inventory edit options:"
                   Call IO.O
                   Graphics.Off=True
                   Strng=RT$(341,"[A]")+"dd"
                   Call IO.O
                   Strng=RT$(342,"[D]")+"elete"
                   Call IO.O
                   Strng=RT$(343,"[L]")+"ist"
                   Call IO.O
                   Graphics.Off=False
                Endif
                Strng="Team container edit option(q to quit)? "
                Line.Length=TempD
                No.Input.Out="Q"
                Call IO.I
                Select Case Ucase$(Out2)
                Case "A"
                   If RT$(341,"[A]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      VarQ=False
                      Call Find.Treasure
                      If TempC! Then
                         If TreasureRecord.Container<>False Then
                            Call Add.Container.To.Team
                            VarQ=True
                         Endif
                      Endif
                      If VarQ=True Then
                         Strng="Container added to team."
                      Else
                         Strng="Container not added to team."
                      Endif
                      Call IO.O
                   Endif
                Case "D"
                   If RT$(342,"[D]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      Strng="Number to delete? "
                      No.Input.Out="0"
                      Call IO.I
                      VarQ=False
                      Temp2!=Int(Val(Out2)+.5)
                      TempX!=SFalse
                      If Temp!>=SFalse And Temp!<=Lof(ContainerFile)/ContainerRecLen Then
                         Var4!=TeamRecord.First2
                         If Var4! Then
                            Do While Lost.Carrier=False
                               Call Read.Record(ContainerFile,Var4!)
                               Var5!=ContainerRecord.Next
                               If ContainerRecord.WithinContainer=SFalse Then
                                  If ContainerRecord.DeletedContainer=False Then
                                     TempX!=TempX!+1!
                                     If TempX!=Temp2! Then
                                        Call Delete.Team.Container(Var4!)
                                        Call Clear.Container.Node
                                        Call Write.Record(ContainerFile,Var4!)
                                        VarQ=True
                                        Exit Do
                                     Endif
                                  Endif
                               Endif
                               If Var5!=SFalse Then
                                  Exit Do
                               Endif
                               Var4!=Var5!
                            Loop
                         Endif
                      Endif
                      If VarQ=True Then
                         Strng="Container deleted from team."
                      Else
                         Strng="Container not deleted from team."
                      Endif
                      Call IO.O
                   Endif
                Case "L"
                   If RT$(343,"[L]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      Graphics.Off=True
                      VarZ=False
                      Allow.Break=True
                      Break=False
                      Continuous=False
                      Temp!=TeamRecord.First2
                      TempX!=SFalse
                      If Temp! Then
                         Do While Lost.Carrier=False
                            Call Read.Record(ContainerFile,Temp!)
                            Var6!=ContainerRecord.Next
                            If ContainerRecord.WithinContainer=SFalse Then
                               If ContainerRecord.DeletedContainer=False Then
                                  Out3=ContainerRecord.ContainerName
                                  Out3=Rtrim$(Out3)
                                  Out3=Lcase$(Out3)
                                  TempX!=TempX!+1!
                                  Strng=Mid$(Str$(TempX!),2)+"."+Out3
                                  If ContainerRecord.InvisibleContainer Then
                                     Strng=Strng+"[inv]"
                                  Endif
                                  Call IO.O
                                  If Break Then
                                     Exit Do
                                  Endif
                                  VarZ=VarZ+1
                                  If VarZ>=User.Pagelength-2 Then
                                     VarZ=False
                                     If Continuous=False Then
                                        Call More.Prompt
                                        If No Or Quit Then
                                           Exit Do
                                        Endif
                                     Endif
                                  Endif
                               Endif
                            Endif
                            If Var6!=SFalse Then
                               Exit Do
                            Endif
                            Temp!=Var6!
                         Loop
                      Endif
                      Allow.Break=False
                      If VarZ Then
                         Call More.Prompt
                      Endif
                   Endif
                Case "Q"
                   Exit Do
                End Select
             Loop
             Endif
          Case "Q"
             Exit Do
          End Select
       Loop
       Endif
    Case "1" To "5"
       Temp2=Int(Val(Out2)+.5)
       If RT$(326+Temp2,"[?]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Find.User(-1)
          If TempD! Then
             Out3=UserRecord2.CodeName
             If Left$(Out3,9)=Deleted$ Then
                Strng="Deleted user record."
                Call IO.O
             Else
                TeamRecord.Member(Temp2)=Ucase$(Out3)
                TeamRecord.UserIndex(Temp2)=TempD!
                TeamRecord.Activated(Temp2)=True
             Endif
          Else
             TeamRecord.Member(Temp2)=Nul
             TeamRecord.UserIndex(Temp2)=SFalse
             TeamRecord.Activated(Temp2)=False
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Call Write.Record(TeamFile,Temp5!)
 Strng="Team"+Str$(Temp5!)+" changed."
 Call IO.O
ErrExit92:
 Exit Sub
ErrResume92:
 Resume ErrExit92
End Sub

Sub List.Teams
 On Local Error Goto ErrResume93
 Temp3!=Lof(TeamFile)/TeamRecLen
 Call Get.Record.Range(Temp!,Temp2!,Temp3!)
 Allow.Break=True
 Break=False
 Continuous=False
 For Temp5!=Temp! To Temp2!
    Call Read.Record(TeamFile,Temp5!)
    For VarQ=1 To 5
       Call Show.Team(VarQ)
       If Break Then
          Exit For
       Endif
    Next
    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
 Break=False
ErrExit93:
 Exit Sub
ErrResume93:
 Resume ErrExit93
End Sub

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

Sub Pack.Teams
 On Local Error Goto ErrResume94
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't pack while node/user online."
    Call IO.O
    Exit Sub
 Endif
 Strng="Delete "+Dead$+" users from teams(y/n)? "
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 TempY=Yes
 Strng="Delete users from teams before date(y/n)? "
 Line.Length=TempD
 No.Input.Out="N"
 Call IO.I
 TempZ=Yes
 If TempZ Then
    Strng="Enter date(form: MM-DD-YYYY)? "
    No.Input.Out="01-01-1980"
    Call IO.I
    TempQ=ValidDate(Out2)
    If TempQ Then
       Temp#=Int(DateValue(Out2))
    Endif
 Endif
 If TempY Or TempZ Then
    Graphics.Off=True
    Carriage.Return=True
    Strng="Making backup of team file"
    Call IO.O
    FileName=Left$(Team.FileName,Instr(Team.FileName,"."))+"bak"
    Close #TempFile1
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TempFile1 Len=TeamRecLen
    VarD=False
    VarE=False
    VarF!=Timeit!
    For Temp3!=1! To Lof(TeamFile)/TeamRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TeamFile,Temp3!)
       Call Write.TempFile(3,Temp3!)
    Next
    Call IO.O
    Graphics.Off=True
    Carriage.Return=True
    Strng="Copying team file"
    Call IO.O
    FileName=Team.FileName
    Close #TeamFile
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    VarD=False
    VarE=False
    VarF!=Timeit!
    Open FileName For Random Shared As #TeamFile Len=TeamRecLen
    VarQ!=SFalse
    For Temp3!=1! To Lof(TempFile1)/TeamRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.TempFile(3,Temp3!)
       For Var=1 To MaxTeamMembers
          Var2!=TeamRecord.UserIndex(Var)
          Temp1$=TeamRecord.Member(Var)
          Temp1$=Rtrim$(Temp1$)
          Temp1$=Lcase$(Temp1$)
          Temp=False
          If Var2!<>SFalse And Temp1$<>Nul Then
             If Var2!>SFalse And Var2!<=Lof(UserFile2)/UserRecLen Then
                Temp=False
             Else
                Temp=True
             Endif
             If Temp=False Then
                Call Read.Record(UserFile2,Var2!)
                Call New.Stats
                Out3=UserRecord2.CodeName
                Out3=Rtrim$(Out3)
                Out3=Lcase$(Out3)
                If TempY Then
                   If Out3<>Temp1$ Then
                      Temp=True
                   Endif
                   If Left$(Out3,9)=Deleted$ Then
                      Temp=True
                   Endif
                   If UserRecord2.Level=False Then
                      Temp=True
                   Endif
                Endif
                If TempZ Then
                   Out2=UserRecord2.DateOn
                   TempQ=ValidDate(Out2)
                   If TempQ Then
                      If Int(DateValue(Out2))<Temp# Then
                         Temp=True
                      Endif
                   Endif
                Endif
             Endif
          Endif
          If Temp Then
             VarQ!=VarQ!+1!
             TeamRecord.Member(Var)=Nul
             TeamRecord.UserIndex(Var)=False
          Endif
       Next
       Call Write.Record(TeamFile,Temp3!)
    Next
    Call IO.O
 Endif
 Strng="Delete empty teams & pack team/inventory file(y/n)? "
 Graphics.Off=False
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 TempX=Yes
 If TempX Then
    Call Repair.Teams(False)
    Graphics.Off=True
    Carriage.Return=True
    Strng="Making backup of team file"
    Call IO.O
    FileName=Left$(Team.FileName,Instr(Team.FileName,"."))+"bak"
    Close #TempFile1
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TempFile1 Len=TeamRecLen
    VarD=False
    VarE=False
    VarF!=Timeit!
    For Temp3!=1! To Lof(TeamFile)/TeamRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TeamFile,Temp3!)
       Call Write.TempFile(3,Temp3!)
    Next
    Call IO.O
    Graphics.Off=True
    Carriage.Return=True
    Strng="Making backup of team inventory file"
    Call IO.O
    FileName=Left$(TeamInv.FileName,Instr(TeamInv.FileName,"."))+"bak"
    Close #TempFile2
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    VarD=False
    VarE=False
    VarF!=Timeit!
    Open FileName For Random Shared As #TempFile2 Len=MessWorkRecLen6
    For Temp3!=1! To Lof(TeamInvFile)/MessWorkRecLen6
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.Record(TeamInvFile,Temp3!)
       Call Write.TempFile(9,Temp3!)
    Next
    Call IO.O
    Graphics.Off=False
    Strng="Packing teams.."
    Call IO.O
    Graphics.Off=True
    FileName=Team.FileName
    Close #TeamFile
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TeamFile Len=TeamRecLen
    FileName=TeamInv.FileName
    Close #TeamInvFile
    If Dir$(FileName)<>Nul Then
       Kill FileName
    Endif
    Open FileName For Random Shared As #TeamInvFile Len=MessWorkRecLen6
    Graphics.Off=True
    Carriage.Return=True
    Strng="Teams deleted"
    Call IO.O
    VarD=False
    VarE=False
    VarF!=Timeit!
    Temp1!=SFalse
    VarX!=SFalse
    For Temp3!=1! To Lof(TempFile1)/TeamRecLen
       Call Dot.Display(VarD,VarE,VarF!)
       Call Read.TempFile(3,Temp3!)
       Temp1$=TeamRecord.Name
       Temp1$=Rtrim$(Temp1$)
       Temp1$=Lcase$(Temp1$)
       If Temp1$=Deleted$ Or Temp1$=Nul Or TeamRecord.Deleted Then
          Var=True
       Else
          Var=False
       Endif
       If Var=False Then
          Var=True
          For Var3=1 To MaxTeamMembers
             VarQ!=TeamRecord.UserIndex(Var3)
             If VarQ!>SFalse And VarQ!<=Lof(UserFile2)/UserRecLen Then
                Var=False
                Exit For
             Endif
          Next
       Endif
       If Var Then
          VarX!=VarX!+1!
       Else
          Temp1!=Temp1!+1!
          TeamRecord.First=SFalse
          TeamRecord.Last=SFalse
          Call Write.Record(TeamFile,Temp1!)
          For VarZ!=1! To Lof(TempFile2)/MessWorkRecLen6
             Call Read.TempFile(9,VarZ!)
             If MessWorkRecord6.User=Temp3! Then
                Var4=False
                Var5!=MessWorkRecord6.Index
                If Var5!>SFalse And Var5!<=Lof(TreasureFile)/TreasureRecLen Then
                   Var4=True
                Else
                   If Var5!<SFalse Then
                      Var5!=Abs(Var5!)
                      If Var5!>SFalse And _
                      Var5!<=Lof(ObjectFile)/ObjectRecLen Then
                         Var4=True
                      Endif
                   Endif
                Endif
                If Var4 Then
                   MessWorkRecord6.User=Temp1!
                   VarY!=Lof(TeamInvFile)/MessWorkRecLen6+1!
                   Call Add.List.Node4(Temp1!,VarY!)
                Endif
             Endif
          Next
       Endif
    Next
    Call IO.O
 Endif
 If TempX=False And TempY=False And TempZ=False Then
    Strng="Team file not packed."
 Else
    Strng="Team file packed."
 Endif
 Graphics.Off=False
 Call IO.O
 Call More.Prompt
ErrExit94:
 Exit Sub
ErrResume94:
 Resume ErrExit94
End Sub

Sub Repair.Teams(VarK)
 On Local Error Goto ErrResume65a
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't repair while node/user online."
    Call IO.O
    Exit Sub
 Endif
 If VarK Then
    Strng="Repair team inventory file(y/n)? "
    Line.Length=TempD
    No.Input.Out="Y"
    Call IO.I
    If No Then
       Exit Sub
    Endif
 Endif
 Carriage.Return=True
 Graphics.Off=True
 Strng="Making backup of team inventory file"
 Call IO.O
 Close #TempFile1
 FileName=Data.Path1+"TEAMINV2.BAK"
 If Dir$(FileName)<>Nul Then
    Kill FileName
 Endif
 VarD=False
 VarE=False
 VarF!=Timeit!
 Open FileName For Random Shared As #TempFile1 Len=MessWorkRecLen6
 For Temp5!=1! To Lof(TeamInvFile)/MessWorkRecLen6
    Call Read.Record(TeamInvFile,Temp5!)
    Call Write.TempFile(7,Temp5!)
    Call Dot.Display(VarD,VarE,VarF!)
 Next
 Call IO.O
 Carriage.Return=True
 Graphics.Off=True
 Strng="Repairing team inventory file"
 Call IO.O
 VarD=False
 VarE=False
 VarF!=Timeit!
 Var4!=SFalse
 VarZ1!=SFalse
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.First
    Temp3!=TeamRecord.Last
    If Temp2!>SFalse And Temp3!>SFalse Then
       If Temp2!=Temp3! Then
          Call Read.Record(TeamInvFile,Temp2!)
          If MessWorkRecord6.Prev<>SFalse Or MessWorkRecord6.Next<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Prev=SFalse
             MessWorkRecord6.Next=SFalse
             Call Write.Record(TeamInvFile,Temp2!)
          Endif
       Else
          Call Read.Record(TeamInvFile,Temp2!)
          If MessWorkRecord6.Prev<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Prev=SFalse
             Call Write.Record(TeamInvFile,Temp2!)
          Endif
          Call Read.Record(TeamInvFile,Temp3!)
          If MessWorkRecord6.Next<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Next=SFalse
             Call Write.Record(TeamInvFile,Temp3!)
          Endif
       Endif
    Endif
 Next
 VarZ2!=SFalse
 Close #TempFile1
 FileName=GetFilename$("TABLE","BK3")
 Open FileName For Random Shared As #TempFile1 Len=4
 Field #TempFile1,4 As S$
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    VarY1!=0!
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.First
    If Temp2! Then
       Do
          Call Read.Record(TeamInvFile,Temp2!)
          VarY1!=VarY1!+1!
          Lset S$=Mks$(Temp2!)
          Put #TempFile1,VarY1!
          Temp6!=MessWorkRecord6.Next
          If Temp6!>SFalse Then
             Call Read.Record(TeamInvFile,Temp6!)
             For Temp7!=1! To VarY1!
                Get #TempFile1,Temp7!
                Temp8!=Cvs(S$)
                If Temp6!=Temp8! Then
                   Gosub Truncate1
                   Exit Do
                Endif
             Next
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    VarY1!=0!
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.Last
    If Temp2! Then
       Do
          Call Read.Record(TeamInvFile,Temp2!)
          VarY1!=VarY1!+1!
          Lset S$=Mks$(Temp2!)
          Put #TempFile1,VarY1!
          Temp6!=MessWorkRecord6.Prev
          If Temp6!>SFalse Then
             Call Read.Record(TeamInvFile,Temp6!)
             For Temp7!=1! To VarY1!
                Get #TempFile1,Temp7!
                Temp8!=Cvs(S$)
                If Temp6!=Temp8! Then
                   Gosub Truncate2
                   Exit Do
                Endif
             Next
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 Close #TempFile1
 Kill Filename
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.First
    If Temp2! Then
       Do
          Call Read.Record(TeamInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Next
          If Temp6!>SFalse Then
             Call Read.Record(TeamInvFile,Temp6!)
             If Temp2!<>MessWorkRecord6.Prev Then
                Gosub Truncate1
                Exit Do
             Endif
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.Last
    If Temp2! Then
       Do
          Call Read.Record(TeamInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Prev
          If Temp6!>SFalse Then
             Call Read.Record(TeamInvFile,Temp6!)
             If Temp2!<>MessWorkRecord6.Next Then
                Gosub Truncate2
                Exit Do
             Endif
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 VarZ3!=SFalse
 For Temp1!=1! To Lof(TeamFile)/TeamRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(TeamFile,Temp1!)
    Temp2!=TeamRecord.First
    If Temp2! Then
       Do
          Call Read.Record(TeamInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Next
          Temp3!=MessWorkRecord6.User
          If Temp3!<>Temp1! Then
             VarZ3!=VarZ3!+1!
             MessWorkRecord6.User=Temp1!
             Call Write.Record(TeamInvFile,Temp2!)
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 Call IO.O
 Graphics.Off=False
 Strng="Team inventory file repaired."
 Call IO.O
 Strng="Reset"+Str$(VarZ1!)+" nodes."
 Call IO.O
 Strng="Deleted"+Str$(VarZ2!)+" nodes."
 Call IO.O
 Strng="Repaired"+Str$(VarZ3!)+" nodes."
 Call IO.O
 Call More.Prompt
 Exit Sub
Truncate1:
 VarZ2!=VarZ2!+1!
 Call Read.Record(TeamInvFile,Temp2!)
 MessWorkRecord6.Next=SFalse
 Call Write.Record(TeamInvFile,Temp2!)
 TeamRecord.Last=Temp2!
 Call Write.Record(TeamFile,Temp1!)
 Return
Truncate2:
 VarZ2!=VarZ2!+1!
 Call Read.Record(TeamInvFile,Temp2!)
 MessWorkRecord6.Prev=SFalse
 Call Write.Record(TeamInvFile,Temp2!)
 TeamRecord.First=Temp2!
 Call Write.Record(TeamFile,Temp1!)
 Return
ErrExit65a:
 Exit Sub
ErrResume65a:
 Resume ErrExit65a
End Sub

Sub Search.Teams
 On Local Error Goto ErrResume95
 Do While Lost.Carrier=False
    Temp1$=Nul
    Temp2$=Nul
    Temp3$=Nul
    Temp4$=Nul
    Temp1#=DFalse
    Temp2#=DFalse
    Do While Lost.Carrier=False
       Graphics.Off=True
       If TempC=False Then
          Strng="[A]team name substring"
          If Temp1$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+Temp1$+")"
          Endif
          Call IO.O
          Strng="[B]team password"
          If Temp2$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+String$(10,Mask$)+")"
          Endif
          Call IO.O
          Strng="[C]gold range"
          If Temp1#>=DFalse And Temp2#>DFalse Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+Mid$(Str$(Temp1#),2)+"-"+ _
             Mid$(Str$(Temp2#),2)+")"
          Endif
          Call IO.O
          Strng="[D]inventory substring"
          If Temp3$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+Temp3$+")"
          Endif
          Call IO.O
          Strng="[E]team username substring"
          If Temp4$<>Nul Then
             Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+Temp4$+")"
          Endif
          Call IO.O
          Graphics.Off=False
       Endif
       Strng="Team search option(S to search, Q to quit)? "
       Line.Length=TempD
       No.Input.Out="Q"
       Call IO.I
       Select Case Ucase$(Out2)
       Case "A"
          Strng="Team name substring? "
          Call IO.I
          Out2=Ucase$(Out2)
          Temp1$=Out2
       Case "B"
          Strng="Team password? "
          Hidden=True
          Line.Length=20
          Call IO.I
          Hidden=False
          Out2=Ucase$(Out2)
          Call Cryptograph(Out2)
          Temp2$=Rtrim$(Out2)
       Case "C"
          Strng="Enter range:"
          Call IO.O
          No.Input.Out="1"
          Strng="From? "
          Call IO.I
          Temp1#=Int(Val(Out2)+.5)
          No.Input.Out="10"
          Strng="To? "
          Call IO.I
          Temp2#=Int(Val(Out2)+.5)
       Case "D"
          Strng="Inventory substring? "
          Call IO.I
          Out2=Lcase$(Out2)
          Temp3$=Out2
       Case "E"
          Strng="Team username substring? "
          Call IO.I
          Out2=Ucase$(Out2)
          Temp4$=Out2
       Case "S"
          Temp5!=Lof(TeamFile)/TeamRecLen
          Call Get.Record.Range(Temp!,Temp2!,Temp5!)
          Allow.Break=True
          Break=False
          Continuous=False
          VarZ1!=0!
          VarZ2!=0!
          If Temp1$<>Nul Then
             VarZ=Instr(Temp1$,"#")
             If VarZ Then
                VarZ2!=Int(Val(Mid$(Temp1$,VarZ+1))+.5)
                Temp1$=Left$(Temp1$,VarZ-1)
             Endif
          Endif
          VarZ5!=0!
          VarZ6!=0!
          If Temp3$<>Nul Then
             VarZ=Instr(Temp3$,"#")
             If VarZ Then
                VarZ6!=Int(Val(Mid$(Temp3$,VarZ+1))+.5)
                Temp3$=Left$(Temp3$,VarZ-1)
             Endif
          Endif
          VarZ7!=0!
          VarZ8!=0!
          If Temp4$<>Nul Then
             VarZ=Instr(Temp4$,"#")
             If VarZ Then
                VarZ8!=Int(Val(Mid$(Temp4$,VarZ+1))+.5)
                Temp4$=Left$(Temp4$,VarZ-1)
             Endif
          Endif
          For Temp5!=Temp! To Temp2!
             Call Read.Record(TeamFile,Temp5!)
             TempX=False
             If Temp1$<>Nul Then
                Out3=Rtrim$(TeamRecord.Name)
                Call InstrSUB(VarX,Out3,Temp1$)
                If VarX Then
                   VarZ1!=VarZ1!+1!
                   If VarZ2!=0! Or VarZ1!=VarZ2! Then
                      TempX=True
                   Endif
                Endif
             Endif
             If Temp2$<>Nul Then
                Out3=Rtrim$(TeamRecord.Pass)
                If Out3=Temp2$ Then
                   TempX=True
                Endif
             Endif
             If Temp1#>=DFalse And Temp2#>DFalse Then
                If TeamRecord.Gold>=Temp1# And TeamRecord.Gold<=Temp2# Then
                   TempX=True
                Endif
             Endif
             If Temp3$<>Nul Then
                Var!=TeamRecord.First
                If Var! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(TeamInvFile,Var!)
                      Var3!=MessWorkRecord6.Next
                      Out3=Nul
                      Var2!=MessWorkRecord6.Index
                      If Var2!>SFalse And Var2!<=Lof(TreasureFile)/TreasureRecLen Then
                         Call Read.Record(TreasureFile,Var2!)
                         Out3=Rtrim$(TreasureRecord.TreasureName)
                      Else
                         If Var2!<SFalse Then
                            Var2!=Abs(Var2!)
                            If Var2!>SFalse And _
                            Var2!<=Lof(ObjectFile)/ObjectRecLen Then
                               Call Read.Record(ObjectFile,Var2!)
                               Out3=Rtrim$(ObjectRecord.ObjectName)
                            Endif
                         Endif
                      Endif
                      If Len(Out3) Then
                         Call InstrSUB(VarX,Out3,Temp3$)
                         If VarX Then
                            VarZ5!=VarZ5!+1!
                            If VarZ6!=0! Or VarZ5!=VarZ6! Then
                               TempX=True
                            Endif
                         Endif
                         If TempX Then
                            Exit Do
                         Endif
                      Endif
                      If Var3!=SFalse Then
                         Exit DO
                      Endif
                      Var!=Var3!
                   Loop
                Endif
             Endif
             If Temp4$<>Nul Then
                For Var=1 To MaxTeamMembers
                   Out3=Rtrim$(TeamRecord.Member(Var))
                   Call InstrSUB(VarX,Out3,Temp4$)
                   If VarX Then
                      VarZ7!=VarZ7!+1!
                      If VarZ8!=0! Or VarZ7!=VarZ8! Then
                         TempX=True
                      Endif
                   Endif
                   If TempX Then
                      Exit For
                   Endif
                Next
             Endif
             If TempX Then
                Out3=Rtrim$(TeamRecord.Name)
                Out3=Lcase$(Out3)
                If Left$(Out3,9)<>Deleted$ Then
                   For VarQ=1 To 5
                      Call Show.Team(VarQ)
                      If Break Then
                         Exit For
                      Endif
                   Next
                   If Break Then
                      Exit For
                   Endif
                   If Continuous=False Then
                      Call More.Prompt
                      If No Or Quit Then
                         Exit For
                      Endif
                   Endif
                Endif
             Endif
          Next
          Allow.Break=False
          Break=False
          Exit Do
       Case "Q"
          Exit Sub
       End Select
    Loop
 Loop
ErrExit95:
 Exit Sub
ErrResume95:
 Resume ErrExit95
End Sub

Sub Show.Team(Var)
 On Local Error Goto ErrResume96
 If Temp5!=SFalse Then
    Exit Sub
 Endif
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="Team number:"+Str$(Temp5!)+"."
 Call IO.O
 Graphics.Off=True
 Case 2
 Strng=Rtrim$(TeamRecord.Name)
 Strng=Lcase$(Strng)
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 If Strng=Nul Then
    Strng=Deleted$
 Endif
 Call Capitalize(Strng)
 If Left$(Strng,9)<>Deleted$ Then
    If TeamRecord.Deleted Then
       Strng=Strng+" (deleted)"
    Endif
 Endif
 Strng="Team name: "+Strng
 Call IO.O
 Case 3
 Strng="Team Gold:"+Str$(TeamRecord.Gold)
 Call IO.O
 Case 4
 Strng="Team inventory:"
 Temp3!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Temp3!=Temp3!+1!
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Var2!=TeamRecord.First2
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var2!)
       Var3!=MessWorkRecord6.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Temp3!=Temp3!+1!
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Strng=Strng+Str$(Temp3!)+" item"
 If Temp3!=1! Then
    Eat$=Nul
 Else
    Strng=Strng+"s"
 Endif
 Strng=Strng+"."
 Call IO.O
 Case 5
 Strng="Team Members:"
 Call IO.O
 For VarY=1 To MaxTeamMembers
    Strng=Rtrim$(TeamRecord.Member(VarY))
    Strng=Lcase$(Strng)
    If Strng<>Nul Then
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
       VarQ!=TeamRecord.UserIndex(VarY)
       If VarQ!>SFalse And VarQ!<=Lof(UserFile2)/UserRecLen Then
          Call Read.Record(UserFile2,VarQ!)
          Out3=UserRecord2.CodeName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          If Left$(Out3,9)=Deleted$ Then
             Strng=Strng+" (deleted)."
          Else
             Strng=Strng+" (level "+Form$(Cdbl(UserRecord2.Level))+")."
          Endif
          Strng=Mid$(Str$(VarY),2)+". "+Strng
          Call IO.O
          If Break Then
             Exit For
          Endif
       Endif
    Endif
 Next
 End Select
ErrExit96:
 Exit Sub
ErrResume96:
 Resume ErrExit96
End Sub

Sub Print.Team(Var)
 On Local Error Goto ErrResume96a
 If Temp5!=SFalse Then
    Exit Sub
 Endif
 Select Case Var
 Case 1
 Strng="Team number:"+Str$(Temp5!)+"."
 Print #TempFile1,Strng
 Case 2
 Strng=Rtrim$(TeamRecord.Name)
 Strng=Lcase$(Strng)
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Call Capitalize(Strng)
 If Strng=Nul Then
    Strng=Deleted$
 Endif
 If Left$(Strng,9)<>Deleted$ Then
    If TeamRecord.Deleted Then
       Strng=Strng+" (deleted)"
    Endif
 Endif
 Strng="Team name: "+Strng
 Print #TempFile1,Strng
 Case 3
 Strng="Team Gold:"+Str$(TeamRecord.Gold)
 Print #TempFile1,Strng
 Case 4
 Strng="Team inventory:"
 Temp3!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Temp3!=Temp3!+1!
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Var2!=TeamRecord.First2
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var2!)
       Var3!=MessWorkRecord6.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Temp3!=Temp3!+1!
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Strng=Strng+Str$(Temp3!)+" items."
 Print #TempFile1,Strng
 Case 5
 Strng="Team Members:"
 Print #TempFile1,Strng
 For VarY=1 To MaxTeamMembers
    Strng=Rtrim$(TeamRecord.Member(VarY))
    Strng=Lcase$(Strng)
    If Strng<>Nul Then
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
       VarQ!=TeamRecord.UserIndex(VarY)
       If VarQ!>SFalse And VarQ!<=Lof(UserFile2)/UserRecLen Then
          Call Read.Record(UserFile2,VarQ!)
          Out3=UserRecord2.CodeName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          If Left$(Out3,9)=Deleted$ Then
             Strng=Strng+" (deleted)."
          Else
             Strng=Strng+" (level "+Form$(Cdbl(UserRecord2.Level))+")."
          Endif
          Strng=Mid$(Str$(VarY),2)+". "+Strng
          Print #TempFile1,Strng
       Endif
    Endif
 Next
 End Select
ErrExit96a:
 Exit Sub
ErrResume96a:
 Resume ErrExit96a
End Sub

Sub Display.Team
 On Local Error Goto ErrResume97
 If TempC Then
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Team number:"+Str$(Temp5!)+"."
 Call IO.O
 Graphics.Off=True
 Out2=TeamRecord.Name
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Call Capitalize(Out2$)
 If TeamRecord.Deleted Then
    Out2=Out2+" (deleted)"
 Endif
 Strng=RT$(323,"[A]")+"Team name: "+Out2
 Call IO.O
 Strng=RT$(324,"[B]")+"Team password: "+String$(10,Mask$)
 Call IO.O
 Strng=RT$(325,"[C]")+"Team Gold:"+Str$(TeamRecord.Gold)
 Call IO.O
 Strng=RT$(326,"[D]")+"Team inventory:"
 Temp3!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Temp3!=Temp3!+1!
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Var2!=TeamRecord.First2
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var2!)
       Var3!=MessWorkRecord6.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Temp3!=Temp3!+1!
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 Strng=Strng+Str$(Temp3!)+" items."
 Call IO.O
 Strng="Team member list:
 Call IO.O
 For Var=1 To MaxTeamMembers
    Strng=RT$(326+Var,"["+Mid$(Str$(Var),2)+"]")
    Out2=Rtrim$(TeamRecord.Member(Var))
    If Len(Out2) Then
       Out2=Lcase$(Out2)
       Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
       ' get user level
       VarQ!=TeamRecord.UserIndex(Var)
       If VarQ!>SFalse And VarQ!<=Lof(UserFile2)/UserRecLen Then
          Call Read.Record(UserFile2,VarQ!)
          If Left$(Out3,9)=Deleted$ Then
             Out2=Out2+" (deleted)."
          Else
             Out2=Out2+" (level "+Form$(Cdbl(UserRecord2.Level))+")."
          Endif
       Endif
    Else
       Out2="<empty>"
    Endif
    Strng=Strng+Out2
    Call IO.O
 Next
ErrExit97:
 Exit Sub
ErrResume97:
 Resume ErrExit97
End Sub

Sub Add.List.Node4(VarY!,VarZ!)
 On Local Error Goto ErrorTrp27b
 If TeamRecord.First=SFalse Then
    TeamRecord.First=VarZ!
    TeamRecord.Last=VarZ!
    Call Write.Record(TeamFile,VarY!)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(TeamInvFile,VarZ!)
    Exit Sub
 Endif
 MessWorkRecord6.Prev=TeamRecord.Last
 MessWorkRecord6.Next=SFalse
 Call Write.Record(TeamInvFile,VarZ!)
 Call Read.Record(TeamInvFile,TeamRecord.Last)
 MessWorkRecord6.Next=VarZ!
 Call Write.Record(TeamInvFile,TeamRecord.Last)
 Call Read.Record(TeamInvFile,VarZ!)
 TeamRecord.Last=VarZ!
 Call Write.Record(TeamFile,VarY!)
ErrorRsm27b:
 Exit Sub
ErrorTrp27b:
 Resume ErrorRsm27b
End Sub

Sub Delete.List.Node4(VarZ!)
 On Local Error Goto ErrorTrp32a
 If TeamRecord.First=VarZ! Then
    Call Read.Record(TeamInvFile,VarZ!)
    TeamRecord.First=MessWorkRecord6.Next
    Call Write.Record(TeamFile,Temp5!)
    If TeamRecord.First>SFalse Then
       Call Read.Record(TeamInvFile,TeamRecord.First)
       MessWorkRecord6.Prev=SFalse
       Call Write.Record(TeamInvFile,TeamRecord.First)
    Endif
 Else
    If TeamRecord.Last=VarZ! Then
       Call Read.Record(TeamInvFile,VarZ!)
       TeamRecord.Last=MessWorkRecord6.Prev
       Call Write.Record(TeamFile,Temp5!)
       If TeamRecord.Last>SFalse Then
          Call Read.Record(TeamInvFile,TeamRecord.Last)
          MessWorkRecord6.Next=SFalse
          Call Write.Record(TeamInvFile,TeamRecord.Last)
       Endif
    Else
       Call Read.Record(TeamInvFile,VarZ!)
       Previous.Node!=MessWorkRecord6.Prev
       Next.Node!=MessWorkRecord6.Next
       Call Read.Record(TeamInvFile,Previous.Node!)
       MessWorkRecord6.Next=Next.Node!
       Call Write.Record(TeamInvFile,Previous.Node!)
       Call Read.Record(TeamInvFile,Next.Node!)
       MessWorkRecord6.Prev=Previous.Node!
       Call Write.Record(TeamInvFile,Next.Node!)
    Endif
 Endif
ErrorRsm32a:
 Exit Sub
ErrorTrp32a:
 Resume ErrorRsm32a
End Sub

Sub Top.Ten.Teams
 On Local Error Goto ErrTrap10
 Allow.Break=False
 Break=False
 Graphics.Off=False
 Strng="Top ten teams. "
 If Local.Mode Then
    Var$="Press <ctrl-break>/<ctrl-c> to interrupt."
 Else
    Var$="Press <control-c>/<control-k> to interrupt."
 Endif
 Strng=Strng+Var$
 Call IO.O
 Graphics.Off=True
 TempX!=Lof(TeamFile)/TeamRecLen
 If TempX!=SFalse Then
    Strng="No teams exist."
    Call IO.O
    Exit Sub
 Endif
 Close #TempFile1
 FileName=DND.Path+"SORT4"+NodeX+".SWP"
 Open FileName For Random Shared As #TempFile1 Len=12
 Field #TempFile1,4 As U$,8 As Z$
 Allow.Break=True
 Break=False
 Do While Lost.Carrier=False
    Allow.Break=True
    Strng="DNDBBS v"+Version$+" r"+Release$+" Top Ten Team Rankings For "+Fclock$+"."
    Call IO.O
    If Break Then
       Exit Do
    Endif
    Strng=Nul
    Call IO.O
    If Break Then
       Exit Do
    Endif
    TempZ!=SFalse
    For Var1!=1! To TempX!
       Call Read.Record(TeamFile,Var1!)
       Strng=Rtrim$(TeamRecord.Name)
       Strng=Lcase$(Strng)
       If Len(Strng) And TeamRecord.Deleted=False Then
          TempQ=False
          TempA#=DFalse
          For Var2=1 To MaxTeamMembers
             Temp2$=Rtrim$(TeamRecord.Member(Var2))
             If Len(Temp2$) Then
                VarY!=TeamRecord.UserIndex(Var2)
                If VarY!>SFalse And VarY!<=Lof(UserFile2)/UserRecLen Then
                   Call Read.Record(UserFile2,VarY!)
                   Strng=UserRecord2.CodeName
                   If Left$(Strng,9)<>Deleted$ Then
                      TempQ=True
                      If UserRecord2.Level>=1 Then
                         TempA#=TempA#+Cdbl(UserRecord2.PermanentKilled*UserRecord2.Level*10)+ _
                         Cdbl(UserRecord2.PlayersKilled*UserRecord2.Level*2)+ _
                         Cdbl(UserRecord2.MonstersKilled*UserRecord2.Level)
                      Endif
                   Endif
                Endif
             Endif
          Next
          If TempQ Then
             If TempA#>DFalse Then
                TempZ!=TempZ!+1!
                Lset U$=Mks$(Var1!)
                Lset Z$=Mkd$(TempA#)
                Put #TempFile1,TempZ!
             Endif
          Endif
       Endif
    Next
    If TempZ!>SFalse Then
       For VarS1!=1! To TempZ!
          For VarS2!=VarS1!+1! To TempZ!
             Get #TempFile1,VarS1!
             TempZ1!=Cvs(U$)
             TempX1#=Cvd(Z$)
             Get #TempFile1,VarS2!
             TempZ2!=Cvs(U$)
             TempX2#=Cvd(Z$)
             If TempX1#<TempX2# Then
                Lset U$=Mks$(TempZ1!)
                Lset Z$=Mkd$(TempX1#)
                Put #TempFile1,VarS2!
                Lset U$=Mks$(TempZ2!)
                Lset Z$=Mkd$(TempX2#)
                Put #TempFile1,VarS1!
             Endif
          Next
       Next
    Endif
    If TempZ!>10! Then
       TempZ!=10!
    Endif
    If User.LineLength=40 Then
       Strng="Teamname                       Members"
       Call IO.O
       Strng="Gold               Ranking"
       Call IO.O
       Call Display.Line(38)
    Else
       Strng="Teamname                       Members Gold               Ranking"
       Call IO.O
       Call Display.Line(65)
    Endif
    If Break Then
       Exit Do
    Endif
    TempX=False
    For Temp1!=1! To TempZ!
       Get #TempFile1,Temp1!
       TempX!=Cvs(U$)
       TempZ#=Cvd(Z$)
       Call Read.Record(TeamFile,TempX!)
       Strng=TeamRecord.Name
       Strng=Rtrim$(Strng)
       Strng=Lcase$(Strng)
       Call Capitalize(Strng)
       Strng=Left$(Strng,30)
       VarQ=31-Len(Strng)
       If Rtrim$(Strng)<>Nul Then
          Strng=Rtrim$(TeamRecord.Prefix1)+Strng
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
	  Call IO.O
          Graphics.On=False
          TempQ=False
          For Temp2=1 To MaxTeamMembers
             VarY!=TeamRecord.UserIndex(Temp2)
             If VarY!>SFalse And VarY!<=Lof(UserFile2)/UserRecLen Then
                Call Read.Record(UserFile2,VarY!)
                Var2$=UserRecord2.CodeName
                If Left$(Var2$,9)<>Deleted$ Then
                   TempQ=TempQ+1
                Endif
             Endif
          Next
          Strng=Space$(VarQ)
          Strng=Strng+Mid$(Str$(TempQ),2)
          If User.LineLength=40 Then
             Call IO.O
          Else
             Strng=Strng+Space$(8-Len(Str$(TempQ)))
          Endif
          Temp#=TeamRecord.Gold
          Strng=Strng+Str$(Temp#)
          Strng=Strng+Space$(19-Len(Str$(Temp#)))
          Strng=Strng+Str$(TempZ#)
          TempX=True
          Call IO.O
          If Break Then
             Exit Do
          Endif
       Endif
    Next
    Exit Do
 Loop
 Allow.Break=False
 Break=False
 If TempX=False Then
    Strng="No teams have top scores."
    Call IO.O
 Endif
 Call More.Prompt
 Close #TempFile1
 If Dir$(FileName)<>"" Then
    Kill FileName
 Endif
ErrResume10:
 Exit Sub
ErrTrap10:
 Resume ErrResume10
End Sub

Sub New.Stats
 On Local Error Goto ErrResume99
 Temp#=Cdbl(Training.Stats(UserRecord2.ClassType,1))*Cdbl(UserRecord2.Level)
 If Temp#>MaxInt Then
    Temp#=MaxInt
 Endif
 UserRecord2.Fatigue=Cint(Temp#)
 UserRecord2.FatigueMax=Cint(Temp#)
 Temp#=Cdbl(Training.Stats(UserRecord2.ClassType,2))*Cdbl(UserRecord2.Level)
 If Temp#>MaxInt Then
    Temp#=MaxInt
 Endif
 UserRecord2.Vitality=Cint(Temp#)
 UserRecord2.VitalityMax=Cint(Temp#)
 Temp#=Cdbl(Training.Stats(UserRecord2.ClassType,3))*Cdbl(UserRecord2.Level)
 If Temp#>MaxInt Then
    Temp#=MaxInt
 Endif
 UserRecord2.Magic=Cint(Temp#)
 UserRecord2.MagicMax=Cint(Temp#)
 Temp#=Cdbl(Training.Stats(UserRecord2.ClassType,4))*Cdbl(UserRecord2.Level)
 If Temp#>MaxInt Then
    Temp#=MaxInt
 Endif
 UserRecord2.Psionic=Cint(Temp#)
 UserRecord2.PsionicMax=Cint(Temp#)
 If UserRecord2.Fatigue<False Or _
 UserRecord2.Fatigue>UserRecord2.FatigueMax Then
    UserRecord2.Fatigue=UserRecord2.FatigueMax
 Endif
 If UserRecord2.Vitality<False Or _
 UserRecord2.Vitality>UserRecord2.VitalityMax Then
    UserRecord2.Vitality=UserRecord2.VitalityMax
 Endif
 If UserRecord2.Magic<False Or _
 UserRecord2.Magic>UserRecord2.MagicMax Then
    UserRecord2.Magic=UserRecord2.MagicMax
 Endif
 If UserRecord2.Psionic<False Or _
 UserRecord2.Psionic>UserRecord2.PsionicMax Then
    UserRecord2.Psionic=UserRecord2.PsionicMax
 Endif
 If Allow.High.Class Then
    If UserRecord2.Level>=10 Then
       If UserRecord2.ClassType>=1 And UserRecord2.ClassType<=10 Then
          Out2=High.Class.Name(UserRecord2.ClassType)
          Call Valid(Out2,20)
          If Out2=Nul Then
             Strng="Illegal characters in high classname."
             Call IO.O
          Else
             UserRecord2.ClassName=Out2
          Endif
       Endif
    Endif
 Endif
ErrExit99:
 Exit Sub
ErrResume99:
 Resume ErrExit99
End Sub

Sub Delete.Team.Container(VarZ!)
 On Local Error Goto ErrorTrp32d
 If TeamRecord.First2=VarZ! Then
    Call Read.Record(ContainerFile,VarZ!)
    TeamRecord.First2=ContainerRecord.Next
    Call Write.Record(TeamFile,Temp5!)
    If TeamRecord.First2>SFalse Then
       Call Read.Record(ContainerFile,TeamRecord.First2)
       ContainerRecord.Prev=SFalse
       Call Write.Record(ContainerFile,TeamRecord.First2)
    Endif
 Else
    If TeamRecord.Last2=VarZ! Then
       Call Read.Record(ContainerFile,VarZ!)
       TeamRecord.Last2=ContainerRecord.Prev
       Call Write.Record(TeamFile,Temp5!)
       If TeamRecord.Last2>SFalse Then
          Call Read.Record(ContainerFile,TeamRecord.Last2)
          ContainerRecord.Next=SFalse
          Call Write.Record(ContainerFile,TeamRecord.Last2)
       Endif
    Else
       Call Read.Record(ContainerFile,VarZ!)
       Previous.Node!=ContainerRecord.Prev
       Next.Node!=ContainerRecord.Next
       Call Read.Record(ContainerFile,Previous.Node!)
       ContainerRecord.Next=Next.Node!
       Call Write.Record(ContainerFile,Previous.Node!)
       Call Read.Record(ContainerFile,Next.Node!)
       ContainerRecord.Prev=Previous.Node!
       Call Write.Record(ContainerFile,Next.Node!)
    Endif
 Endif
ErrorRsm32d:
 Exit Sub
ErrorTrp32d:
 Resume ErrorRsm32d
End Sub

' add container to team.dat list
Sub Add.Container.To.Team
 On Local Error Goto ErrResume141f
 VarA!=Lof(ContainerFile)/ContainerRecLen+1!
 Call Clear.Container
 ContainerRecord.ContainerName=TreasureRecord.TreasureName
 ContainerRecord.ContainerShort=TreasureRecord.ShortName
 ContainerRecord.ContainerMax=TreasureRecord.ContainerMax
 ContainerRecord.NamePrefix=TreasureRecord.ContainerPrefix
 ContainerRecord.Prefix1=TreasureRecord.Prefix1
 ContainerRecord.Size=TreasureRecord.ContainerSize
 ContainerRecord.Material=TreasureRecord.ContainerMaterial
 Strng="Invisible container(y/n)? "
 No.Input.Out="N"
 Call IO.I
 ContainerRecord.InvisibleContainer=Yes
 If TreasureRecord.KeyNumber Then
    ContainerRecord.KeyNumber=TreasureRecord.KeyNumber
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 If TreasureRecord.Locked Then
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 ContainerRecord.RoomNumber=0!
 ContainerRecord.UserNumber=Temp5!
 ContainerRecord.WithinContainer=SFalse
 ContainerRecord.Weight=TreasureRecord.Weight
 ContainerRecord.ContainerIndex=TempC!
 ContainerRecord.Disappears=TreasureRecord.ContainerDisappears
 ContainerRecord.SelfImplodes=TreasureRecord.ContainerSelfImplodes
 ContainerRecord.Permanent=TreasureRecord.Permanent
 ContainerRecord.First=SFalse
 ContainerRecord.Last=SFalse
 ContainerRecord.SwapFlag=SFalse
 ContainerRecord.Scanned=False
 Call Write.Record(ContainerFile,VarA!)
 If TeamRecord.First2=SFalse Then
    TeamRecord.First2=VarA!
    TeamRecord.Last2=VarA!
    Call Write.Record(TeamFile,Temp5!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
 Else
    ContainerRecord.Prev=TeamRecord.Last2
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
    Call Read.Record(ContainerFile,TeamRecord.Last2)
    ContainerRecord.Next=VarA!
    Call Write.Record(ContainerFile,TeamRecord.Last2)
    Call Read.Record(ContainerFile,VarA!)
    TeamRecord.Last2=VarA!
    Call Write.Record(TeamFile,Temp5!)
 Endif
ErrExit141f:
 Exit Sub
ErrResume141f:
 Resume ErrExit141f
End Sub

Sub Clear.Container.Node
 On Local Error Goto ErrorTrp32c
 ContainerRecord.UserNumber=SFalse
 ContainerRecord.RoomNumber=SFalse
 ContainerRecord.DeletedContainer=True
 ContainerRecord.Prev=SFalse
 ContainerRecord.Next=SFalse
ErrorRsm32c:
 Exit Sub
ErrorTrp32c:
 Resume ErrorRsm32c
End Sub

Sub Display.Line(VarX)
 On Local Error Goto ErrTrap11
 Strng=String$(VarX,"-")
 Var=User.LineLength
 If Var>False Then
    If VarX>Var Then
       Var=Var-2
       If Var>False Then
          Strng=String$(Var,"-")
       Else
          Strng=Nul
       Endif
    Endif
 Endif
 If Len(Strng) Then
    Call IO.O
 Endif
ErrResume11:
 Exit Sub
ErrTrap11:
 Resume ErrResume11
End Sub

