 Rem File: Contain.bas - for Cmd*.bas modules
 Rem $Include: 'dndbbs.inc'

 Rem Includes all container subroutines.

Sub Search.Container
 On Local Error Goto ErrTrap41
 Call Examine.Containers
 If TempA!=SFalse Then
    Strng="You can't search that!"
    Call IO.O
    Exit Sub
 Endif
 Call Display.Container(Nul)
ErrResume41:
 Exit Sub
ErrTrap41:
 Resume ErrResume41
End Sub

Sub Search.Container2
 On Local Error Goto ErrTrap41x
 Gosub Get.Config
 VarA$=Parsed.Command1
 VarB$=Parsed.Command2
 Call ParseX
 ' parsed.command1=user
 ' parsed.command2=box
 Call Numeric
 ' online user
 Call Search.Mess(SFalse)
 If Temp!=Room And TempB!<>User.Index Then
    VarY=TempC ' node
    VarB!=TempB!
    Out2=MessWorkRecord1.UserName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Var3$=Out2
    Parsed.Command1=Parsed.Command2
    Call Numeric
    Call Search.User.Container2
    If TempA!<>SFalse Then
       If ContainerRecord.Damaged=True Then
          Strng="You can't, it's damaged."
          Call IO.O
          Exit Sub
       Endif
       If ContainerRecord.Locked=True Then
          Strng="You can't, it's locked."
          Call IO.O
          Exit Sub
       Endif
       If ContainerRecord.Locked=1 Then
          If ContainerRecord.Closed Then
             Strng="You can't, it's closed."
             Call IO.O
             Exit Sub
          Endif
       Endif
       VarQ2=ContainerRecord.TrapType
       VarQ3=ContainerRecord.TrapHits
       VarQ4!=ContainerRecord.TrapItem
       Var2$=ContainerRecord.ContainerShort
       Var2$=Rtrim$(Var2$)
       Var2$=Lcase$(Var2$)
       VarZ$=Var2$
       If Normal.User Then
          If UserRecord2.ClassType>=Lady Then
             Strng3=Rtrim$(Class.Name(UserRecord2.ClassType))
             Call A.Or.An
             Strng="You can't search "+Prefix1+Strng3+"."
             Call IO.O
             Exit Sub
          Endif
          If UserRecord.ClassType<AsstDM Then
             If UserRecord.ClassType<>Thief Then
                If option1 Then
                   Strng="Only thieves can search containers!"
                   Call IO.O
                   Exit Sub
                Endif
             Else
                If UserRecord.Level<option2 Then
                   Strng="Only level"+Str$(option2)+" thieves can search containers!"
                   Call IO.O
                   Exit Sub
                Endif
             Endif
          Endif
       Endif
       Call ContainerTraps(VarQ2,VarQ3,VarQ4!,VarZ$)
       If VarQ2=-1 Then ' *boom*
          Exit Sub
       Endif
       Call Display.Container(Var3$)
       Exit Sub
    Endif
    Strng="You can't search that user!"
    Call IO.O
    Exit Sub
 Endif
 Parsed.Command1=VarA$
 Parsed.Command2=VarB$
 ' look box user
 Call ParseX
 ' parsed.command1=user
 ' parsed.command2=box
 Call Numeric
 ' offline users
 Call Check.User
 If User.Temp Then
    Var3$=Out3
    Parsed.Command1=Parsed.Command2
    Call Numeric
    TempB!=MessWorkRecord4.Index
    Call Search.User.Container2
    If TempA!<>SFalse Then
       If ContainerRecord.Damaged=True Then
          Strng="You can't, it's damaged."
          Call IO.O
          Exit Sub
       Endif
       If ContainerRecord.Locked=True Then
          Strng="You can't, it's locked."
          Call IO.O
          Exit Sub
       Endif
       If ContainerRecord.Locked=1 Then
          If ContainerRecord.Closed Then
             Strng="You can't, it's closed."
             Call IO.O
             Exit Sub
          Endif
       Endif
       VarQ2=ContainerRecord.TrapType
       VarQ3=ContainerRecord.TrapHits
       VarQ4!=ContainerRecord.TrapItem
       Var2$=ContainerRecord.ContainerShort
       Var2$=Rtrim$(Var2$)
       Var2$=Lcase$(Var2$)
       VarZ$=Var2$
       If Normal.User Then
          If UserRecord2.ClassType>=Lady Then
             Strng3=Rtrim$(Class.Name(UserRecord2.ClassType))
             Call A.Or.An
             Strng="You can't search "+Prefix1+Strng3+"."
             Call IO.O
             Exit Sub
          Endif
          If UserRecord.ClassType<AsstDM Then
             If UserRecord.ClassType<>Thief Then
                If option3 Then
                   Strng="Only thieves can search containers!"
                   Call IO.O
                   Exit Sub
                Endif
             Else
                If UserRecord.Level<option4 Then
                   Strng="Only level"+Str$(option4)+" thieves can search containers!"
                   Call IO.O
                   Exit Sub
                Endif
             Endif
          Endif
       Endif
       Call ContainerTraps(VarQ2,VarQ3,VarQ4!,VarZ$)
       If VarQ2=-1 Then ' *boom*
          Exit Sub
       Endif
       Call Display.Container(Var3$)
       Exit Sub
    Endif
 Endif
 Strng="You can't search that user!"
 Call IO.O
 Exit Sub
Get.Config:
 option1=-1
 option2=10
 option3=-1
 option4=10
 VarX=0
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CONTAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Select Case Lcase$(Var2$)
             Case "only.thieves.can.search.online.user"
                Select Case Lcase$(Var3$)
                Case "0", "false", "off"
                   option1=0
                End Select
             Case "search.container.level.online.user"
                option2=Int(Val(Var3$)+.5)
             Case "only.thieves.can.search.offline.user"
                Select Case Lcase$(Var3$)
                Case "0", "false", "off"
                   option3=0
                End Select
             Case "search.container.level.offline.user"
                option4=Int(Val(Var3$)+.5)
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrResume41x:
 Exit Sub
ErrTrap41x:
 Resume ErrResume41x
End Sub

Sub Display.Container(Var$)
 On Local Error Goto ErrTrap41z
 Graphics.Off=True
 Strng2=Rtrim$(ContainerRecord.Prefix1)
 Strng3=Lcase$(Rtrim$(ContainerRecord.ContainerShort))
 If Var$=Nul Then
    Strng="You search the "+Strng2+Strng3
 Else
    Var$=Lcase$(Var$)
    Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
    Strng="You search "+Var$+"'s "+Strng2+Strng3
 Endif
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Graphics.Off=True
 If ContainerRecord.InvisibleContainer Then
    Strng=Strng+" [inv]"
 Endif
 Strng=".."
 Call IO.O
 Graphics.Off=True
 Strng=Rtrim$(ContainerRecord.NamePrefix)
 Strng=Lcase$(Strng)
 Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Strng=Strng+" you find "
 Carriage.Return=True
 Call IO.O
 Strng2=Nul
 Temp9=False
 Temp5!=ContainerRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Temp5!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       Temp7!=MessWorkRecord6.User
       If Temp7! Then
          Temp6=True
       Else
          Temp6=False
       Endif
       If MessWorkRecord6.Plus Then
          If Rnd<Config1(11) Then
             Temp6=True
          Else
             Temp6=False
          Endif
          If Sysop Then
             Temp6=True
          Endif
       Endif
       If Temp6 Then
          Temp9=Temp9+1
          Carriage.Return=True
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Len(Strng2) Then
             Carriage.Return=True
             Strng=Strng2
             Call IO.O
          Endif
          Graphics.On=False
          Strng2=Nul
          If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(TreasureFile,Temp7!)
             Strng=Rtrim$(TreasureRecord.Prefix1)
             Strng=Strng+Rtrim$(TreasureRecord.TreasureName)
             If TreasureRecord.LightType Then
                If MessWorkRecord6.Charges<False Then
                   Strng2=Strng2+" [lit]"
                Endif
             Endif
          Endif
          If Temp7!<SFalse Then
             Temp7!=Abs(Temp7!)
             If Temp7!>SFalse And Temp7!<=Lof(ObjectFile)/ObjectRecLen Then
                Call Read.Record(ObjectFile,Temp7!)
                Strng=Rtrim$(ObjectRecord.Prefix1)
                Strng=Strng+Rtrim$(ObjectRecord.ObjectName)
             Endif
          Endif
          If MessWorkRecord6.Plus Then
             Strng2=Strng2+" [inv]"
          Endif
          Strng2=Strng2+", "
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 Temp5!=ContainerRecord.First2
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Temp5!)
       Temp6!=ContainerRecord.Next
       Temp6=True
       If ContainerRecord.UserNumber=SFalse Then
          If ContainerRecord.RoomNumber=SFalse Then
             Temp6=False
          Endif
       Endif
       If ContainerRecord.WithinContainer Then
          Temp6=True
       Endif
       If Temp6 Then
          If ContainerRecord.InvisibleContainer Then
             If Rnd<Config1(11) Then
                Temp6=True
             Else
                Temp6=False
             Endif
             If Sysop Then
                Temp6=True
             Endif
          Endif
          If ContainerRecord.DeletedContainer Then
             Temp6=False
          Endif
       Endif
       If Temp6 Then
          Carriage.Return=True
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Len(Strng2) Then
             Carriage.Return=True
             Strng=Strng2
             Call IO.O
          Endif
          Strng=Rtrim$(ContainerRecord.Prefix1)
          Strng=Strng+Rtrim$(Lcase$(ContainerRecord.ContainerName))
          Strng2=Nul
          If ContainerRecord.InvisibleContainer Then
             Strng2=Strng2+" [inv]"
          Endif
          Strng2=Strng2+", "
          Temp9=Temp9+1
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 If Temp9=False Then
    Strng="nothing.."
 Else
    If Temp9>1 Then
       Strng="and "+Strng
    Endif
 Endif
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 If Len(Strng2) Then
    Strng=Left$(Strng2,Len(Strng2)-2)+"."
 Else
    Strng="."
 Endif
 Call IO.O
