 Rem File: Cmd091.bas
 Rem Sub: Open.Object
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 091 -- Open.Object."
    Color 7,0
    End
 Endif
 Call Open.Object
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Open.Object
 On Local Error Goto ErrTrap28
 Call Parse
 If Parser Then
    Call Numeric
 Endif
 Call Check.Room.Items
 If Temp7!>SFalse Then
    Strng="You can't open that!"
    Call IO.O
    Exit Sub
 Endif
 If Temp7!=SFalse Then
    Call Num
    Call Check.User.Items
    If Temp7!>SFalse Then
       Strng="You can't open that!"
       Call IO.O
       Exit Sub
    Endif
    If Temp7!=SFalse Then
       Call Num
       Call Examine.Containers
       If TempA! Then
          Call Open.Container
          Exit Sub
       Endif
    Endif
 Endif
 If Temp7!<SFalse Then
    Temp7!=Abs(Temp7!)
    If ObjectRecord.DoorLock<>1 Then
       Strng="You can't open that!"
       Call IO.O
       Exit Sub
    Endif
    If ObjectRecord.Closed=False Then
       Strng="It's already open!"
       Call IO.O
       Exit Sub
    Endif
    ObjectRecord.Closed=False
    Call Write.Record(ObjectFile,Temp7!)
    Strng="You open it!"
    Call IO.O
    Exit Sub
 Endif
 Strng="You can't open that!"
 Call IO.O
ErrResume28:
 Exit Sub
ErrTrap28:
 Resume ErrResume28
End Sub

Sub Open.Container
 On Local Error Goto ErrTrap33
 If ContainerRecord.Damaged=True Then
    Strng="You can't, it's damaged!"
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Locked=True Then ' is locked
    Strng="You can't! It's locked!"
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Locked=False Then ' has no lock
    Strng="You can't open that!"
    Call IO.O
    Exit Sub
 Endif
 If ContainerRecord.Closed=False Then ' is open
    Strng="It's already open!"
    Call IO.O
    Exit Sub
 Endif
 ContainerRecord.Closed=False ' open
 Call Write.Record(ContainerFile,TempA!)
 Strng="You open it!"
 Call IO.O
 ' trap hits when opened.
 VarQ2=ContainerRecord.TrapType
 VarQ3=ContainerRecord.TrapHits
 VarQ4!=ContainerRecord.TrapItem
 VarZ$=ContainerRecord.ContainerShort
 VarZ$=Rtrim$(VarZ$)
 VarZ$=Lcase$(VarZ$)
 Call ContainerTraps(VarQ2,VarQ3,VarQ4!,VarZ$)
ErrResume33:
 Exit Sub
ErrTrap33:
 Resume ErrResume33
End Sub
