 Rem File: DndeditH for Dndbbs Version v5.0a Release r2.0 Tweak t5.0a
 Rem Sub: EditPlayer
 Rem $Include: 'dndedit.inc'

 On Error Goto Main.Error
 Call Stdin(Var)
 If Chained2=0 Then
    Call Init.Arrays
    Call Read.Rows(Var2)
    Max.Row=Var2
    Call Save.Screen(False)
    Call Clear.Screen2
    Call Init.Mouse
    Call Read.Config(False)
    Call Passwrd5(Var,"h")
    Close #TempFile1
    If Var=False Then
       Call Terminate.Program(True)
       End
    Endif
 Endif
Main.Resume:
 Call EditPlayer
 If Chained2 Then
    Chain DND.Path+"DNDEDIT.EXE"
 Endif
 Call Terminate.Program(True)
 End
Main.Error:
 Resume Main.Resume

Sub EditPlayer
 On Local Error Goto Error.Trap232
 Team.Number=1!
 Out3="Sysop Player Team Edit"
 Call DisplayEditScreen(11,10,Out3)
 Call PlayerStatusLine
 Call DisplayPlayer
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseButton(10)
          If Len(TempX$) Then
             Exit Do
          Endif
       Endif
       If Mouse.Row Or Mouse.Column Then
          Call MouseSelect(10)
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 65 To 90 ' A to Z
          Call SearchTeamPrefix(TempX)
       Case 97 To 122 ' a to z
          Call SearchTeamPrefix(TempX)
       Case 1 ' ^a
          Call AddPlayer
          Call PlayerStatusLine
          Call RedisplayField
       Case 4 ' ^d
          TeamRecord.Deleted=True
          Call Write.Record(TeamFile,Team.Number)
          Out3="Sysop Player Team Edit"
          Call DisplayEditScreen(11,10,Out3)
          Call PlayerStatusLine
          Call DisplayPlayer
       Case 21 ' ^u
          TeamRecord.Deleted=False
          Call Write.Record(TeamFile,Team.Number)
          Out3="Sysop Player Team Edit"
          Call DisplayEditScreen(11,10,Out3)
          Call PlayerStatusLine
          Call DisplayPlayer
       Case 8
          Call Help(13)
          Out3="Sysop Player Team Edit"
          Call DisplayEditScreen(11,10,Out3)
          Call PlayerStatusLine
          Call DisplayPlayer
       Case 7 ' ^g
          Call EditTeamContainers
          Call PlayerStatusLine
       Case 13
          Call PlayerEdit
          Call Write.Record(TeamFile,Team.Number)
          Call PlayerStatusLine
          TempX=Selection
          Call ShowPlayer
          Call RedisplayField
       Case 14
          Call NextPlayer
       Case 15 ' ^o
          Call EditTeamObject
          Call PlayerStatusLine
       Case 17
          Call PreviousPlayer
       Case 18
          Call SelectNextPlayer
          Call PlayerStatusLine
          Call RedisplayField
       Case 20 ' ^t
          Call EditTeamTreasure
          Call PlayerStatusLine
       Case 23
          Call SearchPlayer
       Case 27
          Call Write.Record(TeamFile,Team.Number)
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       If TempX=0 Then
          Call Write.Record(TeamFile,Team.Number)
          Exit Do
       Endif
       Call PlayerSelect
    End Select
 Loop
Error.Resume232:
 Exit Sub
Error.Trap232:
 Resume Error.Resume232
End Sub

Sub PlayerStatusLine
 On Local Error Goto Error.Trap232a
 Strng="^ Cursor Select "+Chr$(60)+Chr$(217)
 Strng=Strng+" Enter Choice <esc> Exit ^h Help ^a Add ^n Next ^q Prev"
 Out2="^r Select ^w Search ^o Objects ^t Treasure ^g Containers ^d Delete ^u Undelete"
 Call StatusLine
Error.Resume232a:
 Exit Sub
Error.Trap232a:
 Resume Error.Resume232a
End Sub

Sub DisplayPlayer
 On Local Error Goto Error.Trap232b
 Call Read.Record(TeamFile,Team.Number)
 For TempX=0 To 10
    Call ShowPlayer
 Next
 Call RedisplayField
Error.Resume232b:
 Exit Sub
Error.Trap232b:
 Resume Error.Resume232b
End Sub

Sub ShowPlayer
 On Local Error Goto Error.Trap232c
 Select Case TempX
 Case 0
    Call ANSI(4,33,44)
    Call ANSI(2,2,2)
    Strng="Team"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,7)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,7)
    Strng=Mid$(Str$(Team.Number),2)
    Call Scrn(Strng)
    Team.Treasure=SFalse
    Team.Objects=SFalse
    Temp2!=TeamRecord.First
    If Temp2! Then
       Do While Lost.Carrier=False
          Call Read.Record(TeamInvFile,Temp2!)
          If MessWorkRecord6.User=SFalse Then
             Exit Do
          Endif
          Temp6!=MessWorkRecord6.Next
          If MessWorkRecord6.Index>SFalse Then
             Team.Treasure=Team.Treasure+1!
          Endif
          If MessWorkRecord6.Index<SFalse Then
             Team.Objects=Team.Objects+1!
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
    Team.Containers=SFalse
    Temp2!=TeamRecord.First2
    If Temp2! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp2!)
          Temp6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Team.Containers=Team.Containers+1!
             Endif
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
    Call ANSI(4,33,44)
    Call ANSI(2,2,16)
    Strng="Treasure"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,25)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,25)
    Strng=Mid$(Str$(Team.Treasure),2)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,34)
    Strng="Objects"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,42)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,42)
    Strng=Mid$(Str$(Team.Objects),2)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,51)
    Strng="Containers"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,62)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,62)
    Strng=Mid$(Str$(Team.Containers),2)
    Call Scrn(Strng)
 Case 1
    Call ANSI(4,37,40)
    Call ANSI(2,4,12)
    Strng=Space$(30)
    Call Scrn(Strng)
    Call ANSI(2,4,12)
    Strng=Rtrim$(TeamRecord.Name)
    Strng=Lcase$(Strng)
    If Len(Strng) Then
       Call Capitalize(Strng)
    Endif
    If Strng=Nul Then
       Strng=Deleted$
    Endif
    If Left$(Strng,9)<>Deleted$ Then
       If TeamRecord.Deleted Then
          Strng=Strng+" (deleted)"
       Endif
    Endif
    Call Scrn(Strng)
 Case 2
    Call ANSI(4,37,40)
    Call ANSI(2,6,11)
    Strng=Space$(20)
    Call Scrn(Strng)
    Call ANSI(2,6,11)
    Strng=String$(20,Mask$)
    Call Scrn(Strng)
 Case 3
    Call ANSI(4,37,40)
    Call ANSI(2,8,10)
    Strng=Space$(3)
    Call Scrn(Strng)
    Call ANSI(2,8,10)
    If TeamRecord.Deleted Then
       Strng="Yes"
    Else
       Strng="No "
    Endif
    Call Scrn(Strng)
 Case 4 To 8
    Var=TempX-4
    Select Case Var
    Case 0
       Var2=10
    Case 1
       Var2=12
    Case 2
       Var2=14
    Case 3
       Var2=16
    Case 4
       Var2=18
    End Select
    Call ANSI(4,33,44)
    Call ANSI(2,Var2,42)
    Strng=Space$(9)
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,Var2,11)
    Strng=Space$(30)
    Call Scrn(Strng)
    Call ANSI(2,Var2,11)
    Var3=TempX-3
    Strng=Rtrim$(TeamRecord.Member(Var3))
    Strng=Lcase$(Strng)
    If Strng<>Nul Then
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
       VarQ!=TeamRecord.UserIndex(Var3)
       If VarQ!>SFalse And VarQ!<=Lof(UserFile)/UserRecLen Then
          Call Scrn(Strng)
          Call Read.Record(UserFile,VarQ!)
          Out3=UserRecord.CodeName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          If Left$(Out3,9)=Deleted$ Then
             Call ANSI(4,33,44)
             Call ANSI(2,Var2,42)
             Strng="(deleted)"
             Call Scrn(Strng)
          Endif
       Endif
    Endif
 Case 9
    Call ANSI(4,37,40)
    Call ANSI(2,20,12)
    Strng=Space$(22)
    Call Scrn(Strng)
    Call ANSI(2,20,12)
    Strng=Mid$(Str$(TeamRecord.Gold),2)
    Call Scrn(Strng)
 Case 10
    Call ANSI(4,37,40)
    Call ANSI(2,8,21)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,8,21)
    Strng=Rtrim$(TeamRecord.Prefix1)
    Call Scrn(Strng)
 End Select