ErrResume41z:
 Exit Sub
ErrTrap41z:
 Resume ErrResume41z
End Sub

Sub Examine.Containers
 On Local Error Goto ErrorTrp22
 Temp4=False
 Call Search.Room.Containers
 If TempA!=SFalse Then
    Call Num
    Temp4=True
    Call Search.User.Containers
 Endif
ErrorRsm22:
 Exit Sub
ErrorTrp22:
 Resume ErrorRsm22
End Sub

Sub Search.Room.Containers
 On Local Error Goto ErrorTrp23
 Temp6=False
 Temp7!=SFalse
 TempC=False
 TempA!=SFalse
 If Parsed.Command1<>Nul Then
    Temp5!=RoomRecord.First2
    If Temp5! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp5!)
          Var6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Out3=ContainerRecord.ContainerShort
                Out3=Left$(Out3,Len(Parsed.Command1))
                If Out3=Parsed.Command1 Then
                   TempC=TempC+1
                   If Parse.Temp=False Or TempC=Parse.Temp Then
                      Out3=ContainerRecord.ContainerName
                      Out3=Rtrim$(Out3)
                      TempA!=Temp5!
                      Exit Sub
                   Endif
                Endif
             Endif
          Endif
          If Var6!=SFalse Then
             Exit Do
          Endif
          Temp5!=Var6!
       Loop
    Endif
 Endif
ErrorRsm23:
 Exit Sub
ErrorTrp23:
 Resume ErrorRsm23
End Sub

Sub Search.User.Containers
 On Local Error Goto ErrorTrp24
 Temp6=False
 Temp7!=SFalse
 TempC=False
 TempA!=SFalse
 If Parsed.Command1<>Nul Then
    Temp5!=UserRecord.First2
    If Temp5! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp5!)
          Var6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Out3=ContainerRecord.ContainerShort
                Out3=Left$(Out3,Len(Parsed.Command1))
                If Out3=Parsed.Command1 Then
                   TempC=TempC+1
                   If Parse.Temp=False Or TempC=Parse.Temp Then
                      Out3=ContainerRecord.ContainerName
                      Out3=Rtrim$(Out3)
                      TempA!=Temp5!
                      Exit Sub
                   Endif
                Endif
             Endif
          Endif
          If Var6!=SFalse Then
             Exit Do
          Endif
          Temp5!=Var6!
       Loop
    Endif
 Endif
ErrorRsm24:
 Exit Sub
ErrorTrp24:
 Resume ErrorRsm24
End Sub

Sub Search.User.Container2
 On Local Error Goto ErrorTrp24c
 Temp6=False
 Temp7!=SFalse
 TempC=False
 TempA!=SFalse
 If Parsed.Command1<>Nul Then
    Call Read.Record(UserFile2,TempB!)
    Temp5!=UserRecord2.First2
    If Temp5! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp5!)
          Var6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Out3=ContainerRecord.ContainerShort
                Out3=Left$(Out3,Len(Parsed.Command1))
                If Out3=Parsed.Command1 Then
                   TempC=TempC+1
                   If Parse.Temp=False Or TempC=Parse.Temp Then
                      Out3=ContainerRecord.ContainerName
                      Out3=Rtrim$(Out3)
                      TempA!=Temp5!
                      Exit Sub
                   Endif
                Endif
             Endif
          Endif
          If Var6!=SFalse Then
             Exit Do
          Endif
          Temp5!=Var6!
       Loop
    Endif
 Endif
ErrorRsm24c:
 Exit Sub
ErrorTrp24c:
 Resume ErrorRsm24c
End Sub

Sub Search.In.Container
 On Local Error Goto ErrorTrp24a
 Temp6=False
 Temp7!=SFalse
 TempC=False
 TempB!=SFalse
 Temp5!=ContainerRecord.First2
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Temp5!)
       Var6!=ContainerRecord.Next
       Temp8=True
       If ContainerRecord.UserNumber=SFalse Then
          If ContainerRecord.RoomNumber=SFalse Then
             Temp8=False
          Endif
       Endif
       If ContainerRecord.WithinContainer Then
          Temp8=True
       Endif
       If Temp8 Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerShort
             Out3=Left$(Out3,Len(Parsed.Command1))
             If Out3=Parsed.Command1 Then
                TempC=TempC+1
                If Parse.Temp=False Or TempC=Parse.Temp Then
                   Out3=ContainerRecord.ContainerName
                   Out3=Rtrim$(Out3)
                   TempB!=Temp5!
                   Exit Do
                Endif
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Var6!
    Loop
 Endif
ErrorRsm24a:
 Exit Sub
ErrorTrp24a:
 Resume ErrorRsm24a
End Sub

Sub Find.In.Container
 On Local Error Goto ErrorTrp13b
 Parse.Temp=Temp2
 Temp6=False
 Temp7!=SFalse
 TempC=False
 Call Read.Record(ContainerFile,TempA!)
 Temp5!=ContainerRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Temp5!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       TempB!=MessWorkRecord6.User
       If TempB!<SFalse Then
          TempB!=Abs(TempB!)
          If TempB!>SFalse And TempB!<=Lof(ObjectFile)/ObjectRecLen Then
             Call Read.Record(ObjectFile,TempB!)
             Out3=ObjectRecord.ShortName
             Out3=Left$(Out3,Len(Parsed.Command1))
             If Out3=Parsed.Command1 Then
                TempC=TempC+1
                If Parse.Temp=False Or TempC=Parse.Temp Then
                   Out3=ObjectRecord.ObjectName
                   Out3=Rtrim$(Out3)
                   Temp7!=-TempB!
                   Temp6=MessWorkRecord6.Charges
                   Exit Do
                Endif
             Endif
          Endif
       Endif
       If TempB!>SFalse And TempB!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,TempB!)
          Out3=TreasureRecord.ShortName
          Out3=Left$(Out3,Len(Parsed.Command1))
          If Out3=Parsed.Command1 Then
             TempC=TempC+1
             If Parse.Temp=False Or TempC=Parse.Temp Then
                Out3=TreasureRecord.TreasureName
                Out3=Rtrim$(Out3)
                Temp7!=TempB!
                Temp6=MessWorkRecord6.Charges
                Exit Do
             Endif
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
ErrorRsm13b:
 Exit Sub
ErrorTrp13b:
 Resume ErrorRsm13b
End Sub

Sub Check.Container.Item
 On Local Error Goto ErrorTrp13d
 Temp6=False
 Temp7!=SFalse
 Call Read.Record(ContainerFile,TempA!)
 Temp5!=ContainerRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Temp5!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       TempB!=MessWorkRecord6.User
       If TempB!>SFalse And TempB!<=Lof(TreasureFile)/TreasureRecLen Then
          If TempB!=TempC! Then
             Call Read.Record(TreasureFile,TempB!)
             Out3=TreasureRecord.TreasureName
             Out3=Rtrim$(Out3)
             Temp7!=TempB!
             Temp6=MessWorkRecord6.Charges
             Exit Do
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
ErrorRsm13d:
 Exit Sub
ErrorTrp13d:
 Resume ErrorRsm13d
End Sub

