 Rem File: Editcmd2 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,"2")
    If Var=False Then
       Call Terminate.Program
       End
    Endif
 Endif
 Call Edit.Containers
MainExit0:
 End
ErrMain0:
 Resume MainExit0
 End

Sub Edit.Containers
 On Local Error Goto ErrResume115
 Call Edit.Status.Line
 If Lof(ContainerFile)=SFalse Then
    Call Add.Container
 Endif
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Container Edit utility v"+Left$(Version$,4)+" menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(89,"[A]")+"dd"
       Call IO.O
       Strng=RT$(90,"[C]")+"hange"
       Call IO.O
       Strng=RT$(91,"[D]")+"elete"
       Call IO.O
       Strng=RT$(92,"[L]")+"ist"
       Call IO.O
       Strng=RT$(93,"[P]")+"ack"
       Call IO.O
       Strng=RT$(94,"[R]")+"epair"
       Call IO.O
       Strng=RT$(95,"[S]")+"earch"
       Call IO.O
       Strng=RT$(96,"[U]")+"ndelete"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(583,"[V]")+"Print"
          Call IO.O
       Endif
    Endif
    Graphics.Off=False
    Strng="Container edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(89,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Add.Container
          Temp5!=Lof(ContainerFile)/ContainerRecLen
          Call Modify.Container
          Call Add.New.Container
       Endif
    Case "C"
       If RT$(90,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Find.Container(0)
          If Temp5! Then
             Call Modify.Container
          Endif
       Endif
    Case "D"
       If RT$(91,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Delete.Container
       Endif
    Case "L"
       If RT$(92,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call List.Containers
       Endif
    Case "P"
       If RT$(93,"[P]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Pack.Containers
       Endif
    Case "R"
       If RT$(94,"[R]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Repair.Containers(True)
       Endif
    Case "S"
       If RT$(95,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Search.Containers
       Endif
    Case "U"
       If RT$(96,"[U]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Undelete.Container
       Endif
    Case "V"
       If Local.Mode Then
          If RT$(583,"[V]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Print.Containers
          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
ErrExit115:
 Exit Sub
ErrResume115:
 Resume ErrExit115
End Sub

Sub Add.Container
 On Local Error Goto ErrResume116
 Temp5!=Lof(ContainerFile)/ContainerRecLen+1!
 Call Clear.Container
 ContainerRecord.Prefix1=Nul
 If ANSIPrefixChar<>Nul Then
    ContainerRecord.Prefix1=ANSIPrefixChar+"FE"
 Endif
 Call Write.Record(ContainerFile,Temp5!)
ErrExit116:
 Exit Sub
ErrResume116:
 Resume ErrExit116
End Sub

Sub Add.New.Container
 On Local Error Goto ErrResume116a
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Add container menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(97,"[R]")+"oom"
       Call IO.O
       Strng=RT$(98,"[U]")+"ser"
       Call IO.O
    Endif
    Graphics.Off=False
    Strng="Container add option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "R"
       If RT$(97,"[R]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Temp7!=Temp5!
          Strng="Enter room number(1-"+Mid$(Str$(Lof(RoomFile)/RoomRecLen),2)+")?"
          Call IO.I
          Temp5!=Int(Val(Out2)+.5)
          If Temp5!>SFalse And Temp5!<=Lof(RoomFile)/RoomRecLen Then
             Call Read.Record(RoomFile,Temp5!)
             ContainerRecord.NamePrefix="in it"
             ContainerRecord.RoomNumber=Temp5!
             ContainerRecord.UserNumber=SFalse
             Call Add.Room.Container(Temp7!)
             Strng="Container added to room."
             Call IO.O
          Else
             Strng="Container not added to room."
             Call IO.O
          Endif
       Endif
    Case "U"
       If RT$(98,"[U]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          VarX!=Temp5!
          Call Find.User(0)
          If Temp5! Then
             ContainerRecord.RoomNumber=SFalse
             ContainerRecord.UserNumber=Temp5!
             Call Add.User.Container(VarX!)
             Strng="Container added to user."
             Call IO.O
          Else
             Strng="Container not added to user."
             Call IO.O
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
ErrExit116a:
 Exit Sub
ErrResume116a:
 Resume ErrExit116a
End Sub

Sub Modify.Container
 On Local Error Goto ErrResume117
 Do While Lost.Carrier=False
    Allow.Break=True
    Break=False
    For VarQ=1 To 20
       Call Display.Edit.Container(VarQ)
       If Break Then
	  Exit For
       Endif
    Next
    Allow.Break=False
    Strng="Container change option(q to quit)? "
    Graphics.Off=False
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(99,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Line.Length=30
          Strng="Container name? "
          Call IO.I
          If Out2<>Nul Then
             Out2=Ucase$(Out2)
             Call Valid(Out2,30)
             If Out2=Nul Then
                Strng="Illegal characters in name."
                Call IO.O
             Else
                ContainerRecord.ContainerName=Lcase$(Out2)
             Endif
	  Endif
       Endif
    Case "B"
       If RT$(100,"[B]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Line.Length=30
          Strng="Container short name? "
          Call IO.I
          If Out2<>Nul Then
             Out2=Ucase$(Out2)
             Call Valid(Out2,30)
             If Out2=Nul Then
                Strng="Illegal characters in name."
                Call IO.O
             Else
                ContainerRecord.ContainerShort=Out2
             Endif
	  Endif
       Endif
    Case "C"
       If RT$(101,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Maximum objects in container(0,1-32767/-1=unlimited)? "
          No.Input.Out="10"
          Call IO.I
          Temp3=Int(Val(Out2)+.5)
          ContainerRecord.ContainerMax=Temp3
       Endif
    Case "D"
       If RT$(102,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container is locked(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          If Yes Then
             ContainerRecord.Locked=True
             ContainerRecord.Closed=True
          Else
             ContainerRecord.Locked=False
             ContainerRecord.Closed=False
          Endif
       Endif
    Case "E"
       If RT$(103,"[E]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container is trapped(y/n)?"
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          If Yes Then
             Do While Lost.Carrier=False
                If TempC=False Then
                   Graphics.Off=False
                   Strng="Container trap menu:"
                   Call IO.O
                   Graphics.Off=True
                   Strng=RT$(118,"[C]")+"lear"
                   Call IO.O
                   Strng=RT$(119,"[H]")+"its"
                   Call IO.O
                   Strng=RT$(120,"[E]")+"xplodes"
                   Call IO.O
                   Strng=RT$(121,"[P]")+"oison"
                   Call IO.O
                   Strng=RT$(122,"[W]")+"eapon"
                   Call IO.O
                Endif
                Line.Length=TempD
                No.Input.Out="Q"
                Strng="Container trap(q to quit)? "
                Call IO.I
                Select Case Ucase$(Out2)
                Case "C"
                   If RT$(118,"[C]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      ContainerRecord.TrapType=False
                      ContainerRecord.TrapHits=False
                      ContainerRecord.TrapItem=SFalse
                   Endif
                Case "W"
                   If RT$(122,"[W]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      Call Find.Treasure
                      ContainerRecord.TrapType=4
                      ContainerRecord.TrapItem=TempC!
                   Endif
                Case "P"
                   If RT$(121,"[P]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      ContainerRecord.TrapType=1
                      ContainerRecord.TrapHits=False
                   Endif
                Case "H"
                   If RT$(119,"[H]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      Do While Lost.Carrier=False
                         If TempC=False Then
                            Graphics.Off=False
                            Strng="Container health trap menu:"
                            Call IO.O
                            Graphics.Off=True
                            Strng=RT$(123,"[F]")+"atigue"
                            Call IO.O
                            Strng=RT$(124,"[V]")+"itality"
                            Call IO.O
                            Strng=RT$(125,"[N]")+"one"
                            Call IO.O
                         Endif
                         Line.Length=TempD
                         No.Input.Out="Q"
                         Strng="Container Hits(q to quit)? "
                         Call IO.I
                         Select Case Ucase$(Out2)
                         Case "F"
                            If RT$(123,"[F]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               Strng="Hits of fat(1-32767)?"
                               Call IO.I
                               If Int(Val(Out2)+.5)>False And Int(Val(Out2)+.5)<=32767 Then
                                  ContainerRecord.TrapType=2
                                  ContainerRecord.TrapHits=Int(Val(Out2)+.5)
                               Endif
                            Endif
                         Case "V"
                            If RT$(124,"[V]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               Strng="Hits of vit(1-32767)?"
                               Call IO.I
                               If Int(Val(Out2)+.5)>False And Int(Val(Out2)+.5)<=32767 Then
                                  ContainerRecord.TrapType=2
                                  ContainerRecord.TrapHits=-Int(Val(Out2)+.5)
                               Endif
                            Endif
                         Case "N"
                            If RT$(125,"[N]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               ContainerRecord.TrapType=0
                               ContainerRecord.TrapHits=0
                            Endif
                         Case "Q"
                            Exit Do
                         End Select
                      Loop
                   Endif
                Case "E"
                   If RT$(120,"[E]")="[*]" Then
                      Strng="Command restricted.."
                      Call IO.O
                   Else
                      Do While Lost.Carrier=False
                         If TempC=False Then
                            Graphics.Off=False
                            Strng="Container explodes trap menu:"
                            Call IO.O
                            Graphics.Off=True
                            Strng=RT$(126,"[F]")+"atigue"
                            Call IO.O
                            Strng=RT$(127,"[V]")+"itality"
                            Call IO.O
                            Strng=RT$(128,"[N]")+"one"
                            Call IO.O
                         Endif
                         Line.Length=TempD
                         No.Input.Out="Q"
                         Strng="Container Hits(q to quit)? "
                         Call IO.I
                         Select Case Ucase$(Out2)
                         Case "F"
                            If RT$(126,"[F]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               Strng="Hits of fat(1-32767)?"
                               Call IO.I
                               If Int(Val(Out2)+.5)>False And Int(Val(Out2)+.5)<=32767 Then
                                  ContainerRecord.TrapType=3
                                  ContainerRecord.TrapHits=Int(Val(Out2)+.5)
                               Endif
                            Endif
                         Case "V"
                            If RT$(127,"[V]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               Strng="Hits of vit(1-32767)?"
                               Call IO.I
                               If Int(Val(Out2)+.5)>False And Int(Val(Out2)+.5)<=32767 Then
                                  ContainerRecord.TrapType=3
                                  ContainerRecord.TrapHits=-Int(Val(Out2)+.5)
                               Endif
                            Endif
                         Case "N"
                            If RT$(128,"[N]")="[*]" Then
                               Strng="Command restricted.."
                               Call IO.O
                            Else
                               ContainerRecord.TrapType=False
                               ContainerRecord.TrapHits=False
                            Endif
                         Case "Q"
                            Exit Do
                         End Select
                      Loop
                   Endif
                Case "Q"
                   Exit Do
                End Select
             Loop
          Endif
       Endif
    Case "F"
       If RT$(104,"[F]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container requires key number(1-999999)? "
          No.Input.Out="0"
          Call IO.I
          Temp3!=Int(Val(Out2)+.5)
          If Temp3!>=SFalse And Temp3!<=999999! Then
             ContainerRecord.KeyNumber=Temp3!
          Endif
       Endif
    Case "I"
       If RT$(107,"[I]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container is invisible(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          ContainerRecord.InvisibleContainer=Yes
       Endif
    Case "J"
       If RT$(108,"[J]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container weight? "
          Call IO.I
          ContainerRecord.Weight=Int(Val(Out2)+.5)
       Endif
    Case "K"
       If RT$(109,"[K]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Edit.Container.Inventory
       Endif
    Case "L"
       If RT$(110,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          No.Input.Out="in it"
          Strng="Container name prefix(in it)? "
          Call IO.I
          ContainerRecord.NamePrefix=Lcase$(Out2)
       Endif
    Case "M"
       If RT$(111,"[M]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container disappears with another(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          ContainerRecord.Disappears=SFalse
          If Yes Then
             Strng="Enter destination container to be placed into:"
             Call IO.O
             Call Find.Treasure
             If TempC!=SFalse Then
                Strng="Treasure item not found."
                Call IO.O
             Else
                If TreasureRecord.Container=False Then
                   Strng="Treasure item is not another container."
                   Call IO.O
                Else
                   If TempC!=Temp5! Then
                      Strng="Treasure item is current container."
                      Call IO.O
                   Else
                      ContainerRecord.Disappears=TempC!
                   Endif
                Endif
             Endif
          Endif
          ' if index is 0 then reset.
          If ContainerRecord.ContainerIndex=SFalse Then
             Strng="Current container index is not set."
             Call IO.O
             Strng="Edit this container treasure index(y/n)? "
             Line.Length=TempD
             No.Input.Out="N"
             Call IO.I
             If Yes Then
                Call Find.Treasure
                If TempC!=SFalse Then
                   Strng="Treasure item not found."
                   Call IO.O
                Else
                   If TreasureRecord.Container=False Then
                      Strng="Treasure item is not a container."
                      Call IO.O
                   Else
                      ContainerRecord.ContainerIndex=TempC!
                   Endif
                Endif
             Endif
          Endif
       Endif
    Case "N"
       If RT$(112,"[N]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             If TempC=False Then
                Graphics.Off=False
                Strng="Container size menu:"
                Call IO.O
                Graphics.Off=True
                Strng=RT$(129,"[0]")+"any"
                Call IO.O
                Strng=RT$(130,"[1]")+"small"
                Call IO.O
                Strng=RT$(131,"[2]")+"medium"
                Call IO.O
                Strng=RT$(132,"[3]")+"large"
                Call IO.O
             Endif
             Graphics.Off=False
             Line.Length=TempD
             No.Input.Out="Q"
             Strng="Container size menu(q to quit)? "
             Call IO.I
             Select Case Ucase$(Out2)
             Case "0"
                If RT$(129,"[0]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Size=0
                Endif
             Case "1"
                If RT$(130,"[1]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Size=1
                Endif
             Case "2"
                If RT$(131,"[2]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Size=2
                Endif
             Case "3"
                If RT$(132,"[0]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Size=3
                Endif
             Case "Q"
                Exit Do
             End Select
          Loop
          Do While Lost.Carrier=False
             If TempC=False Then
                Graphics.Off=False
                Strng="Container material menu:"
                Call IO.O
                Graphics.Off=True
                Strng=RT$(687,"[0]")+"paper"
                Call IO.O
                Strng=RT$(688,"[1]")+"glass"
                Call IO.O
                Strng=RT$(689,"[2]")+"wood"
                Call IO.O
                Strng=RT$(690,"[3]")+"metal"
                Call IO.O
             Endif
             Graphics.Off=False
             Line.Length=TempD
             No.Input.Out="Q"
             Strng="Container material menu(q to quit)? "
             Call IO.I
             Select Case Ucase$(Out2)
             Case "0"
                If RT$(687,"[0]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   Strng="Container is burnable paper(y/n)? "
                   Line.Length=TempD
                   No.Input.Out="N"
                   Call IO.I
                   ContainerRecord.Material=Yes
                Endif
             Case "1"
                If RT$(688,"[1]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Material=1
                Endif
             Case "2"
                If RT$(689,"[2]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Material=2
                Endif
             Case "3"
                If RT$(690,"[3]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   ContainerRecord.Material=3
                Endif
             Case "Q"
                Exit Do
             End Select
          Loop
       Endif
    Case "O"
       If RT$(113,"[O]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container is permanent(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          ContainerRecord.Permanent=Yes
       Endif
    Case "P"
       If RT$(114,"[P]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Edit this container treasure index(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          If Yes Then
             Call Find.Treasure
             If TempC!=SFalse Then
                Strng="Treasure item not found."
                Call IO.O
             Else
                If TreasureRecord.Container=False Then
                   Strng="Treasure item is not a container."
                   Call IO.O
                Else
                   ContainerRecord.ContainerIndex=TempC!
                Endif
             Endif
          Endif
       Endif
    Case "R"
       If RT$(115,"[R]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Container self implodes(y/n)? "
          Line.Length=TempD
          No.Input.Out="N"
          Call IO.I
          ContainerRecord.SelfImplodes=Yes
       Endif
    Case "S"
       If RT$(116,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Do While Lost.Carrier=False
             If TempC=False Then
                Graphics.Off=False
                Strng="Enter restricted items:"
                Call IO.O
                Graphics.Off=True
                For VarQ=1 To 3
                   VarQ!=ContainerRecord.RestrictItem(VarQ)
                   If VarQ! Then
                      If VarQ!<0! Then
                         VarQ!=Abs(VarQ!)
                         Call Read.Record(ObjectFile,VarQ!)
                         Strng=Lcase$(Rtrim$(ObjectRecord.ObjectName))
                      Else
                         Call Read.Record(TreasureFile,VarQ!)
                         Strng=Lcase$(Rtrim$(TreasureRecord.TreasureName))
                      Endif
                   Else
                      Strng="<none>"
                   Endif
                   Strng=" ("+Ltrim$(Str$(VarQ))+")"+Strng
                   Call IO.O
                Next
                Strng=" (4)exit"
                Call IO.O
             Endif
             Graphics.Off=False
             Line.Length=TempD
             No.Input.Out="4"
             Strng="Enter restrict option(1-4)? "
             Call IO.I
             VarQ=Int(Val(Out2)+.5)
             Select Case VarQ
             Case 1 To 3
                Do While Lost.Carrier=False
                   If TempC=False Then
                      Graphics.Off=False
                      Strng="Enter restricted type:"
                      Call IO.O
                      Graphics.Off=True
                      Strng=" <o>bject: "
                      If ContainerRecord.RestrictItem(VarQ)<0! Then
                         Strng=Strng+"Yes:"
                         Strng=Strng+Str$(Abs(ContainerRecord.RestrictItem(VarQ)))
                      Else
                         Strng=Strng+"No"
                      Endif
                      Call IO.O
                      Strng=" <t>reasure: "
                      If ContainerRecord.RestrictItem(VarQ)>0! Then
                         Strng=Strng+"Yes:"
                         Strng=Strng+Str$(ContainerRecord.RestrictItem(VarQ))
                      Else
                         Strng=Strng+"No"
                      Endif
                      Call IO.O
                      Strng=" <n>one"
                      Call IO.O
                      Strng=" <q>uit"
                      Call IO.O
                   Endif
                   Graphics.Off=False
                   Strng="Restricted type(o/t/n/q):"
                   Line.Length=TempD
                   No.Input.Out="Q"
                   Call IO.I
                   Graphics.Off=True
                   Select Case Lcase$(Out2)
                   Case "o"
                      Call Find.Object2
                      If TempD! Then
                         ContainerRecord.RestrictItem(VarQ)=-TempD!
                         Strng="Container item"+Str$(VarQ)+" set to"+Str$(TempD!)+"."
                         Call IO.O
                      Endif
                   Case "t"
                      Call Find.Treasure2
                      If TempC! Then
                         ContainerRecord.RestrictItem(VarQ)=TempC!
                         Strng="Container item"+Str$(VarQ)+" set to"+Str$(TempC!)+"."
                         Call IO.O
                      Endif
                   Case "n"
                      ContainerRecord.RestrictItem(VarQ)=0!
                      Strng="Container item"+Str$(VarQ)+" cleared."
                      Call IO.O
                   Case "q"
                      Exit Do
                   End Select
                Loop
             Case 4
                Exit Do
             End Select
          Loop
       Endif
    Case "T"
       If RT$(117,"[T]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Graphics.Off=True
          If ANSIPrefixChar=Nul Then
             Strng="ANSI prefix codes not enabled."
             Call IO.O
             Call More.Prompt
          Else
             Do
                Strng="ANSI prefix code(8 characters, ? for help):"
                Call IO.O
                Strng="?"
                No.Input.Out=Nul
                Call IO.I
                Out2=Ucase$(Out2)
                If Out2="?" Then
                   Call Display.ANSI.Prefixes
                Else
                   Call Check.ANSI.Prefix(V%)
                   If V% Then
                      ContainerRecord.Prefix1=Out2
                      Exit Do
                   Endif
                   Strng="Invalid ANSI code."
                   Call IO.O
                   Call More.Prompt
                Endif
             Loop
          Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Call Write.Record(ContainerFile,Temp5!)
 Strng="Container modified."
 Call IO.O
ErrExit117:
 Exit Sub
ErrResume117:
 Resume ErrExit117
End Sub

Sub Add.List.Node5(VarZ!)
 On Local Error Goto ErrorTrp27b
 If ContainerRecord.First=SFalse Then
    ContainerRecord.First=VarZ!
    ContainerRecord.Last=VarZ!
    Call Write.Record(ContainerFile,Temp5!)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(CtnInvFile,VarZ!)
    Exit Sub
 Endif
 MessWorkRecord6.Prev=ContainerRecord.Last
 MessWorkRecord6.Next=SFalse
 Call Write.Record(CtnInvFile,VarZ!)
 Call Read.Record(CtnInvFile,ContainerRecord.Last)
 MessWorkRecord6.Next=VarZ!
 Call Write.Record(CtnInvFile,ContainerRecord.Last)
 Call Read.Record(CtnInvFile,VarZ!)
 ContainerRecord.Last=VarZ!
 Call Write.Record(ContainerFile,Temp5!)
ErrorRsm27b:
 Exit Sub
ErrorTrp27b:
 Resume ErrorRsm27b
End Sub

Sub Add.Room.Container(VarA!)
 On Local Error Goto ErrResume141g
 ' add container to rooms.dat list
 Call Read.Record(RoomFile,Temp5!)
 If RoomRecord.First2=SFalse Then
    RoomRecord.First2=VarA!
    RoomRecord.Last2=VarA!
    Call Write.Record(RoomFile,Temp5!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
 Else
    ContainerRecord.Prev=RoomRecord.Last2
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
    Call Read.Record(ContainerFile,RoomRecord.Last2)
    ContainerRecord.Next=VarA!
    Call Write.Record(ContainerFile,RoomRecord.Last2)
    Call Read.Record(ContainerFile,VarA!)
    RoomRecord.Last2=VarA!
    Call Write.Record(RoomFile,Temp5!)
 Endif
ErrExit141g:
 Exit Sub
ErrResume141g:
 Resume ErrExit141g
End Sub

' add container to users.dat list
Sub Add.User.Container(VarA!)
 On Local Error Goto ErrResume141h
 ContainerRecord.SwapFlag=False
 If UserRecord2.First2=SFalse Then
    UserRecord2.First2=VarA!
    UserRecord2.Last2=VarA!
    Call Write.Record(UserFile2,Temp5!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
    Exit Sub
 Endif
 ContainerRecord.Prev=UserRecord2.Last2
 ContainerRecord.Next=SFalse
 Call Write.Record(ContainerFile,VarA!)
 Call Read.Record(ContainerFile,UserRecord2.Last2)
 ContainerRecord.Next=VarA!
 Call Write.Record(ContainerFile,UserRecord2.Last2)
 Call Read.Record(ContainerFile,VarA!)
 UserRecord2.Last2=VarA!
 Call Write.Record(UserFile2,Temp5!)
ErrExit141h:
 Exit Sub
ErrResume141h:
 Resume ErrExit141h
End Sub

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

Sub Edit.Container.Inventory
 On Local Error Goto ErrResume118
 Do While Lost.Carrier=False
    Graphics.Off=True
    If TempC=False Then
       VarZ1!=SFalse
       VarZ2!=SFalse
       Var4!=ContainerRecord.First
       If Var4! Then
          Do While Lost.Carrier=False
             Call Read.Record(CtnInvFile,Var4!)
             If MessWorkRecord6.User=SFalse Then
                Exit Do
             Endif
             Var5!=MessWorkRecord6.Next
             If MessWorkRecord6.User<SFalse Then
                VarZ1!=VarZ1!+1!
             Endif
             If MessWorkRecord6.User>SFalse Then
                VarZ2!=VarZ2!+1!
             Endif
             If Var5!=SFalse Then
                Exit Do
             Endif
             Var4!=Var5!
          Loop
       Endif
       Call Read.Record(ContainerFile,Temp5!)
       Strng=RT$(135,"[T]")+"reasure ("+Mid$(Str$(VarZ2!),2)+")"
       Call IO.O
       Strng=RT$(134,"[O]")+"bjects ("+Mid$(Str$(VarZ1!),2)+")"
       Call IO.O
       VarZ!=SFalse
       Var4!=ContainerRecord.First2
       If Var4! Then
          Do While Lost.Carrier=False
             Call Read.Record(ContainerFile,Var4!)
             Var5!=ContainerRecord.Next
             VarZ!=VarZ!+1!
             If Var5!=SFalse Then
                Exit Do
             Endif
             Var4!=Var5!
          Loop
       Endif
       Call Read.Record(ContainerFile,Temp5!)
       Strng=RT$(133,"[C]")+"ontainers ("+Mid$(Str$(VarZ!),2)+")"
       Call IO.O
       Graphics.Off=False
    Endif
    Strng="Container inventory edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "T"
       If RT$(135,"[T]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
       Do While Lost.Carrier=False
          Graphics.Off=True
          If TempC=False Then
             Strng=RT$(142,"[A]")+"dd"
             Call IO.O
             Strng=RT$(143,"[D]")+"elete"
             Call IO.O
             Strng=RT$(144,"[L]")+"ist"
             Call IO.O
             Graphics.Off=False
          Endif
          Strng="Container inventory treasure edit option(q to quit)? "
          Line.Length=TempD
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             If RT$(142,"[A]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                VarQ=False
                Call Find.Treasure
                If TempC! Then
                   Temp2!=Lof(CtnInvFile)/MessWorkRecLen6+1!
                   MessWorkRecord6.Room=SFalse
                   MessWorkRecord6.User=TempC!
                   MessWorkRecord6.Index=Temp5!
                   MessWorkRecord6.Charges=TreasureRecord.Charges
                   Strng="Invisible in container(y/n)? "
                   Line.Length=TempD
                   No.Input.Out="N"
                   Call IO.I
                   MessWorkRecord6.Plus=Yes
                   Call Add.List.Node5(Temp2!)
                   VarQ=True
                Endif
                If VarQ=True Then
                   Strng="Treasure added to container inventory."
                Else
                   Strng="Treasure not added to container inventory."
                Endif
                Call IO.O
             Endif
          Case "D"
             If RT$(143,"[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 Temp2!>SFalse And Temp2!<=Lof(CtnInvFile)/MessWorkRecLen6 Then
                   Var4!=ContainerRecord.First
                   If Var4! Then
                      Do While Lost.Carrier=False
                         Call Read.Record(CtnInvFile,Var4!)
                         Var5!=MessWorkRecord6.Next
                         If MessWorkRecord6.User>SFalse Then
                            TempX!=TempX!+1!
                            If TempX!=Temp2! Then
                               Call Delete.List.Node5(Var4!)
                               Call Clear.List.Node
                               Call Write.Record(CtnInvFile,Var4!)
                               VarQ=True
                               Exit Do
                            Endif
                         Endif
                         If Var5!=SFalse Then
                            Exit Do
                         Endif
                         Var4!=Var5!
                      Loop
                   Endif
                Endif
                If VarQ=True Then
                   Strng="Treasure deleted from container inventory."
                Else
                   Strng="Treasure not deleted from container inventory."
                Endif
                Call IO.O
             Endif
          Case "L"
             If RT$(144,"[L]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                Allow.Break=True
                Break=False
                Continuous=False
                Graphics.Off=True
                Temp8=False
                Temp4!=ContainerRecord.First
                TempX!=SFalse
                If Temp4! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(CtnInvFile,Temp4!)
                      If MessWorkRecord6.User=SFalse Then
                         Exit Do
                      Endif
                      Temp6!=MessWorkRecord6.Next
                      Temp!=MessWorkRecord6.User
                      If Temp!>SFalse And Temp!<=Lof(TreasureFile)/TreasureRecLen Then
                         Call Read.Record(TreasureFile,Temp!)
                         Out3=TreasureRecord.TreasureName
                         Out3=Lcase$(Out3)
                         Out3=Rtrim$(Out3)
                         TempX!=TempX!+1!
                         Strng=Mid$(Str$(TempX!),2)+"."+Out3
                         If MessWorkRecord6.Plus Then
                            Strng=Strng+"[inv]"
                         Endif
                         Call IO.O
                         If Break Then
                            Exit Do
                         Endif
                         Temp8=Temp8+1
                         If Temp8>=User.Pagelength-2 Then
                            Temp8=False
                            If Continuous=False Then
                               Call More.Prompt
                               If No Or Quit Then
                                  Exit Do
                               Endif
                            Endif
                         Endif
                      Endif
                      If Temp6!=SFalse Then
                         Exit Do
                      Endif
                      Temp4!=Temp6!
                   Loop
                Endif
                Allow.Break=False
                Break=False
                If Temp8 Then
                   Call More.Prompt
                Endif
             Endif
          Case "Q"
             Exit Do
          End Select
       Loop
       Endif
    Case "O"
       If RT$(134,"[O]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
       Do While Lost.Carrier=False
          Graphics.Off=True
          If TempC=False Then
             Strng=RT$(139,"[A]")+"dd"
             Call IO.O
             Strng=RT$(140,"[D]")+"elete"
             Call IO.O
             Strng=RT$(141,"[L]")+"ist"
             Call IO.O
             Graphics.Off=False
          Endif
          Strng="Container inventory object edit option(q to quit)? "
          Line.Length=TempD
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             If RT$(139,"[A]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                VarQ=False
                Call Find.Object
                If TempD! Then
                   Temp2!=Lof(CtnInvFile)/MessWorkRecLen6+1!
                   MessWorkRecord6.Room=SFalse
                   MessWorkRecord6.User=-TempD!
                   MessWorkRecord6.Index=Temp5!
                   MessWorkRecord6.Charges=False
                   Strng="Invisible in container(y/n)? "
                   Line.Length=TempD
                   No.Input.Out="N"
                   Call IO.I
                   MessWorkRecord6.Plus=Yes
                   Call Add.List.Node5(Temp2!)
                   VarQ=True
                Endif
                If VarQ=True Then
                   Strng="Object added to container inventory."
                Else
                   Strng="Object not added to container inventory."
                Endif
                Call IO.O
             Endif
          Case "D"
             If RT$(140,"[D]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                Strng="Number to delete? "
                No.Input.Out="1"
                Call IO.I
                VarQ=False
                Temp2!=Int(Val(Out2)+.5)
                TempX!=SFalse
                If Temp2!>SFalse And Temp2!<=Lof(CtnInvFile)/MessWorkRecLen6 Then
                   Var4!=ContainerRecord.First
                   If Var4! Then
                      Do While Lost.Carrier=False
                         Call Read.Record(CtnInvFile,Var4!)
                         Var5!=MessWorkRecord6.Next
                         If MessWorkRecord6.User<SFalse Then
                            TempX!=TempX!+1!
                            If TempX!=Temp2! Then
                               Call Delete.List.Node5(Var4!)
                               Call Clear.List.Node
                               Call Write.Record(CtnInvFile,Var4!)
                               VarQ=True
                               Exit Do
                            Endif
                         Endif
                         If Var5!=SFalse Then
                            Exit Do
                         Endif
                         Var4!=Var5!
                      Loop
                   Endif
                Endif
                If VarQ=True Then
                   Strng="Object deleted from container inventory."
                Else
                   Strng="Object not deleted from container inventory."
                Endif
                Call IO.O
             Endif
          Case "L"
             If RT$(141,"[L]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                Allow.Break=True
                Break=False
                Continuous=False
                Graphics.Off=True
                Temp8=False
                Temp4!=ContainerRecord.First
                TempX!=SFalse
                If Temp4! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(CtnInvFile,Temp4!)
                      If MessWorkRecord6.User=SFalse Then
                         Exit Do
                      Endif
                      Temp6!=MessWorkRecord6.Next
                      Temp!=MessWorkRecord6.User
                      If Temp!<SFalse Then
                         Temp!=Abs(Temp!)
                         If Temp!>SFalse And Temp!<=Lof(ObjectFile)/ObjectRecLen Then
                            Call Read.Record(ObjectFile,Temp!)
                            Out3=ObjectRecord.ObjectName
                            Out3=Lcase$(Out3)
                            Out3=Rtrim$(Out3)
                            TempX!=TempX!+1!
                            Strng=Mid$(Str$(TempX!),2)+"."+Out3
                            If MessWorkRecord6.Plus Then
                               Strng=Strng+"[inv]"
                            Endif
                            Call IO.O
                            If Break Then
                               Exit Do
                            Endif
                            Temp8=Temp8+1
                            If Temp8>=User.Pagelength-2 Then
                               Temp8=False
                               If Continuous=False Then
                                  Call More.Prompt
                                  If No Or Quit Then
                                     Exit Do
                                  Endif
                               Endif
                            Endif
                         Endif
                      Endif
                      If Temp6!=SFalse Then
                         Exit Do
                      Endif
                      Temp4!=Temp6!
                   Loop
                Endif
                Allow.Break=False
                Break=False
                If Temp8 Then
                   Call More.Prompt
                Endif
             Endif
          Case "Q"
             Exit Do
          End Select
       Loop
       Endif
    Case "C"
       If RT$(133,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
       Do While Lost.Carrier=False
          Graphics.Off=True
          If TempC=False Then
             Strng=RT$(136,"[A]")+"dd"
             Call IO.O
             Strng=RT$(137,"[D]")+"elete"
             Call IO.O
             Strng=RT$(138,"[L]")+"ist"
             Call IO.O
             Graphics.Off=False
          Endif
          Strng="Container inventory edit option(q to quit)? "
          Line.Length=TempD
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             If RT$(136,"[A]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                VarQ=False
                Call Find.Treasure
                If TempC! Then
                   If TreasureRecord.Container Then
                      Call Add.Container.To.Container
                      VarQ=True
                   Endif
                Endif
                If VarQ=True Then
                   Strng="Container added to container inventory."
                Else
                   Strng="Container not added to container inventory."
                Endif
                Call IO.O
                Call Read.Record(ContainerFile,Temp5!)
             Endif
          Case "D"
             If RT$(137,"[D]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                Strng="Number to delete? "
                No.Input.Out="1"
                Call IO.I
                VarQ=False
                Temp2!=Int(Val(Out2)+.5)
                Temp4!=ContainerRecord.First2
                TempX!=SFalse
                If Temp4! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(ContainerFile,Temp4!)
                      Temp6!=ContainerRecord.Next
                      TempX!=TempX!+1!
                      If TempX!=Temp2! Then
                         TempA!=Temp5!
                         Call Delete.Within.Container(Temp4!)
                         VarQ=True
                         Exit Do
                      Endif
                      If Temp6!=SFalse Then
                         Exit Do
                      Endif
                      Temp4!=Temp6!
                   Loop
                Endif
                If VarQ=True Then
                   Strng="Container deleted from container inventory."
                Else
                   Strng="Container not deleted from container inventory."
                Endif
                Call IO.O
                Call Read.Record(ContainerFile,Temp5!)
             Endif
          Case "L"
             If RT$(138,"[L]")="[*]" Then
                Strng="Command restricted.."
                Call IO.O
             Else
                Allow.Break=True
                Break=False
                Continuous=False
                Graphics.Off=True
                Temp8=False
                Temp4!=ContainerRecord.First2
                TempX!=SFalse
                If Temp4! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(ContainerFile,Temp4!)
                      Temp6!=ContainerRecord.Next
                      Out3=ContainerRecord.ContainerName
                      Out3=Lcase$(Out3)
                      Out3=Rtrim$(Out3)
                      TempX!=TempX!+1!
                      Strng=Mid$(Str$(TempX!),2)+"."+Out3
                      If ContainerRecord.InvisibleContainer Then
                         Strng=Strng+"[inv]"
                      Endif
                      Strng=Strng+"("+Mid$(Str$(Temp4!),2)+")"
                      Call IO.O
                      If Break Then
                         Exit Do
                      Endif
                      Temp8=Temp8+1
                      If Temp8>=User.Pagelength-2 Then
                         Temp8=False
                         If Continuous=False Then
                            Call More.Prompt
                            If No Or Quit Then
                               Exit Do
                            Endif
                         Endif
                      Endif
                      If Temp6!=SFalse Then
                         Exit Do
                      Endif
                      Temp4!=Temp6!
                   Loop
                Endif
                Allow.Break=False
                Break=False
                If Temp8 Then
                   Call More.Prompt
                Endif
                Call Read.Record(ContainerFile,Temp5!)
             Endif
          Case "Q"
             Exit Do
          End Select
       Loop
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
ErrExit118:
 Exit Sub
ErrResume118:
 Resume ErrExit118
End Sub

' delete container VarZ! from container TempA!
Sub Delete.Within.Container(VarZ!)
 On Local Error Goto ErrorTrp32d
 Call Read.Record(ContainerFile,TempA!)
 If ContainerRecord.First2=VarZ! Then
    Call Read.Record(ContainerFile,VarZ!)
    VarR!=ContainerRecord.Next
    Call Read.Record(ContainerFile,TempA!)
    ContainerRecord.First2=VarR!
    Call Write.Record(ContainerFile,TempA!)
    If VarR!>SFalse Then
       Call Read.Record(ContainerFile,VarR!)
       ContainerRecord.Prev=SFalse
       Call Write.Record(ContainerFile,VarR!)
    Endif
 Else
    If ContainerRecord.Last2=VarZ! Then
       Call Read.Record(ContainerFile,VarZ!)
       VarR!=ContainerRecord.Prev
       Call Read.Record(ContainerFile,TempA!)
       ContainerRecord.Last2=VarR!
       Call Write.Record(ContainerFile,TempA!)
       If VarR!>SFalse Then
          Call Read.Record(ContainerFile,VarR!)
          ContainerRecord.Next=SFalse
          Call Write.Record(ContainerFile,VarR!)
       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 Delete.Container
 On Local Error Goto ErrResume119
 Call Find.Container(0)
 If Temp5!=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(ContainerFile,Temp5!)
 If ContainerRecord.DeletedContainer=True Then
    Strng="Container already deleted."
    Call IO.O
    Exit Sub
 Endif
 ContainerRecord.DeletedContainer=True
 Call Write.Record(ContainerFile,Temp5!)
 Strng="Container deleted."
 Call IO.O
ErrExit119:
 Exit Sub
ErrResume119:
 Resume ErrExit119
End Sub

Sub List.Containers
 On Local Error Goto ErrResume120
 Temp3!=Lof(ContainerFile)/ContainerRecLen
 Call Get.Record.Range(Temp!,Temp2!,Temp3!)
 Allow.Break=True
 Break=False
 Continuous=False
 For Temp5!=Temp! To Temp2!
    Call Read.Record(ContainerFile,Temp5!)
    For VarQ=1 To 20
       Call Display.Container(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
ErrExit120:
 Exit Sub
ErrResume120:
 Resume ErrExit120
End Sub

Sub Print.Containers
 On Local Error Goto ErrResume120a
 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(ContainerFile)/ContainerRecLen
    Call Get.Record.Range(Temp!,Temp2!,Temp3!)
    For Temp5!=Temp! To Temp2!
       Call Read.Record(ContainerFile,Temp5!)
       For VarQ=1 To 19
          Call Print.Container(VarQ)
       Next
       Print #TempFile1,Chr$(12);
    Next
 Endif
ErrExit120a:
 Close #TempFile1
 Exit Sub
ErrResume120a:
 Resume ErrExit120a
End Sub

Sub Pack.Containers
 On Local Error Goto ErrResume121
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't pack while node/user online."
    Call IO.O
    Exit Sub
 Endif
 Strng="Pack containers(y/n)? "
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 If No Then
    Exit Sub
 Endif
 Call Repair.Containers(False)
 Carriage.Return=True
 Graphics.Off=True
 Strng="Making backup of container file."
 Call IO.O
 VarD=False
 VarE=False
 VarF!=Timeit!
 FileName=Left$(Container.Filename,Instr(Container.Filename,"."))+"bak"
 Close #TempFile1
 If Dir$(FileName)<>Nul Then
    Kill FileName
 Endif
 Open FileName For Random Shared As #TempFile1 Len=ContainerRecLen
 For Temp3!=1! To Lof(ContainerFile)/ContainerRecLen
    Call Read.Record(ContainerFile,Temp3!)
    Call Dot.Display(VarD,VarE,VarF!)
    Temp=False
    If ContainerRecord.WithinContainer=False Then
       Var1!=ContainerRecord.RoomNumber
       Var2!=ContainerRecord.UserNumber
       If Var1!=SFalse And Var2!=SFalse Then
          Temp=True
       Endif
       If Var1!>Lof(RoomFile)/RoomRecLen Then
          Temp=True
       Endif
       If Var2!>Lof(UserFile2)/UserRecLen Then
          Temp=True
       Endif
       If Var2!>SFalse And Var2!<=Lof(UserFile2)/UserRecLen Then
          Call Read.Record(UserFile2,Var2!)
          Out3=UserRecord2.CodeName
          If Left$(Out3,9)=Deleted$ Then
             Temp=True
          Endif
       Endif
    Endif
    If ContainerRecord.DeletedContainer Then
       Temp=True
    Endif
    If Temp Then
       Call Delete.Container.Contents(Temp3!)
       ContainerRecord.DeletedContainer=True
    Endif
    Call Write.TempFile(5,Temp3!)
 Next
 Strng=Nul
 Call IO.O
 Graphics.Off=True
 FileName=Container.Filename
 Close #ContainerFile
 If Dir$(FileName)<>Nul Then
    Kill FileName
 Endif
 Open FileName For Random Shared As #ContainerFile Len=ContainerRecLen
 Carriage.Return=True
 Strng="Packing container file"
 Call IO.O
 VarD=False
 VarE=False
 VarF!=Timeit!
 ' pack room containers
 For Temp5!=1! To Lof(RoomFile)/RoomRecLen
    Call Read.Record(RoomFile,Temp5!)
    Temp4!=RoomRecord.First2
    If Temp4! Then
       RoomRecord.First2=SFalse
       RoomRecord.Last2=SFalse
       Call Write.Record(RoomFile,Temp5!)
       Do
          Call Read.TempFile(5,Temp4!)
          Temp6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=False Then
                Temp7!=Lof(ContainerFile)/ContainerRecLen+1!
                Call Add.Room.Container(Temp7!)
                Call Move.Container.Contents(Temp4!,Temp7!)
             Endif
          Endif
          Call Dot.Display(VarD,VarE,VarF!)
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp4!=Temp6!
       Loop
    Endif
 Next
 ' pack user containers
 For Temp5!=1! To Lof(UserFile2)/UserRecLen
    Call Read.Record(UserFile2,Temp5!)
    Temp4!=UserRecord2.First2
    If Temp4! Then
       UserRecord2.First2=SFalse
       UserRecord2.Last2=SFalse
       Call Write.Record(UserFile2,Temp5!)
       Do
          Call Read.TempFile(5,Temp4!)
          Temp6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=False Then
                Temp7!=Lof(ContainerFile)/ContainerRecLen+1!
                Call Add.User.Container(Temp7!)
                Call Move.Container.Contents(Temp4!,Temp7!)
             Endif
          Endif
          Call Dot.Display(VarD,VarE,VarF!)
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp4!=Temp6!
       Loop
    Endif
 Next
 ' pack within containers
 Temp5!=SFalse
 Do
    Temp5!=Temp5!+1!
    If Temp5!>Lof(ContainerFile)/ContainerRecLen Then
       Exit Do
    Endif
    Call Read.Record(ContainerFile,Temp5!)
    Temp4!=ContainerRecord.First2
    If Temp4! Then
       ContainerRecord.First2=SFalse
       ContainerRecord.Last2=SFalse
       Call Write.Record(ContainerFile,Temp5!)
       Do
          Call Read.TempFile(5,Temp4!)
          Temp6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer Then
                Temp7!=Lof(ContainerFile)/ContainerRecLen+1!
                Call Write.Record(ContainerFile,Temp7!)
                Call Add.Within.Container(Temp7!)
                Call Move.Container.Contents(Temp4!,Temp7!)
             Endif
          Endif
          Call Dot.Display(VarD,VarE,VarF!)
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp4!=Temp6!
       Loop
    Endif
 Loop
 Strng=Nul
 Call IO.O
 Graphics.Off=False
 Strng="Container file packed."
 Call IO.O
 Strng="Pack container inventory file(y/n)? "
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 If No Then
    Exit Sub
 Endif
 Call Repair.Containers(False)
 Carriage.Return=True
 Graphics.Off=True
 Strng="Making backup of container inventory file"
 Call IO.O
 Close #TempFile1
 FileName=Data.Path1+"CTNINV.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(CtnInvFile)/MessWorkRecLen6
    Call Read.Record(CtnInvFile,Temp5!)
    Call Write.TempFile(7,Temp5!)
    Call Dot.Display(VarD,VarE,VarF!)
 Next
 Call IO.O
 Carriage.Return=True
 Strng="Packing container inventory file"
 Call IO.O
 Close #CtnInvFile
 FileName=CtnInv.FileName
 If Dir$(FileName)<>Nul Then
    Kill FileName
 Endif
 Open FileName For Random Shared As #CtnInvFile Len=MessWorkRecLen6
 VarD=False
 VarE=False
 VarF!=Timeit!
 For Temp5!=1! To Lof(ContainerFile)/ContainerRecLen
    Call Read.Record(ContainerFile,Temp5!)
    Temp4!=ContainerRecord.First
    If Temp4! Then
       ContainerRecord.First=SFalse
       ContainerRecord.Last=SFalse
       Call Write.Record(ContainerFile,Temp5!)
       Do
          Call Read.TempFile(7,Temp4!)
          Temp6!=MessWorkRecord6.Next
          Temp7!=Lof(CtnInvFile)/MessWorkRecLen6+1!
          Call Add.List.Node5(Temp7!)
          Call Dot.Display(VarD,VarE,VarF!)
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp4!=Temp6!
       Loop
    Endif
 Next
 Call IO.O
 Graphics.Off=False
 Strng="Container inventory file packed."
 Call IO.O
 Close #TempFile1
ErrExit121:
 Exit Sub
ErrResume121:
 Resume ErrExit121
End Sub

Sub Delete.Container.Contents(VarX!)
 On Local Error Goto ErrResume12z
 ContainerRecord.First=SFalse
 ContainerRecord.Last=SFalse
 For VarQ!=1! To Lof(CtnInvFile)/MessWorkRecLen6
    Call Read.Record(CtnInvFile,VarQ!)
    If MessWorkRecord6.Index=VarX! Then
       MessWorkRecord6.User=SFalse
       MessWorkRecord6.Index=SFalse
       MessWorkRecord6.Charges=False
       MessWorkRecord6.Plus=False
       MessWorkRecord6.Room=SFalse
       MessWorkRecord6.Prev=SFalse
       MessWorkRecord6.Next=SFalse
       Call Write.Record(CtnInvFile,VarQ!)
    Endif
 Next
ErrExit12z:
 Exit Sub
ErrResume12z:
 Resume ErrExit12z
End Sub

Sub Move.Container.Contents(Var1!,Var2!)
 On Local Error Goto ErrResume12x
 For VarQ!=1! To Lof(CtnInvFile)/MessWorkRecLen6
    Call Read.Record(CtnInvFile,VarQ!)
    If MessWorkRecord6.Index=Var1! Then
       MessWorkRecord6.Index=Var2!
       Call Write.Record(CtnInvFile,VarQ!)
    Endif
 Next
ErrExit12x:
 Exit Sub
ErrResume12x:
 Resume ErrExit12x
End Sub

Sub Add.Within.Container(VarQ!)
 On Local Error Goto ErrTrap40a
 Call Read.Record(ContainerFile,Temp5!)
 If ContainerRecord.First2=SFalse Then
    ContainerRecord.First2=VarQ!
    ContainerRecord.Last2=VarQ!
    Call Write.Record(ContainerFile,Temp5!)
    Call Read.Record(ContainerFile,VarQ!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarQ!)
 Else
    VarR!=ContainerRecord.Last2
    Call Read.Record(ContainerFile,VarQ!)
    ContainerRecord.Prev=VarR!
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarQ!)
    Call Read.Record(ContainerFile,VarR!)
    ContainerRecord.Next=VarQ!
    Call Write.Record(ContainerFile,VarR!)
    Call Read.Record(ContainerFile,Temp5!)
    ContainerRecord.Last2=VarQ!
    Call Write.Record(ContainerFile,Temp5!)
    Call Read.Record(ContainerFile,VarQ!)
 Endif
ErrResume40a:
 Exit Sub
ErrTrap40a:
 Resume ErrResume40a
End Sub

Sub Repair.Containers(VarK)
 On Local Error Goto ErrResume11a
 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 container 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 container inventory file"
 Call IO.O
 Close #TempFile1
 FileName=Data.Path1+"CTNINV2.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(CtnInvFile)/MessWorkRecLen6
    Call Read.Record(CtnInvFile,Temp5!)
    Call Write.TempFile(7,Temp5!)
    Call Dot.Display(VarD,VarE,VarF!)
 Next
 Call IO.O
 Carriage.Return=True
 Graphics.Off=True
 Strng="Repairing container inventory file"
 Call IO.O
 VarD=False
 VarE=False
 VarF!=Timeit!
 Var4!=SFalse
 VarZ1!=SFalse
 For Temp1!=1! To Lof(ContainerFile)/ContainerRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.First
    Temp3!=ContainerRecord.Last
    If Temp2!>SFalse And Temp3!>SFalse Then
       If Temp2!=Temp3! Then
          Call Read.Record(CtnInvFile,Temp2!)
          If MessWorkRecord6.Prev<>SFalse Or MessWorkRecord6.Next<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Prev=SFalse
             MessWorkRecord6.Next=SFalse
             Call Write.Record(CtnInvFile,Temp2!)
          Endif
       Else
          Call Read.Record(CtnInvFile,Temp2!)
          If MessWorkRecord6.Prev<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Prev=SFalse
             Call Write.Record(CtnInvFile,Temp2!)
          Endif
          Call Read.Record(CtnInvFile,Temp3!)
          If MessWorkRecord6.Next<>SFalse Then
             VarZ1!=VarZ1!+1!
             MessWorkRecord6.Next=SFalse
             Call Write.Record(CtnInvFile,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(ContainerFile)/ContainerRecLen
    VarY1!=0!
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.First
    If Temp2! Then
       Do
          Call Read.Record(CtnInvFile,Temp2!)
          VarY1!=VarY1!+1!
          Lset S$=Mks$(Temp2!)
          Put #TempFile1,VarY1!
          Temp6!=MessWorkRecord6.Next
          If Temp6!>SFalse Then
             Call Read.Record(CtnInvFile,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(ContainerFile)/ContainerRecLen
    VarY1!=0!
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.Last
    If Temp2! Then
       Do
          Call Read.Record(CtnInvFile,Temp2!)
          VarY1!=VarY1!+1!
          Lset S$=Mks$(Temp2!)
          Put #TempFile1,VarY1!
          Temp6!=MessWorkRecord6.Prev
          If Temp6!>SFalse Then
             Call Read.Record(CtnInvFile,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(ContainerFile)/ContainerRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.First
    If Temp2! Then
       Do
          Call Read.Record(CtnInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Next
          If Temp6!>SFalse Then
             Call Read.Record(CtnInvFile,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(ContainerFile)/ContainerRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.Last
    If Temp2! Then
       Do
          Call Read.Record(CtnInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Prev
          If Temp6!>SFalse Then
             Call Read.Record(CtnInvFile,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(ContainerFile)/ContainerRecLen
    Call Dot.Display(VarD,VarE,VarF!)
    Call Read.Record(ContainerFile,Temp1!)
    Temp2!=ContainerRecord.First
    If Temp2! Then
       Do
          Call Read.Record(CtnInvFile,Temp2!)
          Temp6!=MessWorkRecord6.Next
          Temp3!=MessWorkRecord6.Index
          If Temp3!<>Temp1! Then
             VarZ3!=VarZ3!+1!
             MessWorkRecord6.Index=Temp1!
             Call Write.Record(CtnInvFile,Temp2!)
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Next
 Call IO.O
 Graphics.Off=False
 Strng="Container 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
 Exit Sub
Truncate1:
 VarZ2!=VarZ2!+1!
 Call Read.Record(CtnInvFile,Temp2!)
 MessWorkRecord6.Next=SFalse
 Call Write.Record(CtnInvFile,Temp2!)
 ContainerRecord.Last=Temp2!
 Call Write.Record(ContainerFile,Temp1!)
 Return
Truncate2:
 VarZ2!=VarZ2!+1!
 Call Read.Record(CtnInvFile,Temp2!)
 MessWorkRecord6.Prev=SFalse
 Call Write.Record(CtnInvFile,Temp2!)
 ContainerRecord.First=Temp2!
 Call Write.Record(ContainerFile,Temp1!)
 Return
ErrExit11a:
 Exit Sub
ErrResume11a:
 Resume ErrExit11a
End Sub

Sub Search.Containers
 On Local Error Goto ErrResume122
 Do While Lost.Carrier=False
    Temp1$=Nul
    Temp1=False
    Temp3!=SFalse
    Temp4=False
    Temp6!=SFalse
    Temp6$=Nul
    Var7!=SFalse
    Var8!=SFalse
    Temp8=False
    Do While Lost.Carrier=False
       Graphics.Off=True
       If TempC=False Then
	  Strng="[A]container name substring"
	  If Temp1$<>Nul Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"("+Temp1$+")"
	  Endif
	  Call IO.O
	  Strng="[B]locked container"
	  If Temp1 Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"(selected)"
	  Endif
	  Call IO.O
	  Strng="[C]key number"
          If Temp3! Then
             Strng=Strng+Space$(30-Len(Strng))
             If Temp3!=-1 Then
                Strng=Strng+"<any>"
             Else
                Strng=Strng+"("+Mid$(Str$(Temp3!),2)+")"
             Endif
	  Endif
	  Call IO.O
	  Strng="[D]invisible container"
	  If Temp4 Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"(selected)"
	  Endif
	  Call IO.O
	  Strng="[E]user owner"
          If Temp6! Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"("+Temp6$+")"
	  Endif
	  Call IO.O
	  Strng="[F]room owner"
          If Var7! Then
	     Strng=Strng+Space$(30-Len(Strng))
             Strng=Strng+"("+Mid$(Str$(Var7!),2)+")"
	  Endif
	  Call IO.O
	  Strng="[G]container inventory"
          If Var8! Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"(selected)"
	  Endif
	  Call IO.O
          Strng="[H]container implodes"
          If Temp8 Then
	     Strng=Strng+Space$(30-Len(Strng))
	     Strng=Strng+"(selected)"
	  Endif
	  Call IO.O
	  Graphics.Off=False
       Endif
       Strng="Container 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="Container name substring? "
	  Call IO.I
	  Out2=Lcase$(Out2)
	  Temp1$=Out2
       Case "B"
	  Temp1=True
       Case "C"
          Strng="Key number(-1=any)? "
	  Call IO.I
          Temp3!=0!
          Var!=Int(Val(Out2)+.5)
          If Var!=-1! Then
             Temp3!=-1!
          Else
             If Var!>=1! And Var!<=999999! Then
                Temp3!=Var!
             Endif
          Endif
       Case "D"
	  Temp4=True
       Case "H"
          Temp8=True
       Case "E"
          Call Find.User(0)
          If Temp5! Then
             Temp6!=Temp5!
             Temp6$=UserRecord2.CodeName
	     Temp6$=Rtrim$(Temp6$)
	     Temp6$=Lcase$(Temp6$)
	  Endif
       Case "F"
	  Strng="Room number? "
	  Call IO.I
          Var7!=Int(Val(Out2)+.5)
       Case "G"
          Call Find.Treasure
          If TempC! Then
             Var8!=TempC!
          Else
             Call Find.Object
             If TempD! Then
                Var8!=-TempD!
             Endif
          Endif
       Case "S"
          Temp5!=Lof(ContainerFile)/ContainerRecLen
          Call Get.Record.Range(Temp!,Temp2!,Temp5!)
          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
	  Allow.Break=True
	  Break=False
	  Continuous=False
          For Temp5!=Temp! To Temp2!
             Call Read.Record(ContainerFile,Temp5!)
	     TempX=False
	     If Temp1$<>Nul Then
                Out3=Rtrim$(ContainerRecord.ContainerName)
                Call InstrSUB(VarX,Out3,Temp1$)
                If VarX Then
                   VarZ1!=VarZ1!+1!
                   If VarZ2!=0! Or VarZ1!=VarZ2! Then
                      TempX=True
                   Endif
                Endif
	     Endif
	     If Temp1 Then
		If ContainerRecord.Locked Then
		   TempX=True
		Endif
	     Endif
             If Temp8 Then
                If ContainerRecord.SelfImplodes Then
		   TempX=True
		Endif
	     Endif
             If Temp3! Then
                If Temp3!=-1 Then
                   If ContainerRecord.KeyNumber>0! Then
                      TempX=True
                   Endif
                Else
                   If ContainerRecord.KeyNumber=Temp3! Then
                      TempX=True
                   Endif
                Endif
	     Endif
	     If Temp4 Then
		If ContainerRecord.InvisibleContainer Then
		   TempX=True
		Endif
	     Endif
             If Temp6! Then
                If ContainerRecord.UserNumber=Temp6! Then
		   TempX=True
		Endif
	     Endif
             If Var7! Then
                If ContainerRecord.RoomNumber=Var7! Then
		   TempX=True
		Endif
	     Endif
             If Var8! Then
                Var!=ContainerRecord.First
                If Var! Then
                   Do While Lost.Carrier=False
                      Call Read.Record(CtnInvFile,Var!)
                      If MessWorkRecord6.User=SFalse Then
                         Exit Do
                      Endif
                      Var2!=MessWorkRecord6.Next
                      If MessWorkRecord6.User=Var8! Then
                         TempX=True
                         Exit Do
                      Endif
                      If Var2!=SFalse Then
                         Exit Do
                      Endif
                      Var!=Var2!
                   Loop
                Endif
	     Endif
	     If TempX Then
                For VarQ=1 To 20
                   Call Display.Container(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
	  Next
	  Allow.Break=False
	  Break=False
	  Exit Do
       Case "Q"
	  Exit Sub
       End Select
    Loop
 Loop
ErrExit122:
 Exit Sub
ErrResume122:
 Resume ErrExit122
End Sub

Sub Undelete.Container
 On Local Error Goto ErrResume123
 Call Find.Container(0)
 If Temp5!=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(ContainerFile,Temp5!)
 If ContainerRecord.DeletedContainer=False Then
    Strng="Container not deleted."
    Call IO.O
    Exit Sub
 Endif
 ContainerRecord.DeletedContainer=False
 Call Write.Record(ContainerFile,Temp5!)
 Strng="Container undeleted."
 Call IO.O
ErrExit123:
 Exit Sub
ErrResume123:
 Resume ErrExit123
End Sub

Sub Display.Container(Var)
 On Local Error Goto ErrResume124
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="Container number"+Str$(Temp5!)+":"
 Call IO.O
 Graphics.Off=True
 Case 2
 Strng="Container name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerName))
 If ContainerRecord.DeletedContainer Then
    Strng=Strng+" (deleted)"
 Endif
 Call IO.O
 Case 3
 Strng="Short name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerShort))
 Call IO.O
 Case 4
 Strng="Container maximum:"
 If ContainerRecord.ContainerMax=True Then
    Strng=Strng+" <unlimited>"
 Else
    If ContainerRecord.ContainerMax Then
       Strng=Strng+Str$(ContainerRecord.ContainerMax)
    Else
       Strng=Strng+" <n/a>"
    Endif
 Endif
 Call IO.O
 Case 5
 Strng="Container locked: "
 If ContainerRecord.Locked Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Strng="Container is trapped: "
 If ContainerRecord.TrapType=False Then
    Strng=Strng+"No"
 Endif
 If ContainerRecord.TrapType Then
    Select Case ContainerRecord.TrapType
    Case 1
       Strng=Strng+"poison needles."
    Case 2
       Strng=Strng+"hits for"
    Case 3
       Strng=Strng+"explodes for"
    Case 4
       Strng=Strng+"shooting weapon: "
       Var1!=ContainerRecord.TrapItem
       If Var1!>SFalse And Var1!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Var1!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng=Strng+Out3
       Endif
    End Select
    Select Case ContainerRecord.TrapType
    Case 2, 3
       If ContainerRecord.TrapHits=False Then
          Strng=Strng+" no hits."
       Else
          If ContainerRecord.TrapHits>False Then
             Strng=Strng+Str$(ContainerRecord.TrapHits)+" fatigue."
          Else
             If ContainerRecord.TrapHits<False Then
                Strng=Strng+Str$(Abs(ContainerRecord.TrapHits))+" vitality."
             Endif
          Endif
       Endif
    End Select
 Endif
 Call IO.O
 Case 6
 Strng="Container key number:"
 If ContainerRecord.KeyNumber Then
    Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
 Else
    Strng=Strng+" No"
 Endif
 Call IO.O
 Case 7
 Strng="Container user owner: "
 Var1!=ContainerRecord.UserNumber
 If Var1!>SFalse And Var1!<=Lof(UserFile2)/UserRecLen Then
    Call Read.Record(UserFile2,Var1!)
    Out2=Rtrim$(UserRecord2.CodeName)
    Out2=Lcase$(Out2)
    Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
    Strng=Strng+Out2
 Else
    Strng=Strng+"None"
 Endif
 Call IO.O
 Case 8
 Strng="Container room owner:"
 If ContainerRecord.RoomNumber Then
    Strng=Strng+Str$(ContainerRecord.RoomNumber)
 Else
    Strng=Strng+" None"
 Endif
 Call IO.O
 Case 9
 Strng="Container is invisible: "
 If ContainerRecord.InvisibleContainer Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 10
 Strng="Container within other container:"
 If ContainerRecord.WithinContainer Then
    Strng=Strng+" Yes"
 Else
    Strng=Strng+" No"
 Endif
 Call IO.O
 Case 11
 Strng="Container weight:"+Str$(ContainerRecord.Weight)
 Call IO.O
 Case 12
 Temp8!=SFalse
 Var4!=ContainerRecord.First
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Var4!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Var5!=MessWorkRecord6.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Var4!=ContainerRecord.First2
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var5!=ContainerRecord.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Call Read.Record(ContainerFile,Temp5!)
 Strng="Inventory:"+Str$(Temp8!)+" items."
 Call IO.O
 Case 13
 Strng="Container prefix: "
 Strng=Strng+Rtrim$(Lcase$(ContainerRecord.NamePrefix))+" you find"
 Call IO.O
 Case 14
 Strng="Container disappears: "
 VarX!=ContainerRecord.Disappears
 If VarX! Then
    Strng=Strng+"Yes,"+Str$(VarX!)
    If VarX!>SFalse And VarX!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarX!)
       Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
    Endif
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 15
 Strng="Container size: "
 Select Case ContainerRecord.Size
 Case 1
    Strng=Strng+"Small/"
 Case 2
    Strng=Strng+"Medium/"
 Case 3
    Strng=Strng+"Large/"
 Case Else
    Strng=Strng+"Any/"
 End Select
 Select Case ContainerRecord.Material
 Case -1
    Strng=Strng+"Burnable"
 Case 1
    Strng=Strng+"Glass"
 Case 2
    Strng=Strng+"Wood"
 Case 3
    Strng=Strng+"Metal"
 Case Else
    Strng=Strng+"Paper"
 End Select
 Call IO.O
 Case 16
 Strng="Container is permanent: "
 If ContainerRecord.Permanent Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 17
 Strng="Container treasure index"
 VarA!=ContainerRecord.ContainerIndex
 If VarA!=SFalse Then
    Strng=Strng+": <none>"
 Else
    If VarA!>SFalse And VarA!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarA!)
       If TreasureRecord.Container Then
          Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Else
          Strng=Strng+"?: "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Endif
    Endif
 Endif
 Call IO.O
 Case 18
 Strng="Container self implodes: "
 If ContainerRecord.SelfImplodes Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 19
 Strng="Container restricted items: "
 VarR=False
 For VarQ=1 To 3
    VarZ=ContainerRecord.RestrictItem(VarQ)
    If VarZ Then
       VarR=True
       Strng=Strng+Ltrim$(Str$(VarZ))+", "
    Endif
 Next
 If VarR=False Then
    Strng=Strng+"No"
 Else
    Strng=Left$(Strng,Len(Strng)-2)
 Endif
 Call IO.O
 Case 20
 Strng=Strng+"ANSI Prefix code: "
 If Rtrim$(ContainerRecord.Prefix1)=Nul Then
    Strng=Strng+"<none>"
 Else
    Strng=Strng+Rtrim$(ContainerRecord.Prefix1)
 Endif
 Call IO.O
 End Select
ErrExit124:
 Exit Sub
ErrResume124:
 Resume ErrExit124
End Sub

Sub Display.Edit.Container(Var)
 On Local Error Goto ErrResume124a
 If TempC Then
    Exit Sub
 Endif
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="Container number"+Str$(Temp5!)+":"
 Call IO.O
 Graphics.Off=True
 Case 2
 Strng=RT$(99,"[A]")
 Strng=Strng+"Container name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerName))
 If ContainerRecord.DeletedContainer Then
    Strng=Strng+" (deleted)"
 Endif
 Call IO.O
 Case 3
 Strng=RT$(100,"[B]")
 Strng=Strng+"Short name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerShort))
 Call IO.O
 Case 4
 Strng=RT$(101,"[C]")
 Strng=Strng+"Container maximum:"
 If ContainerRecord.ContainerMax=True Then
    Strng=Strng+" <unlimited>"
 Else
    If ContainerRecord.ContainerMax Then
       Strng=Strng+Str$(ContainerRecord.ContainerMax)
    Else
       Strng=Strng+" <n/a>"
    Endif
 Endif
 Call IO.O
 Case 5
 Strng=RT$(102,"[D]")
 Strng=Strng+"Container locked: "
 If ContainerRecord.Locked Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 6
 Strng=RT$(103,"[E]")
 Strng=Strng+"Container is trapped: "
 If ContainerRecord.TrapType=False Then
    Strng=Strng+"No"
 Endif
 If ContainerRecord.TrapType Then
    Select Case ContainerRecord.TrapType
    Case 1
       Strng=Strng+"poison needles."
    Case 2
       Strng=Strng+"hits for"
    Case 3
       Strng=Strng+"explodes for"
    Case 4
       Strng=Strng+"shooting weapon: "
       Var1!=ContainerRecord.TrapItem
       If Var1!>SFalse And Var1!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Var1!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng=Strng+Out3
       Endif
    End Select
    Select Case ContainerRecord.TrapType
    Case 2, 3
       If ContainerRecord.TrapHits=False Then
          Strng=Strng+" no hits."
       Else
          If ContainerRecord.TrapHits>False Then
             Strng=Strng+Str$(ContainerRecord.TrapHits)+" fatigue."
          Else
             If ContainerRecord.TrapHits<False Then
                Strng=Strng+Str$(Abs(ContainerRecord.TrapHits))+" vitality."
             Endif
          Endif
       Endif
    End Select
 Endif
 Call IO.O
 Case 7
 Strng=RT$(104,"[F]")
 Strng=Strng+"Container key number:"
 If ContainerRecord.KeyNumber Then
    Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
 Else
    Strng=Strng+" No"
 Endif
 Call IO.O
 Case 8
 Strng="[*]Container user owner: "
 Var1!=ContainerRecord.UserNumber
 If Var1!>SFalse And Var1!<=Lof(UserFile2)/UserRecLen Then
    Call Read.Record(UserFile2,Var1!)
    Out2=Rtrim$(UserRecord2.CodeName)
    Out2=Lcase$(Out2)
    Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
    Strng=Strng+Out2
 Else
    Strng=Strng+"None"
 Endif
 Call IO.O
 Case 9
 Strng="[*]Container room owner:"
 If ContainerRecord.RoomNumber Then
    Strng=Strng+Str$(ContainerRecord.RoomNumber)
 Else
    Strng=Strng+" None"
 Endif
 Call IO.O
 Case 10
 Strng=RT$(107,"[I]")
 Strng=Strng+"Container is invisible: "
 If ContainerRecord.InvisibleContainer Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 11
 Strng=RT$(108,"[J]")
 Strng=Strng+"Container weight:"+Str$(ContainerRecord.Weight)
 Call IO.O
 Case 12
 Strng=RT$(109,"[K]")
 Temp8!=SFalse
 Var4!=ContainerRecord.First
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Var4!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Var5!=MessWorkRecord6.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Call Write.Record(ContainerFile,Temp5!)
 Var4!=ContainerRecord.First2
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var5!=ContainerRecord.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Call Read.Record(ContainerFile,Temp5!)
 Strng=Strng+"Inventory:"+Str$(Temp8!)+" items."
 Call IO.O
 Case 13
 Strng=RT$(110,"[L]")
 Strng=Strng+"Container prefix: "
 Strng=Strng+Rtrim$(Lcase$(ContainerRecord.NamePrefix))+" you find"
 Call IO.O
 Case 14
 Strng=RT$(111,"[M]")
 Strng=Strng+"Container disappears: "
 VarX!=ContainerRecord.Disappears
 If VarX! Then
    Strng=Strng+"Yes,"+Str$(VarX!)
    If VarX!>SFalse And VarX!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarX!)
       Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
    Endif
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 15
 Strng=RT$(112,"[N]")
 Strng=Strng+"Container size: "
 Select Case ContainerRecord.Size
 Case 1
    Strng=Strng+"Small/"
 Case 2
    Strng=Strng+"Medium/"
 Case 3
    Strng=Strng+"Large/"
 Case Else
    Strng=Strng+"Any/"
 End Select
 Select Case ContainerRecord.Material
 Case -1
    Strng=Strng+"Burnable"
 Case 1
    Strng=Strng+"Glass"
 Case 2
    Strng=Strng+"Wood"
 Case 3
    Strng=Strng+"Metal"
 Case Else
    Strng=Strng+"Paper"
 End Select
 Call IO.O
 Case 16
 Strng=RT$(113,"[O]")
 Strng=Strng+"Container is permanent: "
 If ContainerRecord.Permanent Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 17
 Strng=RT$(114,"[P]")
 Strng=Strng+"Container treasure index"
 VarA!=ContainerRecord.ContainerIndex
 If VarA!=SFalse Then
    Strng=Strng+": <none>"
 Else
    If VarA!>SFalse And VarA!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarA!)
       If TreasureRecord.Container Then
          Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Else
          Strng=Strng+"?: "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Endif
    Endif
 Endif
 Call IO.O
 Case 18
 Strng=RT$(115,"[R]")
 Strng=Strng+"Container self implodes: "
 If ContainerRecord.SelfImplodes Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 19
 Strng=RT$(116,"[S]")
 Strng=Strng+"Container restricted items: "
 VarR=False
 For VarQ=1 To 3
    VarZ=ContainerRecord.RestrictItem(VarQ)
    If VarZ Then
       VarR=True
       Strng=Strng+Ltrim$(Str$(VarZ))+", "
    Endif
 Next
 If VarR=False Then
    Strng=Strng+"No"
 Else
    Strng=Left$(Strng,Len(Strng)-2)
 Endif
 Call IO.O
 Case 20
 Strng=RT$(117,"[T]")
 Strng=Strng+"ANSI Prefix code: "
 If Rtrim$(ContainerRecord.Prefix1)=Nul Then
    Strng=Strng+"<none>"
 Else
    Strng=Strng+Rtrim$(ContainerRecord.Prefix1)
 Endif
 Call IO.O
 End Select
ErrExit124a:
 Exit Sub
ErrResume124a:
 Resume ErrExit124a
End Sub

Sub Print.Container(Var)
 On Local Error Goto ErrResume124b
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="Container number"+Str$(Temp5!)+":"
 Print #TempFile1,Strng
 Graphics.Off=True
 Case 2
 Strng="Container name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerName))
 If ContainerRecord.DeletedContainer Then
    Strng=Strng+" (deleted)"
 Endif
 Print #TempFile1,Strng
 Case 3
 Strng="Short name: "+_
 Lcase$(Rtrim$(ContainerRecord.ContainerShort))
 Print #TempFile1,Strng
 Case 4
 Strng="Container maximum:"
 If ContainerRecord.ContainerMax=True Then
    Strng=Strng+" <unlimited>"
 Else
    If ContainerRecord.ContainerMax Then
       Strng=Strng+Str$(ContainerRecord.ContainerMax)
    Else
       Strng=Strng+" <n/a>"
    Endif
 Endif
 Print #TempFile1,Strng
 Case 5
 Strng="Container locked: "
 If ContainerRecord.Locked Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Strng="Container is trapped: "
 If ContainerRecord.TrapType=False Then
    Strng=Strng+"No"
 Endif
 If ContainerRecord.TrapType Then
    Select Case ContainerRecord.TrapType
    Case 1
       Strng=Strng+"poison needles."
    Case 2
       Strng=Strng+"hits for"
    Case 3
       Strng=Strng+"explodes for"
    Case 4
       Strng=Strng+"shooting weapon: "
       Var1!=ContainerRecord.TrapItem
       If Var1!>SFalse And Var1!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Var1!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng=Strng+Out3
       Endif
    End Select
    Select Case ContainerRecord.TrapType
    Case 2, 3
       If ContainerRecord.TrapHits=False Then
          Strng=Strng+" no hits."
       Else
          If ContainerRecord.TrapHits>False Then
             Strng=Strng+Str$(ContainerRecord.TrapHits)+" fatigue."
          Else
             If ContainerRecord.TrapHits<False Then
                Strng=Strng+Str$(Abs(ContainerRecord.TrapHits))+" vitality."
             Endif
          Endif
       Endif
    End Select
 Endif
 Print #TempFile1,Strng
 Case 6
 Strng="Container key number:"
 If ContainerRecord.KeyNumber Then
    Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
 Else
    Strng=Strng+" No"
 Endif
 Print #TempFile1,Strng
 Case 7
 Strng="Container user owner: "
 Var1!=ContainerRecord.UserNumber
 If Var1!>SFalse And Var1!<=Lof(UserFile2)/UserRecLen Then
    Call Read.Record(UserFile2,Var1!)
    Out2=Rtrim$(UserRecord2.CodeName)
    Out2=Lcase$(Out2)
    Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
    Strng=Strng+Out2
 Else
    Strng=Strng+"None"
 Endif
 Print #TempFile1,Strng
 Case 8
 Strng="Container room owner:"
 If ContainerRecord.RoomNumber Then
    Strng=Strng+Str$(ContainerRecord.RoomNumber)
 Else
    Strng=Strng+" None"
 Endif
 Print #TempFile1,Strng
 Case 9
 Strng="Container is invisible: "
 If ContainerRecord.InvisibleContainer Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Case 10
 Strng="Container within other container:"
 If ContainerRecord.WithinContainer Then
    Strng=Strng+" Yes"
 Else
    Strng=Strng+" No"
 Endif
 Print #TempFile1,Strng
 Case 11
 Strng="Container weight:"+Str$(ContainerRecord.Weight)
 Print #TempFile1,Strng
 Case 12
 Temp8!=SFalse
 Var4!=ContainerRecord.First
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Var4!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Var5!=MessWorkRecord6.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Var4!=ContainerRecord.First2
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var5!=ContainerRecord.Next
       Temp8!=Temp8!+1!
       If Var5!=SFalse Then
          Exit Do
       Endif
       Var4!=Var5!
    Loop
 Endif
 Strng="Inventory:"+Str$(Temp8!)+" items."
 Print #TempFile1,Strng
 Case 13
 Strng="Container prefix: "
 Strng=Strng+Rtrim$(Lcase$(ContainerRecord.NamePrefix))+" you find"
 Print #TempFile1,Strng
 Case 14
 Strng="Container disappears: "
 VarX!=ContainerRecord.Disappears
 If VarX! Then
    Strng=Strng+"Yes,"+Str$(VarX!)
    If VarX!>SFalse And VarX!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarX!)
       Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
    Endif
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Case 15
 Strng="Container size: "
 Select Case ContainerRecord.Size
 Case 1
    Strng=Strng+"Small/"
 Case 2
    Strng=Strng+"Medium/"
 Case 3
    Strng=Strng+"Large/"
 Case Else
    Strng=Strng+"Any/"
 End Select
 Select Case ContainerRecord.Material
 Case -1
    Strng=Strng+"Burnable"
 Case 1
    Strng=Strng+"Glass"
 Case 2
    Strng=Strng+"Wood"
 Case 3
    Strng=Strng+"Metal"
 Case Else
    Strng=Strng+"Paper"
 End Select
 Print #TempFile1,Strng
 Case 16
 Strng="Container is permanent: "
 If ContainerRecord.Permanent Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Case 17
 Strng="Container treasure index"
 VarA!=ContainerRecord.ContainerIndex
 If VarA!=SFalse Then
    Strng=Strng+": <none>"
 Else
    If VarA!>SFalse And VarA!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarA!)
       If TreasureRecord.Container Then
          Strng=Strng+": "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Else
          Strng=Strng+"?: "+Rtrim$(Lcase$(TreasureRecord.TreasureName))
       Endif
    Endif
 Endif
 Print #TempFile1,Strng
 Case 18
 Strng="Container self implodes: "
 If ContainerRecord.SelfImplodes Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Case 19
 Strng="Container restricted items: "
 VarR=False
 For VarQ=1 To 3
    VarZ=ContainerRecord.RestrictItem(VarQ)
    If VarZ Then
       VarR=True
       Strng=Strng+Ltrim$(Str$(VarZ))+", "
    Endif
 Next
 If VarR=False Then
    Strng=Strng+"No"
 Else
    Strng=Left$(Strng,Len(Strng)-2)
 Endif
 Print #TempFile1,Strng
 End Select
ErrExit124b:
 Exit Sub
ErrResume124b:
 Resume ErrExit124b
End Sub

Sub Find.Container(Var)
 On Local Error Goto ErrResume125
 If Var=False Then
    Temp5!=SFalse
 Else
    TempD!=SFalse
 Endif
 Strng="Container name, or number"
 Strng=Strng+"(1-"+Mid$(Str$(Lof(ContainerFile)/ContainerRecLen),2)+")? "
 No.Input.Out="1"
 Call IO.I
 If Out2=Nul Then
    Exit Sub
 Endif
 Temp7!=SFalse
 Out2=Lcase$(Out2)
 If Instr(Out2,"#") Then
    Temp7!=Val(Mid$(Out2,Instr(Out2,"#")+1))
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempQ!=SFalse
 For Var2!=1! To Lof(ContainerFile)/ContainerRecLen
    Call Read.Record(ContainerFile,Var2!)
    Strng=Rtrim$(ContainerRecord.ContainerName)
    Var3$=Out2
    Call InstrSUB4(VarX,Var3$,0)
    If VarX Then
       TempQ!=TempQ!+1!
       If Temp7!=SFalse Or TempQ!=Temp7! Then
          Goto Exit125
       Endif
    Endif
 Next
 Var2!=Int(Val(Out2)+.5)
 If Var2!<1! Or Var2!>Lof(ContainerFile)/ContainerRecLen Then
    Var2!=SFalse
    Strng="Container name not found."
    Call IO.O
 Else
    Call Read.Record(ContainerFile,Var2!)
 Endif
Exit125:
 If Var=False Then
    Temp5!=Var2!
 Else
    TempD!=Var2!
 Endif
ErrExit125:
 Exit Sub
ErrResume125:
 Resume ErrExit125
End Sub

' add container to containr.dat
Sub Add.Container.To.Container
 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)? "
 Line.Length=TempD
 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=0!
 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!)
 Call Read.Record(ContainerFile,Temp5!)
 If ContainerRecord.First2=SFalse Then
    ContainerRecord.First2=VarA!
    ContainerRecord.Last2=VarA!
    Call Write.Record(ContainerFile,Temp5!)
    Call Read.Record(ContainerFile,VarA!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    ContainerRecord.WithinContainer=True
    Call Write.Record(ContainerFile,VarA!)
 Else
    VarR!=ContainerRecord.Last2
    Call Read.Record(ContainerFile,VarA!)
    ContainerRecord.Prev=VarR!
    ContainerRecord.Next=SFalse
    ContainerRecord.WithinContainer=True
    Call Write.Record(ContainerFile,VarA!)
    Call Read.Record(ContainerFile,VarR!)
    ContainerRecord.Next=VarA!
    Call Write.Record(ContainerFile,VarR!)
    Call Read.Record(ContainerFile,Temp5!)
    ContainerRecord.Last2=VarA!
    Call Write.Record(ContainerFile,Temp5!)
    Call Read.Record(ContainerFile,VarA!)
 Endif
ErrExit141f:
 Exit Sub
ErrResume141f:
 Resume ErrExit141f
End Sub

Sub Find.Object2
 On Local Error Goto ErrResume105
 TempD!=SFalse
 Strng="Object name, or number"
 Strng=Strng+"(0-"+Mid$(Str$(Lof(ObjectFile)/ObjectRecLen),2)+")? "
 No.Input.Out="0"
 Call IO.I
 If Out2=Nul Then
    Exit Sub
 Endif
 Out2=Lcase$(Out2)
 Temp7!=SFalse
 If Instr(Out2,"#") Then
    Temp7!=Val(Mid$(Out2,Instr(Out2,"#")+1))
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempQ!=SFalse
 For Var2!=1! To Lof(ObjectFile)/ObjectRecLen
    Call Read.Record(ObjectFile,Var2!)
    Strng=Rtrim$(ObjectRecord.ObjectName)
    Var3$=Out2
    Call InstrSUB4(VarX,Var3$,0)
    If VarX Then
       TempQ!=TempQ!+1!
       If Temp7!=SFalse Or TempQ!=Temp7! Then
          Goto Exit105
       Endif
    Endif
 Next
 Var2!=Int(Val(Out2)+.5)
 If Var2!<=SFalse Or Var2!>Lof(ObjectFile)/ObjectRecLen Then
    Var2!=SFalse
 Else
    Call Read.Record(ObjectFile,Var2!)
 Endif
Exit105:
 TempD!=Var2!
ErrExit105:
 Exit Sub
ErrResume105:
 Resume ErrExit105
End Sub

Sub Find.Treasure2
 On Local Error Goto ErrResume106
 TempC!=SFalse
 Strng="Treasure name, or number"
 Strng=Strng+"(0-"+Mid$(Str$(Lof(TreasureFile)/TreasureRecLen),2)+")? "
 No.Input.Out="0"
 Call IO.I
 If Out2=Nul Then
    Exit Sub
 Endif
 Out2=Lcase$(Out2)
 Temp7!=SFalse
 If Instr(Out2,"#") Then
    Temp7!=Val(Mid$(Out2,Instr(Out2,"#")+1))
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempQ!=SFalse
 For Var2!=1! To Lof(TreasureFile)/TreasureRecLen
    Call Read.Record(TreasureFile,Var2!)
    Strng=Rtrim$(TreasureRecord.TreasureName)
    Var3$=Out2
    Call InstrSUB4(VarX,Var3$,0)
    If VarX Then
       TempQ!=TempQ!+1!
       If Temp7!=SFalse Or TempQ!=Temp7! Then
          Goto Exit106
       Endif
    Endif
 Next
 Var2!=Int(Val(Out2)+.5)
 If Var2!<=SFalse Or Var2!>Lof(TreasureFile)/TreasureRecLen Then
    Var2!=SFalse
 Else
    Call Read.Record(TreasureFile,Var2!)
 Endif
Exit106:
 TempC!=Var2!
ErrExit106:
 Exit Sub
ErrResume106:
 Resume ErrExit106
End Sub