Error.Resume232c:
 Exit Sub
Error.Trap232c:
 Resume Error.Resume232c
End Sub

Sub Capitalize(Var3$)
 On Local Error Goto ErrorTrap24x4
 Var3$=Rtrim$(Ltrim$(Var3$))
 If Var3$=Nul Then
    Exit Sub
 Endif
 Mid$(Var3$,1,1)=Ucase$(Mid$(Var3$,1,1))
 Var=Instr(Var3$," ")
 If Var<Len(Var3$) Then
    Do While Var
       Mid$(Var3$,Var+1,1)=Ucase$(Mid$(Var3$,Var+1,1))
       Var=Instr(Var+1,Var3$," ")
    Loop
 Endif
 Exit Sub
ErrorResume24x4:
 Exit Sub
ErrorTrap24x4:
 Resume ErrorResume24x4
End Sub

Sub AddPlayer
 On Local Error Goto Error.Trap232d
 Team.Number=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=Team.Number 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,Team.Number)
 Call DisplayPlayer
 UserRecord.ObjectsCreated(6)=UserRecord.ObjectsCreated(6)+1#
 If User.Index Then
    Call Write.Record(UserFile,User.Index)
 Endif
Error.Resume232d:
 Exit Sub
Error.Trap232d:
 Resume Error.Resume232d
End Sub

Sub SelectNextPlayer
 On Local Error Goto Error.Trap232e
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field "
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Team: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,14)
 Strng=Space$(6)
 Call Scrn(Strng)
 Call ANSI(4,37,44)
 Call ANSI(2,23,23)
 Strng="(1-"+Mid$(Str$(Lof(TeamFile)/TeamRecLen),2)+")"
 Multiplier=Len(Strng)+23
 Strng=Strng+" (+/-/x)"
 Call Scrn(Strng)
 Restore DataMess1
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Multiplier=False
 Var2!=Int(Val(Edit.Data(1))+.5)
 If Var2!>SFalse And Var2!<=Lof(TeamFile)/TeamRecLen Then
    Call Write.Record(TeamFile,Team.Number)
    Team.Number=Var2!
    Call DisplayPlayer
    Exit Sub
 Endif
 Strng="The value is not within the existing team numbers."
 Call ErrorMessage
Error.Resume232e:
 Exit Sub
Error.Trap232e:
 Resume Error.Resume232e
End Sub

Sub NextPlayer
 On Local Error Goto Error.Trap232g
 If Team.Number!+1!>Lof(TeamFile)/TeamRecLen Then
    Strng="This is the last team in the team file."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(TeamFile,Team.Number)
 Team.Number=Team.Number+1!
 Call DisplayPlayer
Error.Resume232g:
 Exit Sub
Error.Trap232g:
 Resume Error.Resume232g
End Sub

Sub PreviousPlayer
 On Local Error Goto Error.Trap232h
 If Team.Number=1! Then
    Strng="This is the first team in the team file."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(TeamFile,Team.Number)
 Team.Number=Team.Number-1!
 Call DisplayPlayer
Error.Resume232h:
 Exit Sub
Error.Trap232h:
 Resume Error.Resume232h
End Sub