Sub ContainerTraps(VarQ2,VarQ3,VarQ4!,VarZ$)
 On Local Error Goto ErrorTrap42
 VarX1=Temp4
 VarA!=TempA!
 New.Room=False
 If VarQ2 Then
    If Node>False Then
       Out2=UserRecord.CodeName
       Out2=Rtrim$(Out2)
       Out2=Lcase$(Out2)
       Out2=Out2+" was just hit by a trap."
       Call Send.Mess(8,SFalse,Room,Out2)
    Endif
 Endif
 If VarQ2=1 Then ' poison
    Gosub CheckRingHits
    If VarX Then
       Exit Sub
    Endif
    Strng="You have been poisoned!"
    Call IO.O
    UserRecord.Poison=-1
    Exit Sub
 Endif
 If VarQ2=2 Then ' hits fat/vit
    Gosub CheckRingHits
    If VarX Then
       Exit Sub
    Endif
    If VarQ3 Then
       Strng="As you access the "+VarZ$+","
       Call IO.O
       Strng="You are hit for"
       Prefix2=Nul
       Out3="accessing an item"
       Call Hit.Player(VarQ3)
    Endif
    Exit Sub
 Endif
 If VarQ2=3 Then ' explodes
    Gosub CheckRingHits
    If VarX=False Then
       If VarQ3 Then
          Strng="As you access the "+VarZ$+","
          Call IO.O
          Strng="You are hit for"
          Prefix2=Nul
          Out3="accessing an item"
          Call Hit.Player(VarQ3)
       Endif
    Endif
    ' container explodes
    Select Case VarX1
    Case False
       Call Read.Record(ContainerFile,VarA!)
       Call Delete.Room.Container(VarA!)
       Call Clear.Container
       Call Write.Record(ContainerFile,VarA!)
       Strng="*Boom* the "+VarZ$+" explodes!"
       Call IO.O
       VarQ2=-1
    Case True
       Call Read.Record(ContainerFile,VarA!)
       Weight=Weight-ContainerRecord.Weight
       If Weight<DFalse Then
          Weight=DFalse
       Endif
       Call Delete.User.Container(VarA!)
       Call Clear.Container
       Call Write.Record(ContainerFile,VarA!)
       Strng="*Boom* the "+VarZ$+" explodes!"
       Call IO.O
       VarQ2=-1
    End Select
    Exit Sub
 Endif
 If VarQ2=4 Then ' shooting weapon
    If VarQ4!>SFalse And VarQ4!<=Lof(TreasureFile)/TreasureRecLen Then
       TempA!=VarA!
       TempC!=VarQ4!
       Call Check.Container.Item
       If Temp7! Then
          Out3=Lcase$(Out3)
          Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
          Strng=Out3+" shoots out of the "+VarZ$+"!"
          Call IO.O
          If TreasureRecord.Container Then
             Call Drop.Container.In.Room(Temp7!)
          Else
             Call Drop.Inventory(Temp7!,Temp6)
          Endif
          Call Delete.List.Node5(Temp5!)
          Call Clear.List.Node
          Call Write.Record(CtnInvFile,Temp5!)
          If TreasureRecord.Container Then
             Exit Sub
          Endif
          ' check rings
          If TreasureRecord.WeaponNumber=7 Then
             Gosub CheckRingHits
             If VarX Then
                Exit Sub
             Endif
             VarQ3=TreasureRecord.Plus
             If VarQ3>False Then
                Strng="As you access the "+VarZ$+","
                Call IO.O
                Strng="You are hit for"
                Prefix2=Nul
                Out3="accessing an item"
                Call Hit.Player(VarQ3)
             Endif
          Endif
       Endif
    Endif
 Endif
 Exit Sub

' check rings
CheckRingHits:
 VarX=0
 Var2!=UserRecord.Weapon(4).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=4 Then
       Call Get.Ring.Hits(True,4)
       VarX=-1
       Return
    Endif
 Endif
 Var2!=UserRecord.Weapon(9).Index
 If Var2! Then
    Call Read.Record(TreasureFile,Var2!)
    If TreasureRecord.RingType=4 Then
       Call Get.Ring.Hits(False,4)
       VarX=-1
       Return
    Endif
 Endif
 Return
ErrorResume42:
 Exit Sub
ErrorTrap42:
 Resume ErrorResume42
End Sub

Sub Delete.List.Node5(VarZ!)
 On Local Error Goto ErrorTrp32x
 If ContainerRecord.First=VarZ! Then
    Call Read.Record(CtnInvFile,VarZ!)
    ContainerRecord.First=MessWorkRecord6.Next
    Call Write.Record(ContainerFile,TempA!)
    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,TempA!)
       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
ErrorRsm32x:
 Exit Sub
ErrorTrp32x:
 Resume ErrorRsm32x
End Sub

Sub Delete.User.Container(VarZ!)
 On Local Error Goto ErrorTrp32e
 If UserRecord.First2=VarZ! Then
    Call Read.Record(ContainerFile,VarZ!)
    UserRecord.First2=ContainerRecord.Next
    Call Write.Record(UserFile,User.Index)
    If UserRecord.First2>SFalse Then
       Call Read.Record(ContainerFile,UserRecord.First2)
       ContainerRecord.Prev=SFalse
       Call Write.Record(ContainerFile,UserRecord.First2)
    Endif
 Else
    If UserRecord.Last2=VarZ! Then
       Call Read.Record(ContainerFile,VarZ!)
       UserRecord.Last2=ContainerRecord.Prev
       Call Write.Record(UserFile,User.Index)
       If UserRecord.Last2>SFalse Then
          Call Read.Record(ContainerFile,UserRecord.Last2)
          ContainerRecord.Next=SFalse
          Call Write.Record(ContainerFile,UserRecord.Last2)
       Endif
    Else
       Call Read.Record(ContainerFile,VarZ!)
       Previous.Node!=ContainerRecord.Prev
       Next.Node!=ContainerRecord.Next
       Call Read.Record(ContainerFile,Previous.Node!)
       ContainerRecord.Next=Next.Node!
       Call Write.Record(ContainerFile,Previous.Node!)
       Call Read.Record(ContainerFile,Next.Node!)
       ContainerRecord.Prev=Previous.Node!
       Call Write.Record(ContainerFile,Next.Node!)
    Endif
 Endif
ErrorRsm32e:
 Exit Sub
ErrorTrp32e:
 Resume ErrorRsm32e
End Sub

Sub Delete.User.Container3(VarZ!)
 On Local Error Goto ErrorTrp32g
 Call Read.Record(UserFile2,TempB!)
 If UserRecord2.First2=VarZ! Then
    Call Read.Record(ContainerFile,VarZ!)
    UserRecord2.First2=ContainerRecord.Next
    Call Write.Record(UserFile2,TempB!)
    If UserRecord2.First2>SFalse Then
       Call Read.Record(ContainerFile,UserRecord2.First2)
       ContainerRecord.Prev=SFalse
       Call Write.Record(ContainerFile,UserRecord2.First2)
    Endif
 Else
    If UserRecord2.Last2=VarZ! Then
       Call Read.Record(ContainerFile,VarZ!)
       UserRecord2.Last2=ContainerRecord.Prev
       Call Write.Record(UserFile2,TempB!)
       If UserRecord2.Last2>SFalse Then
          Call Read.Record(ContainerFile,UserRecord2.Last2)
          ContainerRecord.Next=SFalse
          Call Write.Record(ContainerFile,UserRecord2.Last2)
       Endif
    Else
       Call Read.Record(ContainerFile,VarZ!)
       Previous.Node!=ContainerRecord.Prev
       Next.Node!=ContainerRecord.Next
       Call Read.Record(ContainerFile,Previous.Node!)
       ContainerRecord.Next=Next.Node!
       Call Write.Record(ContainerFile,Previous.Node!)
       Call Read.Record(ContainerFile,Next.Node!)
       ContainerRecord.Prev=Previous.Node!
       Call Write.Record(ContainerFile,Next.Node!)
    Endif
 Endif
ErrorRsm32g:
 Exit Sub
ErrorTrp32g:
 Resume ErrorRsm32g
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,TempA!)
    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,TempA!)
ErrorRsm27b:
 Exit Sub
ErrorTrp27b:
 Resume ErrorRsm27b
End Sub

Sub Drop.Container.In.Room(Var2!)
 On Local Error Goto ErrTrap48
 VarA!=Lof(ContainerFile)/ContainerRecLen+1!
 Call Clear.Container
 ContainerRecord.ContainerName=TreasureRecord.TreasureName
 ContainerRecord.ContainerShort=TreasureRecord.ShortName
 ContainerRecord.ContainerMax=TreasureRecord.ContainerMax
 ContainerRecord.NamePrefix=TreasureRecord.ContainerPrefix
 ContainerRecord.Size=TreasureRecord.ContainerSize
 ContainerRecord.Material=TreasureRecord.ContainerMaterial
 If TreasureRecord.KeyNumber Then
    ContainerRecord.KeyNumber=TreasureRecord.KeyNumber
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 If TreasureRecord.Locked Then
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 ContainerRecord.RoomNumber=Room
 ContainerRecord.UserNumber=False
 ContainerRecord.Weight=TreasureRecord.Weight
 ContainerRecord.ContainerIndex=Abs(Var2!)
 ContainerRecord.Disappears=TreasureRecord.ContainerDisappears
 ContainerRecord.SelfImplodes=TreasureRecord.ContainerSelfImplodes
 ContainerRecord.Permanent=TreasureRecord.Permanent
 For VarR=1 To 3
    ContainerRecord.RestrictItem(VarR)=TreasureRecord.RestrictItem(VarR)
 Next
 ContainerRecord.TrapType=TreasureRecord.TrapType
 ContainerRecord.TrapHits=TreasureRecord.TrapHits
 ContainerRecord.TrapItem=TreasureRecord.TrapItem
 ContainerRecord.Prefix1=TreasureRecord.Prefix1
 Call Write.Record(ContainerFile,VarA!)
 Call Add.Room.Container(VarA!)
ErrResume48:
 Exit Sub
ErrTrap48:
 Resume ErrResume48
End Sub

Sub Add.Room.Container(VarA!)
 On Local Error Goto ErrResume141h
 Call Read.Record(RoomFile,Room)
 If RoomRecord.First2=SFalse Then
    RoomRecord.First2=VarA!
    RoomRecord.Last2=VarA!
    Call Write.Record(RoomFile,Room)
    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,Room)
 Endif
ErrExit141h:
 Exit Sub
ErrResume141h:
 Resume ErrExit141h
End Sub

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

Sub Drop.Container.In.User(Var2!)
 On Local Error Goto ErrTrap48a
 VarA!=Lof(ContainerFile)/ContainerRecLen+1!
 Call Clear.Container
 ContainerRecord.ContainerName=TreasureRecord.TreasureName
 ContainerRecord.ContainerShort=TreasureRecord.ShortName
 ContainerRecord.ContainerMax=TreasureRecord.ContainerMax
 ContainerRecord.NamePrefix=TreasureRecord.ContainerPrefix
 ContainerRecord.Size=TreasureRecord.ContainerSize
 ContainerRecord.Material=TreasureRecord.ContainerMaterial
 If TreasureRecord.KeyNumber Then
    ContainerRecord.KeyNumber=TreasureRecord.KeyNumber
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 If TreasureRecord.Locked Then
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 ContainerRecord.InvisibleContainer=False
 ContainerRecord.RoomNumber=False
 ContainerRecord.UserNumber=User.Index
 ContainerRecord.Weight=TreasureRecord.Weight
 ContainerRecord.ContainerIndex=Abs(Var2!)
 ContainerRecord.Disappears=TreasureRecord.ContainerDisappears
 ContainerRecord.SelfImplodes=TreasureRecord.ContainerSelfImplodes
 ContainerRecord.Permanent=TreasureRecord.Permanent
 For VarR=1 To 3
    ContainerRecord.RestrictItem(VarR)=TreasureRecord.RestrictItem(VarR)
 Next
 ContainerRecord.TrapType=TreasureRecord.TrapType
 ContainerRecord.TrapHits=TreasureRecord.TrapHits
 ContainerRecord.TrapItem=TreasureRecord.TrapItem
 ContainerRecord.Prefix1=TreasureRecord.Prefix1
 Call Write.Record(ContainerFile,VarA!)
 Call Add.User.Container(VarA!)
ErrResume48a:
 Exit Sub
ErrTrap48a:
 Resume ErrResume48a
End Sub

' add container to user index#1
Sub Add.User.Container(VarA!)
 On Local Error Goto ErrResume141g
 ContainerRecord.SwapFlag=False
 If UserRecord.First2=SFalse Then
    UserRecord.First2=VarA!
    UserRecord.Last2=VarA!
    Call Write.Record(UserFile,User.Index)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
 Else
    ContainerRecord.Prev=UserRecord.Last2
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
    Call Read.Record(ContainerFile,UserRecord.Last2)
    ContainerRecord.Next=VarA!
    Call Write.Record(ContainerFile,UserRecord.Last2)
    Call Read.Record(ContainerFile,VarA!)
    UserRecord.Last2=VarA!
    Call Write.Record(UserFile,User.Index)
 Endif
ErrExit141g:
 Exit Sub
ErrResume141g:
 Resume ErrExit141g
End Sub

' add container to user index#2
Sub Add.User.Container2(VarA!)
 On Local Error Goto ErrResume141i
 Call Read.Record(UserFile2,TempB!)
 ContainerRecord.SwapFlag=False
 If UserRecord2.First2=SFalse Then
    UserRecord2.First2=VarA!
    UserRecord2.Last2=VarA!
    Call Write.Record(UserFile2,TempB!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
 Else
    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,TempB!)
 Endif
ErrExit141i:
 Exit Sub
ErrResume141i:
 Resume ErrExit141i
End Sub

' add item to user index#2
Sub Add.User.Item2(VarA!)
 On Local Error Goto ErrResume141j
 Call Read.Record(UserFile2,TempB!)
 If UserRecord2.First=SFalse Then
    UserRecord2.First=VarA!
    UserRecord2.Last=VarA!
    Call Write.Record(UserFile2,TempB!)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(UserInvFile,VarA!)
 Else
    MessWorkRecord6.Prev=UserRecord2.Last
    MessWorkRecord6.Next=SFalse
    Call Write.Record(UserInvFile,VarA!)
    Call Read.Record(UserInvFile,UserRecord2.Last)
    MessWorkRecord6.Next=VarA!
    Call Write.Record(UserInvFile,UserRecord2.Last)
    Call Read.Record(UserInvFile,VarA!)
    UserRecord2.Last=VarA!
    Call Write.Record(UserFile2,TempB!)
 Endif
ErrExit141j:
 Exit Sub
ErrResume141j:
 Resume ErrExit141j
End Sub

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

' take container TempB! from container TempA! and add to user
Sub Take.Within.Container
 On Local Error Goto ErrTrap43x
 Weight=Weight+ContainerRecord.Weight
 Call Delete.Within.Container(TempB!)
 Call Read.Record(ContainerFile,TempB!)
 ContainerRecord.UserNumber=User.Index
 ContainerRecord.RoomNumber=SFalse
 ContainerRecord.WithinContainer=SFalse
 ContainerRecord.InvisibleContainer=False
 Call Write.Record(ContainerFile,TempB!)
 Call Add.User.Container(TempB!)
ErrResume43x:
 Exit Sub
ErrTrap43x:
 Resume ErrResume43x
End Sub

' take container TempB! from container TempA! and add to room
Sub Take.Within.Container2
 On Local Error Goto ErrTrap43x2
 Call Delete.Within.Container(TempB!)
 Call Read.Record(ContainerFile,TempB!)
 ContainerRecord.UserNumber=SFalse
 ContainerRecord.RoomNumber=Room
 ContainerRecord.WithinContainer=SFalse
' ContainerRecord.InvisibleContainer=False
 Call Write.Record(ContainerFile,TempB!)
 Call Add.Room.Container(TempB!)
ErrResume43x2:
 Exit Sub
ErrTrap43x2:
 Resume ErrResume43x2
End Sub

' delete container VarZ! from container TempA!
Sub Delete.Within.Container(VarZ!)
 On Local Error Goto ErrorTrp32f
 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
ErrorRsm32f:
 Exit Sub
ErrorTrp32f:
 Resume ErrorRsm32f
End Sub

Sub Drop.Container
 On Local Error Goto ErrTrap38
 Call Delete.User.Container(TempA!)
 Call Read.Record(ContainerFile,TempA!)
 ContainerRecord.RoomNumber=Room
 ContainerRecord.UserNumber=SFalse
 ContainerRecord.InvisibleContainer=False
 Call Add.Room.Container(TempA!)
 Weight=Weight-ContainerRecord.Weight
 If Weight<DFalse Then
    Weight=DFalse
 Endif
 Graphics.Off=False
 Strng2=Rtrim$(ContainerRecord.Prefix1)
 Strng3=Lcase$(Out3)
 Strng="You drop "+Strng2+Strng3
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Graphics.Off=True
 Strng=Nul
 If ContainerRecord.InvisibleContainer Then
    Strng=" [inv]"
 Endif
 Strng=Strng+"!"
 Call IO.O
 Graphics.Off=False
ErrResume38:
 Exit Sub
ErrTrap38:
 Resume ErrResume38
End Sub

' add container to containr.dat
Sub Add.Container.To.Container(VarX!)
 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
 ContainerRecord.InvisibleContainer=False
 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=VarX!
 ContainerRecord.Disappears=TreasureRecord.ContainerDisappears
 ContainerRecord.SelfImplodes=TreasureRecord.ContainerSelfImplodes
 ContainerRecord.Permanent=TreasureRecord.Permanent
 For VarQ=1 To 3
    ContainerRecord.RestrictItem(VarQ)=TreasureRecord.RestrictItem(VarQ)
 Next
 ContainerRecord.First=SFalse
 ContainerRecord.Last=SFalse
 ContainerRecord.SwapFlag=SFalse
 ContainerRecord.Scanned=False
 Call Write.Record(ContainerFile,VarA!)
 Call Read.Record(ContainerFile,TempA!)
 If ContainerRecord.First2=SFalse Then
    ContainerRecord.First2=VarA!
    ContainerRecord.Last2=VarA!
    Call Write.Record(ContainerFile,TempA!)
    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,TempA!)
    ContainerRecord.Last2=VarA!
    Call Write.Record(ContainerFile,TempA!)
    Call Read.Record(ContainerFile,VarA!)
 Endif
ErrExit141f:
 Exit Sub
ErrResume141f:
 Resume ErrExit141f