Sub PlayerEdit
 On Local Error Goto Error.Trap232i
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field"
 Call StatusLine
 Restore PlayerEditData
 For TempX=1 To Selection
    Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
 Next
 Select Case Selection
 Case 1
    Strng=Rtrim$(TeamRecord.Name)
    Strng=Lcase$(Strng)
    If Len(Strng) Then
       Call Capitalize(Strng)
    Endif
    Edit.Data(1)=Strng
 Case 2
    Hidden=True
    Strng=Nul
    Edit.Data(1)=Nul
 Case 3
    If TeamRecord.Deleted Then
       Edit.Data(1)="Yes"
    Else
       Edit.Data(1)="No "
    Endif
 Case 4 To 8
    Var=Selection-3
    Strng=Rtrim$(TeamRecord.Member(Var))
    Strng=Lcase$(Strng)
    If Len(Strng) Then
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
    Endif
    Edit.Data(1)=Strng
 Case 9
    Edit.Data(1)=Mid$(Str$(TeamRecord.Gold),2)
 Case 10
    Edit.Data(1)=Rtrim$(TeamRecord.Prefix1)
 End Select
 Call ScreenEdit
 Select Case Selection
 Case 1
    TeamRecord.Name=Ucase$(Edit.Data(1))
 Case 2
    Hidden=False
    Out3=Ucase$(Edit.Data(1))
    Call Cryptograph(Out3)
    TeamRecord.Pass=Out3
 Case 3
    If Ucase$(Edit.Data(1))="Y" Then
       TeamRecord.Deleted=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TeamRecord.Deleted=False
    Endif
    If Ucase$(Edit.Data(1))="YES" Then
       TeamRecord.Deleted=True
    Endif
    If Ucase$(Edit.Data(1))="NO" Then
       TeamRecord.Deleted=False
    Endif
 Case 4 To 8
    Temp2=Int(Val(Edit.Data(1))+.5)
    Out2=Ucase$(Edit.Data(1))
    Call FindPlayer
    If TempD! Then
       Call Read.Record(UserFile,TempD!)
       Out3=Rtrim$(UserRecord.CodeName)
       Out3=Lcase$(Out3)
       Temp2=False
       Call Write.Record(TeamFile,Team.Number)
       For Var2!=1! To Lof(TeamFile)/TeamRecLen
          Call Read.Record(TeamFile,Var2!)
          If TeamRecord.Deleted=False Then
             For Var3=1 To MaxTeamMembers
                Var$=Rtrim$(TeamRecord.Member(Var3))
                Var$=Lcase$(Var$)
                If Len(Var$) Then
                   If Left$(Var$,Len(Out3))=Out3 Then
                      If Var2!<>Team.Number Then
                         Temp2=True
                         Exit For
                      Else
                         If Var2!=Team.Number Then
                            If Var3<>Selection-3 Then
                               Temp2=True
                               Exit For
                            Endif
                         Endif
                      Endif
                   Endif
                Endif
             Next
          Endif
          If Temp2 Then
             Exit For
          Endif
       Next
       Call Read.Record(TeamFile,Team.Number)
       If Temp2 Then
          Out2="That player exists in team#"+Mid$(Str$(Var2!),2)+"."
          Call ErrorStatusLine
          Exit Sub
       Else
          TeamRecord.Member(Selection-3)=Ucase$(Out3)
          TeamRecord.UserIndex(Selection-3)=TempD!
       Endif
    Else
       If Out2=Nul Then
          TeamRecord.Member(Selection-3)=Nul
          TeamRecord.UserIndex(Selection-3)=SFalse
       Endif
    Endif
 Case 9
    TeamRecord.Gold=Int(Val(Edit.Data(1))+.5)
 Case 10
    TeamRecord.Prefix1=Ucase$(Rtrim$(Edit.Data(1)))
 End Select
Error.Resume232i:
 Exit Sub
Error.Trap232i:
 Resume Error.Resume232i
End Sub

Sub SearchTeamPrefix(VarQ)
 On Local Error Goto Error.Trap107x
 Call Write.Record(TeamFile,Team.Number)
 VarQ$=Nul
 If VarQ>=65 And VarQ<=90 Then
    VarQ$=Chr$(VarQ)
 Endif
 If VarQ>=97 And VarQ<=122 Then
    VarQ$=Ucase$(Chr$(VarQ))
 Endif
 If Len(VarQ$) Then
    VarX = 0
    For Var2!=Team.Number + 1! To Lof(TeamFile)/TeamRecLen
       Call Read.Record(TeamFile,Var2!)
       Strng=Rtrim$(TeamRecord.Name)
       Strng=Ucase$(Strng)
       If Len(Strng) Then
          If Left$(Strng,1)=VarQ$ Then
             VarX = -1
             Team.Number=Var2!
             Exit For
          Endif
          If Left$(Strng, 4) = "THE " Then
             Strng=Mid$(Strng, 5)
             If Left$(Strng,1)=VarQ$ Then
                VarX = -1
                Team.Number=Var2!
                Exit For
             Endif
          Endif
       Endif
    Next
    If VarX = 0 Then
       For Var2!=1! To Team.Number
          Call Read.Record(TeamFile,Var2!)
          Strng=Rtrim$(TeamRecord.Name)
          Strng=Ucase$(Strng)
          If Len(Strng) Then
             If Left$(Strng,1)=VarQ$ Then
                VarX = -1
                Team.Number=Var2!
                Exit For
             Endif
             If Left$(Strng, 4) = "THE " Then
                Strng=Mid$(Strng, 5)
                If Left$(Strng,1)=VarQ$ Then
                   VarX = -1
                   Team.Number=Var2!
                   Exit For
                Endif
             Endif
          Endif
       Next
    Endif
 Endif
 Call DisplayPlayer
Error.Resume107x:
 Exit Sub
Error.Trap107x:
 Resume Error.Resume107x
End Sub

Sub SearchPlayer
 On Local Error Goto Error.Trap232j
 Call Write.Record(TeamFile,Team.Number)
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for specific team"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Team or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,24)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore DataPlayer4
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Call PlayerStatusLine
 Var2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Ucase$(Edit.Data(1))
 If Var2!>SFalse And Var2!<=Lof(TeamFile)/TeamRecLen Then
    Team.Number=Var2!
    Call DisplayPlayer
    Exit Sub
 Endif
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 Temp!=SFalse
 Temp3!=SFalse
 For Var2!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var2!)
    Strng=Rtrim$(TeamRecord.Name)
    Call InstrSUB(TempX,Strng,Temp$)
    If TempX Then
       Temp3!=Temp3!+1!
       If Temp3!=1! Then
          Temp!=Var2!
       Endif
       If Temp.Index Then
          If Temp3!=Temp.Index Then
             Team.Number=Var2!
             Call DisplayPlayer
             Exit Sub
          Endif
       Endif
    Endif
 Next
 If Temp.Index>SFalse Then
    Strng="The team name was not found in the team file."
    Call ErrorMessage
    Call DisplayPlayer
    Exit Sub
 Endif
 If Temp3!=SFalse Then
    Strng="The team name was not found in the team file."
    Call ErrorMessage
    Call DisplayPlayer
    Exit Sub
 Endif
 If Temp3!=1! Then
    Team.Number=Temp!
    Call DisplayPlayer
    Exit Sub
 Endif
 Strng="There was more than one team found."
 Call ErrorMessage
 Strng="^ Scroll Team  "+Chr$(60)+Chr$(217)+" Select Team ("+Ltrim$(Str$(Temp3!))+" found)."
 Out2=Nul
 Call StatusLine
 Team.Number=Temp!
 Var2!=Temp!
 Call DisplayPlayer
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       If TempX$=Chr$(13) Then
          Team.Number=Var2!
          Call PlayerStatusLine
          Call DisplayPlayer
          Exit Sub
       Endif
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          VarA=False
          For Var3!=Var2!-1! To 1! Step -1!
             Call Read.Record(TeamFile,Var3!)
             Strng=Rtrim$(TeamRecord.Name)
             Call InstrSUB(TempX,Strng,Temp$)
             If TempX Then
                VarA=True
                Var2!=Var3!
                Team.Number=Var3!
                Call DisplayPlayer
                Exit For
             Endif
          Next
          If VarA=False Then
             Strng="This is the first team in the search."
             Call ErrorMessage
          Endif
       Case 80, 145, 160
          VarA=False
          For Var3!=Var2!+1! To Lof(TeamFile)/TeamRecLen
             Call Read.Record(TeamFile,Var3!)
             Strng=Rtrim$(TeamRecord.Name)
             Call InstrSUB(TempX,Strng,Temp$)
             If TempX Then
                VarA=True
                Var2!=Var3!
                Team.Number=Var3!
                Call DisplayPlayer
                Exit For
             Endif
          Next
          If VarA=False Then
             Strng="This is the last team in the search."
             Call ErrorMessage
          Endif
       End Select
    End Select
 Loop