End Sub

' add container VarQ! to container TempA!
Sub Add.Within.Container(VarQ!,VarX)
 On Local Error Goto ErrTrap40a
 Call Read.Record(ContainerFile,TempA!)
 If ContainerRecord.First2=SFalse Then
    ContainerRecord.First2=VarQ!
    ContainerRecord.Last2=VarQ!
    Call Write.Record(ContainerFile,TempA!)
    Call Read.Record(ContainerFile,VarQ!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    ContainerRecord.WithinContainer=True
    ContainerRecord.InvisibleContainer=VarX
    Call Write.Record(ContainerFile,VarQ!)
 Else
    VarR!=ContainerRecord.Last2
    Call Read.Record(ContainerFile,VarQ!)
    ContainerRecord.Prev=VarR!
    ContainerRecord.Next=SFalse
    ContainerRecord.WithinContainer=True
    ContainerRecord.InvisibleContainer=VarX
    Call Write.Record(ContainerFile,VarQ!)
    Call Read.Record(ContainerFile,VarR!)
    ContainerRecord.Next=VarQ!
    Call Write.Record(ContainerFile,VarR!)
    Call Read.Record(ContainerFile,TempA!)
    ContainerRecord.Last2=VarQ!
    Call Write.Record(ContainerFile,TempA!)
    Call Read.Record(ContainerFile,VarQ!)
 Endif
ErrResume40a:
 Exit Sub
ErrTrap40a:
 Resume ErrResume40a
End Sub

Sub Take.All.From.Container(Var2$)
 On Local Error Goto ErrTrap43a
 Call Read.Record(ContainerFile,TempA!)
 Var3$=Rtrim$(ContainerRecord.Prefix1)
 Temp5!=ContainerRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Temp5!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Temp6=MessWorkRecord6.Charges
       Temp6!=MessWorkRecord6.Next
       Temp7!=MessWorkRecord6.User
       VarZ3=False
       If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
          VarZ3=True
          Call Read.Record(TreasureFile,Temp7!)
          Var5$=Rtrim$(TreasureRecord.Prefix1)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          If TreasureRecord.Coin=False Then
             If UserRecord.Encumbrance>=False Then
                Temp1#=Cdbl(Weight+TreasureRecord.Weight)
                Temp2#=Cdbl(UserRecord.Stats(1))*Cdbl(UserRecord.Encumbrance)
                If Temp1#>Temp2# Then
                   Strng="You can't carry any more!"
                   Call IO.O
                   Exit Sub
                Endif
             Endif
          Endif
       Endif
       If Temp7!<SFalse Then
          If Abs(Temp7!)<=Lof(ObjectFile)/ObjectRecLen Then
             VarZ3=True
             Call Read.Record(ObjectFile,Abs(Temp7!))
             Var5$=Rtrim$(ObjectRecord.Prefix1)
             Out3=ObjectRecord.ObjectName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
          Endif
       Endif
       If VarZ3 Then
          Out4=Nul
          TempQ1=False
          TempQ2=False
          If Temp7!>SFalse Then
             If TreasureRecord.LightType Then
                If Temp6<False Then
                   Out4=" [lit]"
                Endif
             Endif
          Endif
          VarQ1=False
          If Temp7!>SFalse Then
             If TreasureRecord.Invisible Then
                VarQ1=-1
                If Rnd>=Config1(11) Then
                   TempQ1=True
                Endif
             Endif
          Endif
          If Temp7!<SFalse Then
             If ObjectRecord.Invisible Then
                VarQ1=-1
                If Rnd>=Config1(11) Then
                   TempQ1=True
                Endif
             Endif
          Endif
          If MessWorkRecord6.Plus Then
             VarQ1=-1
             If Rnd>=Config1(11) Then
                TempQ2=True
             Endif
          Endif
          If VarQ1 Then
             Out4=Out4+" [inv]"
          Endif
          If UserRecord.ClassType=DM Or Sysop Then
             TempQ1=False
             TempQ2=False
          Endif
          If TempQ1=False And TempQ2=False Then
             If Temp7!>SFalse Then
                If TreasureRecord.Coin=False Then
                   Call Add.Inventory(Temp7!,Temp6)
                Endif
             Else
                Call Add.Inventory(Temp7!,Temp6)
             Endif

             Call Delete.List.Node5(Temp5!)
             Call Clear.List.Node
             Call Write.Record(CtnInvFile,Temp5!)

             Graphics.Off=False
             Strng="You take "+Var5$+Out3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O

             Graphics.On=False
             Graphics.Off=True
             If Len(Out4) Then
                Strng=Out4
                Carriage.Return=True
                Call IO.O
             Endif

             Carriage.Return=True
             Strng=" from "
             Call IO.O

             Graphics.Off=False
             Strng=Var3$+Var2$
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O

             Graphics.On=False
             Graphics.Off=True
             Strng=Nul
             If ContainerRecord.InvisibleContainer Then
                Strng=" [inv]"
             Endif
             Strng=Strng+"!"
             Call IO.O
             Graphics.Off=False

             If Temp7!>SFalse Then
                If TreasureRecord.Coin Then
                   UserRecord.Gold=UserRecord.Gold+TreasureRecord.Gold
                   Call Amount3(UserRecord.Gold,Var$)
                   Strng="You now have"+Var$+" Gold!"
                   Call IO.O
                Endif
             Endif

             TempX=True
          Endif
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
ErrResume43a:
 Exit Sub
ErrTrap43a:
 Resume ErrResume43a
End Sub

Sub Take.All.Containers.From.Container(Var2$)
 On Local Error Goto ErrorTrp24a2
 Call Read.Record(ContainerFile,TempA!)
 Var3$=Rtrim$(ContainerRecord.Prefix1)
 If ContainerRecord.InvisibleContainer Then
    VarQZ=-1
 Endif
 Temp6=False
 Temp7!=SFalse
 TempC=False
 TempB!=SFalse
 Var5!=ContainerRecord.First2
 If Var5! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var5!)
       Var6!=ContainerRecord.Next
       Temp8=True
       If ContainerRecord.UserNumber=SFalse Then
          If ContainerRecord.RoomNumber=SFalse Then
             Temp8=False
          Endif
       Endif
       If ContainerRecord.WithinContainer Then
          Temp8=True
       Endif
       If Temp8 Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerShort
             Out3=Left$(Out3,Len(Parsed.Command1))
             TempC=TempC+1
             If Parse.Temp=False Or TempC=Parse.Temp Then
                Out3=ContainerRecord.ContainerName
                Out3=Rtrim$(Out3)
                TempB!=Var5!
                VarX$=Lcase$(Out3)

                Out4=Nul
                If ContainerRecord.InvisibleContainer Then
                   Out4=" [inv]"
                Endif

                Call Take.Within.Container
                Graphics.Off=False
                Var5$=Rtrim$(ContainerRecord.Prefix1)
                Strng="You take "+Var5$+Out3
                Call Convert.ANSI(True,VarQ,VarR)
                Carriage.Return=True
                Graphics.On=True
                Call IO.O

                Graphics.On=False
                Graphics.Off=True
                If Len(Out4) Then
                   Strng=Out4
                   Carriage.Return=True
                   Call IO.O
                Endif

                Strng=" from "
                Carriage.Return=True
                Call IO.O

                Graphics.Off=False
                Strng=Var3$+Var2$
                Call Convert.ANSI(True,VarQ,VarR)
                Carriage.Return=True
                Graphics.On=True
                Call IO.O

                Graphics.On=False
                Graphics.Off=True
                Strng=Nul
                If VarQZ Then
                   Strng=" [inv]"
                Endif
                Strng=Strng+"!"
                Call IO.O
                Graphics.Off=False
                TempX=True
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var5!=Var6!
    Loop
 Endif
ErrorRsm24a2:
 Exit Sub
ErrorTrp24a2:
 Resume ErrorRsm24a2
End Sub

' count items and containers in container
Sub Count.Container.Items
 On Local Error Goto ErrTrap40z
 TempB!=SFalse
 Tmp3!=ContainerRecord.First ' items
 If Tmp3! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Tmp3!)
       Tmp6!=MessWorkRecord6.Next
       Tmp7!=MessWorkRecord6.User
       If Tmp7! Then
          TempB!=TempB!+1!
       Endif
       If Tmp6!=SFalse Then
          Exit Do
       Endif
       Tmp3!=Tmp6!
    Loop
 Endif
 Tmp3!=ContainerRecord.First2 ' containers
 If Tmp3! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Tmp3!)
       Tmp6!=ContainerRecord.Next
       If ContainerRecord.DeletedContainer=False Then
          TempB!=TempB!+1!
       Endif
       If Tmp6!=SFalse Then
          Exit Do
       Endif
       Tmp3!=Tmp6!
    Loop
 Endif
 Call Read.Record(ContainerFile,TempA!)
ErrResume40z:
 Exit Sub
ErrTrap40z:
 Resume ErrResume40z
End Sub

Sub Drop.Container.In.Container(VarX)
 On Local Error Goto ErrTrap40
 If VarX Then
    Var3$=" hide "
 Else
    Var3$=" drop "
 Endif
 VarA!=TempA!
 Var1$=ContainerRecord.ContainerName
 Var1$=Rtrim$(Var1$)
 Var1$=Lcase$(Var1$)
 VarZ1$=Rtrim$(ContainerRecord.Prefix1)
 VarTemp1!=ContainerRecord.Disappears
 VarTempX!=ContainerRecord.ContainerIndex
 VarSize1=False
 If ContainerRecord.Size>False Then
    VarSize1=ContainerRecord.Size
 Endif
 VarQ1=ContainerRecord.SelfImplodes
 Parse.Temp=Temp3
 User.Command=Parsed.Command1
 Parsed.Command1=Parsed.Command2
 Call Examine.Containers
 If ContainerRecord.InvisibleContainer Then
    VarZZ=-1
 Endif
 VarB!=TempA!
 Var2$=ContainerRecord.ContainerName
 Var2$=Rtrim$(Var2$)
 Var2$=Lcase$(Var2$)
 VarZ2$=Rtrim$(ContainerRecord.Prefix1)
 Var4$=Ltrim$(Rtrim$(ContainerRecord.NamePrefix))
 VarTemp2!=ContainerRecord.Disappears
 VarTempY!=ContainerRecord.ContainerIndex
 VarSize2=False
 If ContainerRecord.Size>False Then
    VarSize2=ContainerRecord.Size
 Endif
 If Var4$=Nul Then
    Var4$=" in "
 Else
    If Instr(Var4$," ") Then
       Var4$=Left$(Var4$,Instr(Var4$," ")-1)
    Endif
    Var4$=" "+Var4$+" "
 Endif
 Parsed.Command1=User.Command
 If TempA!=SFalse Then
    Strng="You can't"+Var3$+"that there!"
    Call Io.O
    Exit Sub
 Endif

 ' get container size
 Call Count.Container.Items

 ' count max restrict size
 VarZ1=False
 VarZ2=False
 For VarZ=1 To 3
    If ContainerRecord.RestrictItem(VarZ) Then
       VarZ1=True
       VarZ2=VarZ2+1
    Endif
 Next
 IF VarZ1 Then
    Max!=Csng(ContainerRecord.ContainerMax)
    Max!=Max!*VarZ2
 Else
    Max!=Csng(ContainerRecord.ContainerMax)
 Endif

 ' check damage type
 If ContainerRecord.Damaged=True Then
    Strng="You can't, it's damaged."
    Call IO.O
    Exit Sub
 Endif

 ' check container in container restriction
 VarZ1=False
 For VarZ=1 To 3
    If ContainerRecord.RestrictItem(VarZ) Then
       VarZ1=True
       Exit For
    Endif
 Next
 If VarZ1 Then
    VarZ1=False
    For VarZ=1 To 3
       If ContainerRecord.RestrictItem(VarZ)=VarTempX! Then
          VarZ1=True
          Exit For
       Endif
    Next
    If VarZ1=False Then
       Strng="The container is restricted to certain items."
       Call IO.O
       Exit Sub
    Endif
 Endif

 ' check container lock
 If ContainerRecord.Locked=True Then
    Strng="You can't! It's locked!"
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Locked=1 Then
    If ContainerRecord.Closed Then
       Strng="You can't! It's closed!"
       Call IO.O
       Exit Sub
    Endif
 Endif

 ' check drop container in self
 If Temp4 Then
    If VarA!=VarB! Then

       If Var3$=" hide " Then
          Strng="You can't"+Var3$+"it in itself!"
          Call Io.O
          Exit Sub
       Endif

       If VarQ1=False Then
          Strng="You can't"+Var3$+"it in itself!"
          Call Io.O
          Exit Sub
       Endif

       Call Read.Record(ContainerFile,VarA!)

       Var$=Rtrim$(Lcase$(ContainerRecord.ContainerShort))
       Var1$=Rtrim$(Lcase$(ContainerRecord.Prefix1))
       Strng="*Poof* the "+Var1$+Var$

       Call Convert.ANSI(True,VarQ,VarR)
       Carriage.Return=True
       Graphics.On=True
       Call IO.O
       Graphics.On=False
       Graphics.Off=True
       Strng=" disappears!"
       Call IO.O

       Weight=Weight-ContainerRecord.Weight
       If Weight<DFalse Then
          Weight=DFalse
       Endif
       Call Delete.User.Container(VarA!)
       Call Clear.Container
       Call Write.Record(ContainerFile,VarA!)
       Exit Sub
    Endif
 Endif

 ' check container size
 If VarSize1>False And VarSize2>False Then
    If VarSize1>=VarSize2 Then
       Strng="You can't! It's too small!"
       Call IO.O
       Exit Sub
    Endif
 Endif

 ' check two containers disappear when dropped in each other.
 '   for example, when a portable hole is placed into a magic bag of holding.
 If VarTemp1!>SFalse And VarTemp2!>SFalse Then
    If VarTempX!>SFalse And VarTempY!>SFalse Then

       ' containers match
       If VarTemp1!=VarTempY! And VarTemp2!=VarTempX! Then

          ' source container
          Call Read.Record(ContainerFile,VarA!)
          Weight=Weight-ContainerRecord.Weight
          If Weight<DFalse Then
             Weight=DFalse
          Endif
          Var1$=Rtrim$(Lcase$(ContainerRecord.ContainerShort))
          VarX1$=Rtrim$(Lcase$(ContainerRecord.Prefix1))

          ' destination container
          Call Read.Record(ContainerFile,VarB!)
          If Temp4 Then ' user index
             Weight=Weight-ContainerRecord.Weight
             If Weight<DFalse Then
                Weight=DFalse
             Endif
          Endif
          Var2$=Rtrim$(Lcase$(ContainerRecord.ContainerShort))
          VarX2$=Rtrim$(Lcase$(ContainerRecord.Prefix1))

          Strng="*Poof* the "

          ' see if source name equals destination name.
          If Var1$=Var2$ Then
             Call Plural.Name(Var1$,Var3$)
             If Len(VarX1$) Then
                Strng=Strng+VarX1$
             Else
                If Len(VarX2$) Then
                   Strng=Strng+VarX2$
                Endif
             Endif
             Strng=Strng+Var3$

             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Graphics.Off=True
             Strng=" disappear!"
             Call IO.O
          Else
             Strng=Strng+VarX1$+Var1$
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O

             Strng=" and the "+VarX2$+Var2$
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O

             Graphics.On=False
             Graphics.Off=True
             Strng=" disappear!"
             Call IO.O
          Endif

          ' remove source container
          Call Delete.User.Container(VarA!)
          Call Clear.Container
          Call Write.Record(ContainerFile,VarA!)

          ' remove destination container
          If Temp4 Then
             Call Delete.User.Container(VarB!)
          Else
             Call Delete.Room.Container(VarB!)
          Endif
          Call Clear.Container
          Call Write.Record(ContainerFile,VarB!)
          Exit Sub
       Endif
    Endif
 Endif

 ' check max items in container
 If Max!<0! Then ' unlimited
    Eat$=Nul
 Else
    If Max!=SFalse Then
       Strng="You can't put anything in there!"
       Call IO.O
       Exit Sub
    Endif
    If TempB!>=Max! Then
       Strng="You can't, it's full!"
       Call IO.O
       Exit Sub
    Endif
 Endif

 ' drop the container into container
 Call Delete.User.Container(VarA!)
 Call Read.Record(ContainerFile,VarA!)
 Weight=Weight-ContainerRecord.Weight
 If Weight<DFalse Then
    Weight=DFalse
 Endif
 Call Add.Within.Container(VarA!,VarX)

 Graphics.Off=False
 Strng="You"+Var3$+VarZ1$+Var1$
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O

 Graphics.On=False
 Graphics.Off=True
 Strng=Var4$
 Carriage.Return=True
 Call IO.O

 Graphics.Off=False
 Strng=VarZ2$+Var2$
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O

 Graphics.On=False
 Graphics.Off=True
 Strng=Nul
 If VarZZ Then
    Strng=" [inv]"
 Endif
 Strng=Strng+"!"
 Call IO.O
ErrResume40:
 Exit Sub
ErrTrap40:
 Resume ErrResume40
End Sub