Error.Resume232j:
 Exit Sub
Error.Trap232j:
 Resume Error.Resume232j
End Sub

Sub PlayerSelect
 On Local Error Goto Error.Trap232k
 Next.Field=False
 If TempX$=Chr$(9) Then
    TempX=77
 Endif
 Select Case TempX
 Case 77, 157, 116
    Select Case Selection
    Case 3
       Next.Field=10
    End Select
 Case 15, 75, 155, 115
    Select Case Selection
    Case 10
       Next.Field=3
    End Select
 Case 72, 141, 152
    Select Case Selection
    Case 2 To 9
       Next.Field=Selection-1
    End Select
 Case 80, 145, 160
    Select Case Selection
    Case 1 To 8
       Next.Field=Selection+1
    End Select
 Case 71, 119
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 79, 117
    If Selection<>9 Then
       Next.Field=9
    Endif
 Case 73, 132
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 81, 118
    If Selection<>9 Then
       Next.Field=9
    Endif
 End Select
 Call ShowField
Error.Resume232k:
 Exit Sub
Error.Trap232k:
 Resume Error.Resume232k
End Sub

Sub FindPlayer
 On Local Error Goto Error.Trap232l
 TempD!=SFalse
 Temp7!=SFalse
 If Out2=Nul Then
    Exit Sub
 Endif
 If Instr(Out2,"#") Then
    Temp7!=Int(Val(Mid$(Out2,Instr(Out2,"#")+1))+.5)
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempX!=SFalse
 No.Input=False
 For Var2!=1! To Lof(UserFile)/UserRecLen
    Call Read.Record(UserFile,Var2!)
    Out3=UserRecord.CodeName
    If Left$(Out3,Len(Out2))=Out2 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(UserFile)/UserRecLen Then
       Call Read.Record(UserFile,Var2!)
       No.Input=True
    Endif
 Endif
 If No.Input=False Then
    Var2!=SFalse
 Endif
 TempD!=Var2!
Error.Resume232l:
 Exit Sub
Error.Trap232l:
 Resume Error.Resume232l
End Sub

Sub Clear.List.Node
 On Local Error Goto ErrorTrp32z
 MessWorkRecord6.User=SFalse
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.Index=SFalse
 MessWorkRecord6.Charges=False
 MessWorkRecord6.Plus=False
 MessWorkRecord6.Prev=SFalse
 MessWorkRecord6.Next=SFalse
ErrorRsm32z:
 Exit Sub
ErrorTrp32z:
 Resume ErrorRsm32z
End Sub

Sub Add.List.Node4(VarY!,VarZ!)
 On Local Error Goto Error.Trap232y1
 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!)
Error.Resume232y1:
 Exit Sub
Error.Trap232y1:
 Resume Error.Resume232y1
End Sub

Sub Delete.List.Node4(VarZ!)
 On Local Error Goto Error.Trap232y3
 If TeamRecord.First=VarZ! Then
    Call Read.Record(TeamInvFile,VarZ!)
    TeamRecord.First=MessWorkRecord6.Next
    Call Write.Record(TeamFile,Team.Number)
    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,Team.Number)
       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
Error.Resume232y3:
 Exit Sub
Error.Trap232y3:
 Resume Error.Resume232y3
End Sub

' Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
DataMess1:
 Data 23,14,14,6,23,1,1

' Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
DataPlayer4:
 Data 23,24,24,30,23,1,1
DataPlayer5:
 Data 23,29,29,30,23,1,1

' Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
PlayerEditData:
 Data 4,12,12,30,1,4,1
 Data 6,11,11,20,1,6,1
 Data 8,10,10,3,1,8,1
 Data 10,11,11,30,1,10,1
 Data 12,11,11,30,1,12,1
 Data 14,11,11,30,1,14,1
 Data 16,11,11,30,1,16,1
 Data 18,11,11,30,1,18,1
 Data 20,12,12,22,1,20,1
 Data 8,21,21,8,1,8,1

Sub PreviousTeamObject
 On Local Error Goto Error.Trap72
 If Object.Number=1 Or Team.Objects=1 Then
    Out2="That is the first or only object. Can't cursor up."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Object.Number=Object.Number-1!
 Call DisplayTeamObjectScreen
Error.Resume72:
 Exit Sub
Error.Trap72:
 Resume Error.Resume72
End Sub

Sub NextTeamObject
 On Local Error Goto Error.Trap73
 If Object.Number>=Team.Objects Then
    Out2="That is the last or only object. Can't cursor down."
    Call ErrorStatusLine
 Else
    Object.Number=Object.Number+1!
    Call DisplayTeamObjectScreen
 Endif
Error.Resume73:
 Exit Sub
Error.Trap73:
 Resume Error.Resume73
End Sub

Sub TeamObjectStatusLine
 On Local Error Goto Error.Trap74
 Strng="^ Cursor Select <esc> Exit Object Display"
 Out2="^d Delete Object ^a Add Object ^w Search Objects"
 Call StatusLine
Error.Resume74:
 Exit Sub
Error.Trap74:
 Resume Error.Resume74
End Sub

Sub DisplayTeamTreasureScreen
 On Local Error Goto Error.Trap75
 If Team.Treasure=SFalse Then
    Treasure.Index=SFalse
    Treasure.Number=SFalse
    Call ShowTeamTreasure
    Out2="There is no treasure in the team to display."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Temp!=SFalse
 Treasure.Index=SFalse
 Team.Index!=TeamRecord.First
 If Team.Index! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Team.Index!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       If MessWorkRecord6.Index>SFalse Then
          Temp!=Temp!+1!
          If Temp!=Treasure.Number Then
             Treasure.Index=MessWorkRecord6.Index
             Exit Do
          Endif
       Endif
       Team.Index!=MessWorkRecord6.Next
       If Team.Index!=SFalse Then
          Exit Do
       Endif
    Loop
 Endif
 If Treasure.Index<=SFalse Or _
 Treasure.Index>Lof(TreasureFile)/TreasureRecLen Then
    Out2="The treasure number is not within the treasure file range."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call ShowTeamTreasure
Error.Resume75:
 Exit Sub
Error.Trap75:
 Resume Error.Resume75
End Sub

Sub EditTeamTreasure
 On Local Error Goto Error.Trap76
 Treasure.Number=1
 Call DisplayTeamTreasureScreen
 Do While Lost.Carrier=False
    Call TeamTreasureStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddTeamTreasure
       Case 4
          Call DeleteTeamTreasure
       Case 23
          Call SearchTeamTreasure
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousTeamTreasure
       Case 80, 145, 160
          Call NextTeamTreasure
       End Select
    End Select
 Loop