Sub Drop.All.Into.Container(Var2$,Var3$,Var4$,VarX)
 On Local Error Goto ErrTrap39a
 Max!=Csng(ContainerRecord.ContainerMax)
 If Max!=-1! Then
    Eat$=Nul
 Else
    If Max!=SFalse Then
       Strng="You can't put anything in there!"
       Call IO.O
       Exit Sub
    Endif
    Call Count.Container.Items
    If TempB!>=Max! Then
       Strng="It's full!"
       Call IO.O
       Exit Sub
    Endif
 Endif
 VarQ1=False
 VarZ2$=Rtrim$(ContainerRecord.Prefix1)
 For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    Call Read.Record(MessWorkFile6,Temp5!)
    If MessWorkRecord6.User=User.Index Then
       Temp6=MessWorkRecord6.Charges
       Temp7!=MessWorkRecord6.Index
       VarZ3=0
       VarZZ=0
       VarZZ2=0
       If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
          VarZ3=-1
          Call Read.Record(TreasureFile,Temp7!)
          Var1$=TreasureRecord.TreasureName
          Var1$=Rtrim$(Lcase$(Var1$))
          VarZ1$=Rtrim$(TreasureRecord.Prefix1)
          If TreasureRecord.Invisible Then
             VarZZ2=-1
          Endif
          If TreasureRecord.LightType Then
             If Temp6<False Then
                VarZZ=-1
             Endif
          Endif
       Else
          If Temp7!<SFalse Then
             If Abs(Temp7!)<=Lof(ObjectFile)/ObjectRecLen Then
                VarZ3=-1
                Call Read.Record(ObjectFile,Abs(Temp7!))
                Var1$=ObjectRecord.ObjectName
                Var1$=Rtrim$(Lcase$(Var1$))
                VarZ1$=Rtrim$(ObjectRecord.Prefix1)
                If ObjectRecord.Invisible Then
                   VarZZ2=-1
                Endif
             Endif
          Endif
       Endif
       If VarZ3 Then
          If Max!=-1! Then
             Eat$=Nul
          Else
             If TempB!>=Max! Then
                Strng="It's full!"
                Call IO.O
                Exit Sub
             Endif
          Endif
          TempB!=TempB!+1!
          Call Discard(Temp5!,True)
          Temp3!=Lof(CtnInvFile)/MessWorkRecLen6+1!
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.User=Temp7!
          MessWorkRecord6.Index=TempA!
          MessWorkRecord6.Charges=Temp6
          MessWorkRecord6.Plus=VarX
          Call Add.List.Node5(Temp3!)
          Graphics.Off=False
          Strng="You"+Var3$+VarZ1$+Var1$
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          Graphics.Off=True
          Strng=Nul
          If VarZZ Then
             Strng=" [lit]"
          Endif
          If VarZZ2 Then
             Strng=Strng+" [inv]"
          Endif
          Strng=Strng+Var4$
          Carriage.Return=True
          Call IO.O
          Graphics.Off=False
          Strng=VarZ2$+Var2$
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          Graphics.Off=True
          Strng=Nul
          If ContainerRecord.InvisibleContainer Then
             Strng=" [inv]"
          Endif
          Strng=Strng+"!"
          Call IO.O
          VarQ1=True
       Endif
    Endif
 Next
 If VarQ1=False Then
    Strng="You drop nothing!"
    Call IO.O
 Endif
ErrResume39a:
 Exit Sub
ErrTrap39a:
 Resume ErrResume39a
End Sub

Sub Look.In.Container(Var$)
 On Local Error Goto ErrTrap32
 Gosub Get.Config3

 ' analyze container
 If ContainerRecord.Damaged=True Then
    Strng="You can't, it's damaged."
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Locked=True Then
    Strng="You can't, it's locked."
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Locked=1 Then
    If ContainerRecord.Closed Then
       Strng="You can't, it's closed."
       Call IO.O
       Exit Sub
    Endif
 Endif

 ' dropped into
 VarQ2=ContainerRecord.TrapType
 VarQ3=ContainerRecord.TrapHits
 VarQ4!=ContainerRecord.TrapItem
 Var2$=ContainerRecord.ContainerShort
 Var2$=Rtrim$(Var2$)
 Var2$=Lcase$(Var2$)
 VarZ$=Var2$
 If Normal.User Then
    If Var$<>Nul Then
       If MessWorkRecord1.ClassType>=Lady Then
          Strng3=Rtrim$(Class.Name(MessWorkRecord1.ClassType))
          Call A.Or.An
          Strng="You can't search "+Prefix1+Strng3+"."
          Call IO.O
          Exit Sub
       Endif
       If UserRecord.ClassType<AsstDM Then
          If UserRecord.ClassType<>Thief Then
             If option20 Then
                Strng="Only thieves can search containers!"
                Call IO.O
                Exit Sub
             Endif
          Else
             If UserRecord.Level<option21 Then
                Strng="Only level "+Form$(Cdbl(option21))+" thieves can search containers!"
                Call IO.O
                Exit Sub
             Endif
          Endif
       Endif
    Endif
 Endif
 Call ContainerTraps(VarQ2,VarQ3,VarQ4!,VarZ$)
 If VarQ2=-1 Then ' *boom*
    Exit Sub
 Endif

 ' display container
 Strng=Rtrim$(ContainerRecord.Prefix1)
 If Var$=Nul Then
    Strng3=Lcase$(Rtrim$(ContainerRecord.ContainerName))
    Strng=Prefix1+Strng+Strng3
 Else
    Var$=Lcase$(Var$) ' user owned container
    Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
    Strng3=Lcase$(Rtrim$(ContainerRecord.ContainerShort))
    Strng="It's "+Var$+"'s "+Strng+Strng3
 Endif

 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Strng=Nul
 If ContainerRecord.InvisibleContainer Then
    Strng=Strng+" [inv]"
 Endif
 If ContainerRecord.KeyNumber Then
    Strng=Strng+" (#"+Right$(Mid$(Str$(ContainerRecord.KeyNumber+1000000!),2),6)+")"
 Endif
 Select Case ContainerRecord.Size
 Case 1
    Strng=Strng+" {small}"
 Case 2
    Strng=Strng+" {medium}"
 Case 3
    Strng=Strng+" {large}"
 End Select
 Strng=Strng+"."
 Call IO.O
 Select Case ContainerRecord.Material
 Case -1
    Strng="It's burnable"
 Case 1
    Strng="It's glass"
 Case 2
    Strng="It's wood"
 Case 3
    Strng="It's metal"
 Case Else
'    Strng="It's paper"
 End Select
 If Len(Strng) Then
    Strng=Strng+"."
    Call IO.O
 Endif
 If Last.Command.Number=Identify.Command Then
    Temp6=ContainerRecord.ContainerMax
    Select Case Temp6
    Case True
       Strng="It can contain unlimited items."
    Case 0
       Strng="It has no containment."
    Case 1
       Strng="It can contain one item."
    Case 2 To 10
       Strng="It can contain "+Rtrim$(Numeral(Temp6))+" items."
    Case Else
       Strng="It can contain "+Form$(Cdbl(Temp6))+" items."
    End Select
    Call IO.O
    If ContainerRecord.SelfImplodes Then
       Strng="It selfimplodes."
       Call IO.O
    Endif
    Select Case ContainerRecord.TrapType
    Case 1
       Strng="It's trapped with poison needles!"
       Call IO.O
    Case 2
       VarQ2=ContainerRecord.TrapHits
       Select Case VarQ2
       Case Is>False
          Select Case VarQ2
          Case 1
             Strng="It's trapped for one fatigue hit!"
          Case 2 To 10
             Strng="It's trapped for "+Rtrim$(Numeral(VarQ2))+" fatigue hits!"
          Case Else
             Strng="It's trapped for "+Form$(Cdbl(VarQ2))+" fatigue hits!"
          End Select
          Call IO.O
       Case Is<False
          VarQ2=Abs(VarQ2)
          Select Case VarQ2
          Case 1
             Strng="It's trapped for one vitality hit!"
          Case 2 To 10
             Strng="It's trapped for "+Rtrim$(Numeral(VarQ2))+" vitality hits!"
          Case Else
             Strng="It's trapped for "+Form$(Cdbl(VarQ2))+" vitality hits!"
          End Select
          Call IO.O
       End Select
    Case 3
       ' explodes
       '   (ignored: already exploded before here!)
    Case 4
       Var2!=ContainerRecord.TrapItem
       If Var2!>SFalse And Var2!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Var2!)
          Out3=TreasureRecord.TreasureName
          Out3=Rtrim$(Out3)
          Out3=Lcase$(Out3)
          Strng="It has a shooting weapon trap with "+Out3+"!"
          Call IO.O
       Endif
    End Select

    ' count restricted items
    VarZ1=False
    VarZ2=0
    For VarZ=1 To 3
       If ContainerRecord.RestrictItem(VarZ) Then
          VarZ1=True
          VarZ2=VarZ2+1
       Endif
    Next

    ' display restricted items
    VarZ3=0
    If VarZ1 Then
       Strng="It is restricted to containing the following:"
       Call IO.O
       For VarZ=1 To 3
          VarQ!=ContainerRecord.RestrictItem(VarZ)
          If VarQ!<SFalse Then
             VarQ!=Abs(VarQ!)
             VarZ3=VarZ3+1
             Call Read.Record(ObjectFile,VarQ!)
             Out2=Rtrim$(ObjectRecord.Prefix1)
             Out3=Lcase$(Rtrim$(ObjectRecord.ObjectName))
             Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             Strng=Strng+Out2+Out3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=-1
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             If VarZ3<VarZ2 Then
                Strng=", "
                Carriage.Return=-1
                Graphics.Off=True
                Call IO.O
             Endif
          Else
             If VarQ!>SFalse Then
                VarZ3=VarZ3+1
                Call Read.Record(TreasureFile,VarQ!)
                Out2=Rtrim$(TreasureRecord.Prefix1)
                Out3=Lcase$(Rtrim$(TreasureRecord.TreasureName))
                Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
                Strng=Strng+Out2+Out3
                Call Convert.ANSI(True,VarQ,VarR)
                Carriage.Return=-1
                Graphics.On=True
                Call IO.O
                Graphics.On=False
                If VarZ3<VarZ2 Then
                   Strng=", "
                   Carriage.Return=-1
                   Graphics.Off=True
                   Call IO.O
                Endif
             Endif
          Endif
       Next
       Strng="."
       Call IO.O
    Endif
 Endif
 Graphics.Off=True
 Strng=Rtrim$(ContainerRecord.NamePrefix)
 Strng=Lcase$(Strng)
 If Len(Strng) Then
    Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
 Endif
 Strng=Strng+" you find "
 Carriage.Return=True
 Call IO.O
 Strng=Nul
 Strng2=Nul
 Temp9!=SFalse
 Temp5!=ContainerRecord.First
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(CtnInvFile,Temp5!)
       If MessWorkRecord6.User=SFalse Then
          Exit Do
       Endif
       Temp6!=MessWorkRecord6.Next
       Temp7!=MessWorkRecord6.User
       If Temp7! Then
          Temp6=True
       Else
          Temp6=False
       Endif
       If MessWorkRecord6.Plus Then
          If Normal.User Then
             Temp6=False
          Endif
       Endif
       If Temp6 Then
          Temp9!=Temp9!+1!
          Carriage.Return=True
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Len(Strng2) Then
             Carriage.Return=True
             Strng=Strng2
             Call IO.O
          Endif
          Graphics.On=False
          Strng2=Nul
          VarZZ2=0
          If Temp7!>SFalse And Temp7!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(TreasureFile,Temp7!)
             Strng=Rtrim$(TreasureRecord.Prefix1)
             Strng=Strng+Rtrim$(TreasureRecord.TreasureName)
             If TreasureRecord.LightType Then
                If MessWorkRecord6.Charges<False Then
                   Strng2=Strng2+" [lit]"
                Endif
             Endif
             If TreasureRecord.Invisible Then
                VarZZ2=-1
             Endif
          Else
             If Temp7!<SFalse Then
                Temp8!=Abs(Temp7!)
                If Temp8!>SFalse And Temp8!<=Lof(ObjectFile)/ObjectRecLen Then
                   Call Read.Record(ObjectFile,Temp8!)
                   Strng=Rtrim$(ObjectRecord.Prefix1)
                   Strng=Strng+Rtrim$(ObjectRecord.ObjectName)
                   If ObjectRecord.Invisible Then
                      VarZZ2=-1
                   Endif
                Endif
             Endif
          Endif
          If MessWorkRecord6.Plus Or VarZZ2 Then
             Strng2=Strng2+" [inv]"
          Endif
          Strng2=Strng2+", "
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 Temp5!=ContainerRecord.First2
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Temp5!)
       Temp6!=ContainerRecord.Next
       Temp6=True
       If ContainerRecord.UserNumber=SFalse Then
          If ContainerRecord.RoomNumber=SFalse Then
             Temp6=False
          Endif
       Endif
       If ContainerRecord.WithinContainer Then
          Temp6=True
       Endif
       If Temp6 Then
          If ContainerRecord.InvisibleContainer Then
             If Normal.User Then
                Temp6=False
             Endif
          Endif
          If ContainerRecord.DeletedContainer Then
             Temp6=False
          Endif
       Endif
       If Temp6 Then
          Carriage.Return=True
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Len(Strng2) Then
             Carriage.Return=True
             Strng=Strng2
             Call IO.O
          Endif
          Strng=Rtrim$(ContainerRecord.Prefix1)
          Strng=Strng+Rtrim$(Lcase$(ContainerRecord.ContainerName))
          Strng2=Nul
          If ContainerRecord.InvisibleContainer Then
             Strng2=Strng2+" [inv]"
          Endif
          Strng2=Strng2+", "
          Temp9!=Temp9!+1!
       Endif
       If Temp6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Temp6!
    Loop
 Endif
 If Temp9!=SFalse Then
    Strng="nothing.."
 Else
    If Temp9!>1! Then
       Strng="and "+Strng
    Endif
 Endif
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 If Len(Strng2) Then
    Strng=Left$(Strng2,Len(Strng2)-2)+"."
 Else
    Strng="."
 Endif
 Call IO.O
 Exit Sub

Get.Config3:
 VarX=0
 option20=-1
 option21=10
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Exit Do
    Endif
    VarZ3$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(VarZ3$)="[CONTAIN]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Return
          Endif
          VarZ3$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(VarZ3$)="[END]" Then
             Return
          Endif
          Var=Instr(VarZ3$,"=")
          If Var Then
             Var2$=Lcase$(Ltrim$(Rtrim$(Left$(VarZ3$,Var-1))))
             Var3$=Lcase$(Ltrim$(Rtrim$(Mid$(VarZ3$,Var+1))))
             Select Case Var2$
             Case "only.thieves.can.search.container.of.online.user"
                Select Case Lcase$(Var3$)
                Case "0", "false", "off"
                   option20=0
                End Select
             Case "search.container.level.item.online.user"
                option21=Int(Val(Var3$)+.5)
             End Select
          Endif
       Loop
    Endif
 Loop
 Return
ErrResume32:
 Exit Sub
ErrTrap32:
 Resume ErrResume32
End Sub

Sub Drop.All.Items
 On Local Error Goto ErrTrap23a
 Temp6=False
 Temp7!=SFalse
 For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    Call Read.Record(MessWorkFile6,Temp5!)
    If MessWorkRecord6.User=User.Index Then
       VarQ!=MessWorkRecord6.Index
       If VarQ!<SFalse Then
          VarA!=Abs(VarQ!)
          If VarA!>SFalse And VarA!<=Lof(ObjectFile)/ObjectRecLen Then
             Call Read.Record(ObjectFile,VarA!)
             Out3=Lcase$(Rtrim$(ObjectRecord.ObjectName))
             Strng2=Rtrim$(ObjectRecord.Prefix1)
             Temp7!=VarQ!
             Temp6=MessWorkRecord6.Charges
             Call Drop.Item.In.Room(Temp7!,Temp6)
             MessWorkRecord6.User=SFalse
             MessWorkRecord6.Room=SFalse
             MessWorkRecord6.Index=SFalse
             MessWorkRecord6.Charges=False
             MessWorkRecord6.Plus=False
             MessWorkRecord6.Prev=SFalse
             MessWorkRecord6.Next=SFalse
             Call Write.Record(MessWorkFile6,Temp5!)
             Graphics.Off=False
             Strng="You drop "+Strng2+Out3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Graphics.Off=True
             Strng=Nul
             If ObjectRecord.Invisible Then
                Strng=" [inv]"
             Endif
             Strng=Strng+"!"
             Call IO.O
             Graphics.Off=False
          Endif
       Endif
       If VarQ!>SFalse Then
          If VarQ!>SFalse And VarQ!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(TreasureFile,VarQ!)
             Out3=Lcase$(Rtrim$(TreasureRecord.TreasureName))
             Strng2=Rtrim$(TreasureRecord.Prefix1)
             Temp7!=VarQ!
             Temp6=MessWorkRecord6.Charges
             TempZ2=0
             TempZ3=0
             If TreasureRecord.Container Then
                Call Drop.Container.In.Room(Temp7!)
                Call Discard(Temp5!,True)
             Else
                Call Discard(Temp5!,False)
                If TreasureRecord.LightType Then
                   If MessWorkRecord6.Charges<False Then
                      TempZ2=-1
                   Endif
                Endif
                If TreasureRecord.Invisible Then
                   TempZ3=-1
                Endif
             Endif
             Graphics.Off=False
             Strng="You drop "+Strng2+Out3
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Graphics.Off=True
             Strng=Nul
             If TempZ2 Then
                Strng=" [lit]"
             Endif
             If TempZ3 Then
                Strng=Strng+" [inv]"
             Endif
             Strng=Strng+"!"
             Call IO.O
             Graphics.Off=False
          Endif
       Endif
    Endif
 Next
 Temp6=False
 Temp7!=SFalse
 TempA!=SFalse
 Temp5!=UserRecord.First2
 If Temp5! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Temp5!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.DeletedContainer=False Then
          If ContainerRecord.WithinContainer=SFalse Then
             Out3=Lcase$(Rtrim$(ContainerRecord.ContainerName))
             TempA!=Temp5!
             Call Drop.Container
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Temp5!=Var6!
    Loop
 Endif
ErrResume23a:
 Exit Sub
ErrTrap23a:
 Resume ErrResume23a
End Sub

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