Error.Resume76:
 Exit Sub
Error.Trap76:
 Resume Error.Resume76
End Sub

Sub DeleteTeamTreasure
 On Local Error Goto Error.Trap77
 If Team.Treasure>SFalse Then
    Call Read.Record(TeamInvFile,Team.Index)
    If MessWorkRecord6.User=Team.Number Then
       If MessWorkRecord6.Index>SFalse Then
          Call Delete.List.Node4(Team.Index)
          Call Clear.List.Node
          Call Write.Record(TeamInvFile,Team.Index)
          Team.Treasure=Team.Treasure-1!
          Out2="The treasure has been deleted from the team."
          Call ErrorStatusLine
          Treasure.Number=1!
          Call DisplayTeamTreasureScreen
          TempX=False
          Call ShowPlayer
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The treasure has not been deleted from the team."
 Call ErrorStatusLine
 Treasure.Number=1!
 Call DisplayTeamTreasureScreen
Error.Resume77:
 Exit Sub
Error.Trap77:
 Resume Error.Resume77
End Sub

Sub AddTeamTreasure
 On Local Error Goto Error.Trap78
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate treasure"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Treasure Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,33)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data15
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!=SFalse Then
    Temp.Index=SFalse
    Var$=Edit.Data(1)
    Var=Instr(Var$,"#")
    If Var Then
       Edit.Data(1)=Left$(Var$,Var-1)
       Var$=Mid$(Var$,Var+1)
       Temp.Index=Int(Val(Var$)+.5)
    Endif
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)<>Nul Then
       Temp3!=SFalse
       For Temp2!=1! To Lof(TreasureFile)/TreasureRecLen
          Call Read.Record(TreasureFile,Temp2!)
          If TreasureRecord.Container=False Then
             If Left$(TreasureRecord.TreasureName, _
             Len(Edit.Data(1)))=Edit.Data(1) Then
                Temp3!=Temp3!+1!
                If Temp.Index=Temp3! Or Temp.Index=SFalse Then
                   Exit For
                Endif
             Endif
          Endif
       Next
    Endif
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Out2="The treasure name was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Temp2!)
 Temp3!=Lof(TeamInvFile)/MessWorkRecLen6+1!
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.User=Team.Number
 MessWorkRecord6.Index=Temp2!
 MessWorkRecord6.Charges=TreasureRecord.Charges
 MessWorkRecord6.Plus=False
 Call Add.List.Node4(Team.Number,Temp3!)
 Team.Treasure=Team.Treasure+1!
 Treasure.Number=1!
 Call DisplayTeamTreasureScreen
 TempX=False
 Call ShowPlayer
Error.Resume78:
 Exit Sub
Error.Trap78:
 Resume Error.Resume78
End Sub

Sub SearchTeamTreasure
 On Local Error Goto Error.Trap79
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate treasure"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Treasure Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,33)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data16
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Temp2!=SFalse
 Endif
 If Temp2!=SFalse Then
    Temp4=Len(Temp$)
    Temp3!=SFalse
    For Temp5!=1! To Lof(TreasureFile)/TreasureRecLen
       Call Read.Record(TreasureFile,Temp5!)
       If TreasureRecord.Container=False Then
          Out3=Rtrim$(TreasureRecord.TreasureName)
          Call InstrSUB(TempX,Out3,Temp$)
          If TempX Then
             Temp3!=Temp3!+1!
             If Temp3!=Temp.Index Or Temp.Index=SFalse Then
                Temp2!=Temp5!
                Exit For
             Endif
          Endif
       Endif
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The treasure name was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Treasure.Number=Temp2!
 Treasure.Index=Temp2!
 Call ShowTeamTreasure
 Out2="To exit treasure search display,"
 Call ErrorStatusLine
 Treasure.Number=1!
 Call DisplayTeamTreasureScreen
Error.Resume79:
 Exit Sub
Error.Trap79:
 Resume Error.Resume79
End Sub

Sub PreviousTeamTreasure
 On Local Error Goto Error.Trap80
 If Treasure.Number=1! Or Team.Treasure=1! Then
    Out2="That is the first or only treasure. Can't cursor up."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Treasure.Number=Treasure.Number-1!
 Call DisplayTeamTreasureScreen
Error.Resume80:
 Exit Sub
Error.Trap80:
 Resume Error.Resume80
End Sub

Sub NextTeamTreasure
 On Local Error Goto Error.Trap81
 If Treasure.Number>=Team.Treasure Then
    Out2="That is the last or only treasure. Can't cursor down."
    Call ErrorStatusLine
 Else
    Treasure.Number=Treasure.Number+1!
    Call DisplayTeamTreasureScreen
 Endif
Error.Resume81:
 Exit Sub
Error.Trap81:
 Resume Error.Resume81
End Sub

Sub TeamTreasureStatusLine
 On Local Error Goto Error.Trap82
 Strng="^ Cursor Select <esc> Exit Treasure Display"
 Out2="^d Delete Treasure ^a Add Treasure ^w Search Treasure"
 Call StatusLine
Error.Resume82:
 Exit Sub
Error.Trap82:
 Resume Error.Resume82
End Sub

Sub ShowTeamTreasure
 On Local Error Goto Error.Trap83
 Call MakeBox(6,33,12,79)
 TempD=True

 Title$="Treasure Number"+Str$(Treasure.Number)
 Call TitleBar(Title$)

 If Treasure.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Treasure.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.TreasureName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Weight:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(TreasureRecord.Weight),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Value:"
 Call Scrn(Strng)
' Strng=Mid$(Str$(TreasureRecord.Gold),2)
 VarX#=TreasureRecord.Gold
 Call Extend.Amount2(VarX#,Strng)
 Call Scrn(Strng)
 Call ANSI(2,11,34)
 Strng="Hits:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(Abs(TreasureRecord.Plus)),2)
 Call Scrn(Strng)
 Call ANSI(2,7,60)
 Strng="Coins:"
 Call Scrn(Strng)
 If TreasureRecord.Coin Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Potion:"
 Call Scrn(Strng)
 If TreasureRecord.Potion Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Scroll:"
 Call Scrn(Strng)
 If TreasureRecord.Scroll Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If TreasureRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Key Number:"
 Call Scrn(Strng)
 If TreasureRecord.MasterKey Then
    Strng="<master>"
 Else
    If TreasureRecord.KeyNumber>SFalse Then
       Strng=Right$(Str$(TreasureRecord.KeyNumber+1000000!),6)
    Else
       Strng="0"
    Endif
 Endif
 Call Scrn(Strng)
Error.Resume83:
 Exit Sub
Error.Trap83:
 Resume Error.Resume83
End Sub

Sub AddTeamObject
 On Local Error Goto Error.Trap114
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate objects"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Object Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,31)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data13
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!=SFalse Then
    Temp.Index=SFalse
    Var$=Edit.Data(1)
    Var=Instr(Var$,"#")
    If Var Then
       Edit.Data(1)=Left$(Var$,Var-1)
       Var$=Mid$(Var$,Var+1)
       Temp.Index=Int(Val(Var$)+.5)
    Endif
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)<>Nul Then
       Temp3!=SFalse
       For Temp2!=1! To Lof(ObjectFile)/ObjectRecLen
          Call Read.Record(ObjectFile,Temp2!)
          If Left$(ObjectRecord.ObjectName, _
          Len(Edit.Data(1)))=Edit.Data(1) Then
             Temp3!=Temp3!+1!
             If Temp3!=Temp.Index Or Temp.Index=SFalse Then
                Exit For
             Endif
          Endif
       Next
    Endif
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(ObjectFile)/ObjectRecLen Then
    Out2="The object name was not found in the object file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Read.Record(ObjectFile,Temp2!)
 Temp3!=Lof(TeamInvFile)/MessWorkRecLen6+1!
 MessWorkRecord6.Room=SFalse
 MessWorkRecord6.User=Team.Number
 MessWorkRecord6.Index=-Temp2!
 MessWorkRecord6.Charges=False
 MessWorkRecord6.Plus=False
 Call Add.List.Node4(Team.Number,Temp3!)
 Team.Objects=Team.Objects+1!
 Object.Number=1!
 Call DisplayTeamObjectScreen
 TempX=False
 Call ShowPlayer
Error.Resume114:
 Exit Sub
Error.Trap114:
 Resume Error.Resume114
End Sub

Sub SearchTeamObject
 On Local Error Goto Error.Trap115
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate objects"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Object Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,31)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data14
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(ObjectFile)/ObjectRecLen Then
    Temp2!=SFalse
 Endif
 If Temp2!=SFalse Then
    Temp4=Len(Temp$)
    Temp3!=SFalse
    For Temp5!=1! To Lof(ObjectFile)/ObjectRecLen
       Call Read.Record(ObjectFile,Temp5!)
       Out3=Rtrim$(ObjectRecord.ObjectName)
       Call InstrSUB(TempX,Out3,Temp$)
       If TempX Then
          Temp3!=Temp3!+1!
          If Temp3!=Temp.Index Or Temp.Index=SFalse Then
             Temp2!=Temp5!
             Exit For
          Endif
       Endif
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The object name was not found in the object file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Object.Number=Temp2!
 Object.Index=Temp2!
 Call ShowTeamObject
 Out2="To exit object search display,"
 Call ErrorStatusLine
 Object.Number=1!
 Call DisplayTeamObjectScreen
Error.Resume115:
 Exit Sub
Error.Trap115:
 Resume Error.Resume115
End Sub

Sub ShowTeamObject
 On Local Error Goto Error.Trap118
 Call MakeBox(6,33,12,79)
 TempD=True

 Title$="Object Number"+Str$(Object.Number)
 Call TitleBar(Title$)

 If Object.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(ObjectFile,Object.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ObjectName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Room Links:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink1),2)+","
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink2),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Permanent:"
 Call Scrn(Strng)
 If ObjectRecord.Permanent Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,34)
 Strng="Hiding:"
 Call Scrn(Strng)
 If MessWorkRecord6.Plus=Hidden.Object Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,7,60)
 Strng="Hidden:"
 Call Scrn(Strng)
 If ObjectRecord.Hidden Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If ObjectRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Trapped:"
 Call Scrn(Strng)
 If ObjectRecord.JailTrap Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Locked:"
 Call Scrn(Strng)
 If ObjectRecord.DoorLock>1 Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Relocks:"
 Call Scrn(Strng)
 If ObjectRecord.Relocks Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
Error.Resume118:
 Exit Sub
Error.Trap118:
 Resume Error.Resume118
End Sub

Data13:
 Data 23,31,31,30,23,1,1
Data14:
 Data 23,31,31,30,23,1,1
Data15:
 Data 23,33,33,30,23,1,1
Data16:
 Data 23,33,33,30,23,1,1

Sub DisplayTeamObjectScreen
 On Local Error Goto Error.Trap111
 If Team.Objects=SFalse Then
    Object.Index=SFalse
    Object.Number=SFalse
    Call ShowTeamObject
    Out2="There are no objects in the team to display."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Temp!=SFalse
 Object.Index=SFalse
 Team.Index!=TeamRecord.First
 If Team.Index! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Team.Index!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       If MessWorkRecord6.Index<SFalse Then
          Temp!=Temp!+1!
          If Temp!=Object.Number Then
             Object.Index=Abs(MessWorkRecord6.Index)
             Exit Do
          Endif
       Endif
       Team.Index!=MessWorkRecord6.Next
       If Team.Index!=SFalse Then
          Exit Do
       Endif
    Loop
 Endif
 If Object.Index<=SFalse Or Object.Index>Lof(ObjectFile)/ObjectRecLen Then
    Out2="The object number is not within the object file range."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call ShowTeamObject
Error.Resume111:
 Exit Sub
Error.Trap111:
 Resume Error.Resume111
End Sub

Sub EditTeamObject
 On Local Error Goto Error.Trap112
 Object.Number=1!
 Call DisplayTeamObjectScreen
 Do While Lost.Carrier=False
    Call TeamObjectStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddTeamObject
       Case 4
          Call DeleteTeamObject
       Case 23
          Call SearchTeamObject
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousTeamObject
       Case 80, 145, 160
          Call NextTeamObject
       End Select
    End Select
 Loop
Error.Resume112:
 Exit Sub
Error.Trap112:
 Resume Error.Resume112
End Sub

Sub DeleteTeamObject
 On Local Error Goto Error.Trap113
 If Team.Objects>SFalse Then
    Call Read.Record(TeamInvFile,Team.Index)
    If MessWorkRecord6.User=Team.Number Then
       If MessWorkRecord6.Index<SFalse Then
          Call Delete.List.Node4(Team.Index)
          Call Clear.List.Node
          Call Write.Record(TeamInvFile,Team.Index)
          Team.Objects=Team.Objects-1!
          Out2="The object has been deleted from the team."
          Call ErrorStatusLine
          Object.Number=1!
          Call DisplayTeamObjectScreen
          TempX=False
          Call ShowPlayer
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The object has not been deleted from the team."
 Call ErrorStatusLine
 Object.Number=1!
 Call DisplayTeamObjectScreen
Error.Resume113:
 Exit Sub
Error.Trap113:
 Resume Error.Resume113
End Sub

Sub EditTeamContainers
 On Local Error Goto Error.Trap143c
 Container.Number=1
 Call DisplayTeamContainerScreen
 Do While Lost.Carrier=False
    Call Get.Team.Container
    Call TeamContainerStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddTeamContainer
       Case 4
          Call DeleteTeamContainer
       Case 23
          Call SearchTeamContainer
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousTeamContainer
       Case 80, 145, 160
          Call NextTeamContainer
       End Select
    End Select
 Loop
Error.Resume143c:
 Exit Sub
Error.Trap143c:
 Resume Error.Resume143c
End Sub

Sub DeleteTeamContainer
 On Local Error Goto Error.Trap144c
 VarQ=False
 Temp!=SFalse
 Call Get.Team.Container
 If Team.Containers>SFalse Then
    Inventory.Index!=TeamRecord.First2
    If Inventory.Index! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Inventory.Index!)
          Next.Index!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Temp!=Temp!+1!
                If Temp!=Container.Number Then
                   Call Delete.Team.Container(Inventory.Index!)
                   Call Clear.Container.Node
                   Call Write.Record(ContainerFile,Inventory.Index!)
                   VarQ=True
                   Exit Do
                Endif
             Endif
          Endif
          If Next.Index!=SFalse Then
             Exit Do
          Endif
          Inventory.Index!=Next.Index!
       Loop
    Endif
 Endif
 If VarQ=True Then
    Out2="The container has been deleted from the team."
    TempX=False
    Call ShowPlayer
 Else
    Out2="The container was not deleted from the team."
 Endif
 Call ErrorStatusLine
 Container.Number=1
 Call DisplayTeamContainerScreen
Error.Resume144c:
 Exit Sub
Error.Trap144c:
 Resume Error.Resume144c
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 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,Team.Number)
    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,Team.Number)
       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

Sub AddTeamContainer
 On Local Error Goto Error.Trap145c
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate containers"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Container Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,34)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data15C
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 If Temp2!=SFalse Then
    Temp.Index=SFalse
    Var$=Edit.Data(1)
    Var=Instr(Var$,"#")
    If Var Then
       Edit.Data(1)=Left$(Var$,Var-1)
       Var$=Mid$(Var$,Var+1)
       Temp.Index=Int(Val(Var$)+.5)
    Endif
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)<>Nul Then
       Temp3!=SFalse
       For Temp2!=1! To Lof(TreasureFile)/TreasureRecLen
          Call Read.Record(TreasureFile,Temp2!)
          If TreasureRecord.Container Then
             If Left$(TreasureRecord.TreasureName, _
             Len(Edit.Data(1)))=Edit.Data(1) Then
                Temp3!=Temp3!+1!
                If Temp.Index=Temp3! Or Temp.Index=SFalse Then
                   Temp6=TreasureRecord.Charges
                   Exit For
                Endif
             Endif
          Endif
       Next
    Endif
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Out2="The container name was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Drop.Container.In.Team(Temp2!)
 Out2="The container has been added to the team."
 TempX=False
 Call ShowPlayer
 Call ErrorStatusLine
 Container.Number=1
 Call DisplayTeamContainerScreen
Error.Resume145c:
 Exit Sub
Error.Trap145c:
 Resume Error.Resume145c
End Sub

Sub SearchTeamContainer
 On Local Error Goto Error.Trap146c
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for duplicate containers"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Container Name or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,34)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data16C
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1))+.5)
 Temp$=Lcase$(Edit.Data(1))
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))+.5))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 If Temp2!<=SFalse Or Temp2!>Lof(ContainerFile)/ContainerRecLen Then
    Temp2!=SFalse
 Endif
 If Temp2!=SFalse Then
    Temp4=Len(Temp$)
    Temp3!=SFalse
    For Temp5!=1! To Lof(ContainerFile)/ContainerRecLen
       Call Read.Record(ContainerFile,Temp5!)
       If Container.DeletedContainer=False Then
          If ContainerRecord.WithinContainer=SFalse Then
             Out3=Rtrim$(ContainerRecord.ContainerName)
             Call InstrSUB(TempX,Out3,Temp$)
             If TempX Then
                Temp3!=Temp3!+1!
                If Temp3!=Temp.Index Or Temp.Index=SFalse Then
                   Temp2!=Temp5!
                   Exit For
                Endif
             Endif
          Endif
       Endif
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The container name was not found in the container file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Container.Number=Temp2!
 Container.Index=Temp2!
 Call ShowTeamContainer
 Out2="To exit container search display,"
 Call ErrorStatusLine
 Container.Number=1!
 Call DisplayTeamContainerScreen
Error.Resume146c:
 Exit Sub
Error.Trap146c:
 Resume Error.Resume146c
End Sub

Sub PreviousTeamContainer
 On Local Error Goto Error.Trap147c
 If Container.Number<=1! Then
    Out2="That is the first or only container. Can't cursor up."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Container.Number=Container.Number-1!
 Call DisplayTeamContainerScreen
Error.Resume147c:
 Exit Sub
Error.Trap147c:
 Resume Error.Resume147c
End Sub

Sub NextTeamContainer
 On Local Error Goto Error.Trap148c
 Call Get.Team.Container
 If Container.Number>=Team.Containers Then
    Out2="That is the last or only container. Can't cursor down."
    Call ErrorStatusLine
 Else
    Container.Number=Container.Number+1!
    Call DisplayTeamContainerScreen
 Endif
Error.Resume148c:
 Exit Sub
Error.Trap148c:
 Resume Error.Resume148c
End Sub

Sub TeamContainerStatusLine
 On Local Error Goto Error.Trap149c
 Strng="^ Cursor Select <esc> Exit Container Display"
 Out2="^d Delete Container ^a Add Container ^w Search Containers"
 Call StatusLine
Error.Resume149c:
 Exit Sub
Error.Trap149c:
 Resume Error.Resume149c
End Sub

Data15C:
 Data 23,34,34,30,23,1,1
Data16C:
 Data 23,34,34,30,23,1,1

Sub DisplayTeamContainerScreen
 On Local Error Goto Error.Trap142c
 Call Get.Team.Container
 If Team.Containers=SFalse Then
    Container.Index=SFalse
    Container.Number=SFalse
    Call ShowTeamContainer
    Out2="There is no container of the team to display."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Temp!=SFalse
 Container.Index=SFalse
 Inventory.Index!=TeamRecord.First2
 If Inventory.Index! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Inventory.Index!)
       Next.Index!=ContainerRecord.Next
       If ContainerRecord.DeletedContainer=False Then
          If ContainerRecord.WithinContainer=SFalse Then
             Temp!=Temp!+1!
             If Temp!=Container.Number Then
                Container.Index=Temp! ' ContainerRecord.ContainerIndex
                Exit Do
             Endif
          Endif
       Endif
       If Next.Index!=SFalse Then
          Exit Do
       Endif
       Inventory.Index!=Next.Index!
    Loop
 Endif
 If Container.Index=SFalse Then
    Out2="The container number is not within the container file range."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call ShowTeamContainer
Error.Resume142c:
 Exit Sub
Error.Trap142c:
 Resume Error.Resume142c
End Sub

Sub ShowTeamContainer
 On Local Error Goto Error.Trap150b
 Call MakeBox(6,33,12,79)
 TempD=True

 Title$="Container Number"+Str$(Container.Number)
 Call TitleBar(Title$)

 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    Strng=Left$(ContainerRecord.ContainerName,20)
    Call Scrn(Strng)
 Endif
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    Strng=Left$(ContainerRecord.ContainerShort,14)
    Strng=Lcase$(Strng)
    Call Scrn(Strng)
 Endif
 Call ANSI(2,9,34)
 Strng="Weight:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    Strng=Mid$(Str$(ContainerRecord.Weight),2)
    Call Scrn(Strng)
 Endif
 Call ANSI(2,10,34)
 Strng="Prefix:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    Strng=Left$(ContainerRecord.NamePrefix,14)
    Strng=Lcase$(Strng)
    Call Scrn(Strng)
 Endif
 Call ANSI(2,11,34)
 Strng="Max:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    If ContainerRecord.ContainerMax=True Then
       Strng="<unlimited>"
    Else
       If ContainerRecord.ContainerMax Then
          Strng=Mid$(Str$(ContainerRecord.ContainerMax),2)
       Else
          Strng="<n/a>"
       Endif
    Endif
    Call Scrn(Strng)
 Endif
 Call ANSI(2,7,60)
 Strng="Size:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    Select Case ContainerRecord.Size
    Case 1
       Strng="small"
    Case 2
       Strng="medium"
    Case 3
       Strng="large"
    Case Else
       Strng="any"
    End Select
    Call Scrn(Strng)
 Endif
 Call ANSI(2,8,60)
 Strng="Trap:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    If ContainerRecord.TrapType Then
       Call Scrn("Yes")
    Else
       Call Scrn("No")
    Endif
 Endif
 Call ANSI(2,9,60)
 Strng="Damaged:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    If ContainerRecord.Damaged Then
       Call Scrn("Yes")
    Else
       Call Scrn("No")
    Endif
 Endif
 Call ANSI(2,10,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    If ContainerRecord.InvisibleContainer Then
       Call Scrn("Yes")
    Else
       Call Scrn("No")
    Endif
 Endif
 Call ANSI(2,11,60)
 Strng="Key Number:"
 Call Scrn(Strng)
 If Container.Index>SFalse Then
    If ContainerRecord.KeyNumber>SFalse Then
       Strng=Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)
    Else
       Strng="0"
    Endif
    Call Scrn(Strng)
 Endif
Error.Resume150b:
 Exit Sub
Error.Trap150b:
 Resume Error.Resume150b
End Sub

Sub Get.Team.Container
 On Local Error Goto Error.Trap141c
 Team.Containers=SFalse
 Temp2!=TeamRecord.First2
 If Temp2! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Temp2!)
       VarQ!=ContainerRecord.Next
       If ContainerRecord.DeletedContainer=False Then
          If ContainerRecord.WithinContainer=SFalse Then
             Team.Containers=Team.Containers+1!
          Endif
          If VarQ!=SFalse Then
             Exit Do
          Endif
          Temp2!=VarQ!
       Endif
    Loop
 Endif
 If Container.Number>Team.Containers Then
    Container.Number=Team.Containers
 Endif
Error.Resume141c:
 Exit Sub
Error.Trap141c:
 Resume Error.Resume141c
End Sub

Sub Drop.Container.In.Team(Var2!)
 On Local Error Goto ErrTrap48b
 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.Size=TreasureRecord.ContainerSize
 ContainerRecord.Material=TreasureRecord.ContainerMaterial
 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=SFalse
 ContainerRecord.UserNumber=Team.Number
 ContainerRecord.Weight=TreasureRecord.Weight
 ContainerRecord.ContainerIndex=Abs(Var2!)
 ContainerRecord.Disappears=TreasureRecord.ContainerDisappears
 ContainerRecord.SelfImplodes=TreasureRecord.ContainerSelfImplodes
 ContainerRecord.Permanent=TreasureRecord.Permanent
 For VarR=1 To 3
    ContainerRecord.RestrictItem(VarR)=TreasureRecord.RestrictItem(VarR)
 Next
 ContainerRecord.TrapType=TreasureRecord.TrapType
 ContainerRecord.TrapHits=TreasureRecord.TrapHits
 ContainerRecord.TrapItem=TreasureRecord.TrapItem
 ContainerRecord.Prefix1=TreasureRecord.Prefix1
 Call Write.Record(ContainerFile,VarA!)
 Call Add.Team.Container(VarA!)
ErrResume48b:
 Exit Sub
ErrTrap48b:
 Resume ErrResume48b
End Sub

Sub Add.Team.Container(VarA!)
 On Local Error Goto ErrResume141h
 ' add container to teams.dat list
 Call Read.Record(TeamFile,Team.Number)
 If TeamRecord.First2=SFalse Then
    TeamRecord.First2=VarA!
    TeamRecord.Last2=VarA!
    Call Write.Record(TeamFile,Team.Number)
    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,Team.Number)
 Endif
ErrExit141h:
 Exit Sub
ErrResume141h:
 Resume ErrExit141h
End Sub

Sub Clear.Container
 On Local Error Goto ErrTrap46
 ContainerRecord.ContainerName=Nul
 ContainerRecord.ContainerShort=Nul
 ContainerRecord.NamePrefix="in it"
 ContainerRecord.ContainerMax=False
 ContainerRecord.Closed=False
 ContainerRecord.Locked=False
 ContainerRecord.KeyNumber=SFalse
 ContainerRecord.UserNumber=SFalse
 ContainerRecord.RoomNumber=SFalse
 ContainerRecord.DeletedContainer=False
 ContainerRecord.InvisibleContainer=False
 ContainerRecord.Weight=False
 ContainerRecord.WithinContainer=SFalse
 ContainerRecord.Disappears=SFalse
 ContainerRecord.ContainerIndex=SFalse
 ContainerRecord.Size=False
 ContainerRecord.Material=False
 ContainerRecord.Permanent=False
 ContainerRecord.SelfImplodes=False
 ContainerRecord.First=SFalse
 ContainerRecord.Last=SFalse
 ContainerRecord.First2=SFalse
 ContainerRecord.Last2=SFalse
 ContainerRecord.Prefix1=""
 ContainerRecord.Damaged=False
 ContainerRecord.Scanned=False
ErrResume46:
 Exit Sub
ErrTrap46:
 Resume ErrResume46
End Sub

Sub Extend.Amount2(Var#,Var$)
 VarX$=Ltrim$(Str$(Var#)) ' 1.111D308
 V=Instr(VarX$,"D")
 If V Then
    If Mid$(VarX$,2,1)="." Then
       VarX$=Left$(VarX$,1)+Mid$(VarX$,V)
    Endif
    Var$=" "+VarX$
 Else
    Var$=" "+Format$(Var#,"#,##0;;")
 Endif
End Sub

