 Rem File: DndeditI.bas
 Rem Sub: EditRoom
 Rem $Include: 'dndedit.inc'

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

Sub EditRoom
 On Local Error Goto Error.Trap153
 Room.Number=1!
 If Lof(RoomFile)=SFalse Then
    Call AddRoom
 Endif
 Out3="Sysop Room Edit"
 Call DisplayEditScreen(1,20,Out3)
 Call RoomStatusLine
 Call DisplayRoom
 Call MouseDriver(3)
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseButton(20)
          If Len(TempX$) Then
             Exit Do
          Endif
       Endif
       If Mouse.Row Or Mouse.Column Then
          Call MouseSelect(20)
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddRoom
       Case 5
          Call DisplayRoomClass
       Case 7
          Call EditRoomContainers
          Call RoomStatusLine
       Case 8
          Call Help(1)
          Out3="Sysop Room Edit"
          Call DisplayEditScreen(1,20,Out3)
          Call RoomStatusLine
          Call DisplayRoom
       Case 9
          Call RoomSelect
       Case 10
          Call JumpRoom
       Case 13
          Call EditSelectedRoom
       Case 14
          Call NextRoom
       Case 15
          Call EditRoomObject
          Call RoomStatusLine
       Case 17
          Call PreviousRoom
       Case 18
          Call SelectNextRoom
          Call RoomStatusLine
       Case 20
          Call EditRoomTreasure
          Call RoomStatusLine
       Case 23
          Call SearchRoom
       Case 27
          Call Write.Record(RoomFile,Room.Number)
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       If TempX=0 Then
          Call Write.Record(RoomFile,Room.Number)
          Exit Do
       Endif
       Call RoomSelect
    End Select
 Loop
Error.Resume153:
 Exit Sub
Error.Trap153:
 Resume Error.Resume153
End Sub

Sub SearchRoom
 On Local Error Goto Error.Trap154
 Call Write.Record(RoomFile,Room.Number)
 Strng=Nul
 Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field  "
 Out2=Out2+"Append # sign and number for specific room"
 Call StatusLine
 Call ANSI(4,33,44)
 Call ANSI(2,23,2)
 Strng="Enter Room Desc or Number: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,29)
 Strng=Space$(30)
 Call Scrn(Strng)
 Restore Data19
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Call RoomStatusLine
 Var2!=Int(Val(Edit.Data(1)))
 Temp$=Ucase$(Edit.Data(1))
 If Var2!>SFalse And Var2!<=Lof(RoomFile)/RoomRecLen Then
    Room.Number=Var2!
    Call DisplayRoom
    Exit Sub
 Endif
 Temp.Index=SFalse
 Temp1=Instr(Temp$,"#")
 If Temp1 Then
    Temp.Index=Csng(Int(Val(Mid$(Temp$,Temp1+1))))
    Temp$=Left$(Temp$,Temp1-1)
 Endif
 Temp!=SFalse
 Temp3!=SFalse
 For Var2!=1! To Lof(RoomFile)/RoomRecLen
    Call Read.Record(RoomFile,Var2!)
    Strng=Rtrim$(RoomRecord.ShortDesc)
    Call InstrSUB(TempX,Strng,Temp$)
    If TempX Then
       Temp3!=Temp3!+1!
       If Temp3!=1! Then
          Temp!=Var2!
       Endif
       If Temp.Index Then
          If Temp3!=Temp.Index Then
             Room.Number=Var2!
             Call DisplayRoom
             Exit Sub
          Endif
       Endif
    Else
       For Var=1 To 19
          VarX!=RoomRecord.LongDesc(Var)
          If VarX!>SFalse And VarX!<=Lof(RoomDescFile)/RoomDescLen Then
             Call Read.Record(RoomDescFile,VarX!)
             Strng=Ucase$(Rtrim$(Left$(BufferRecord.Buffer,78)))
             If Len(Strng) Then
                Call InstrSUB(TempX,Strng,Temp$)
                If TempX Then
                   Temp3!=Temp3!+1!
                   If Temp3!=1! Then
                      Temp!=Var2!
                   Endif
                   If Temp.Index Then
                      If Temp3!=Temp.Index Then
                         Room.Number=Var2!
                         Call DisplayRoom
                         Exit Sub
                      Endif
                   Endif
                   Exit For
                Endif
             Endif
          Endif
       Next
    Endif
 Next
 If Temp.Index>SFalse Then
    Strng="The room desc was not found in the room file."
    Call ErrorMessage
    Call DisplayRoom
    Exit Sub
 Endif
 If Temp3!=SFalse Then
    Strng="The room desc was not found in the room file."
    Call ErrorMessage
    Call DisplayRoom
    Exit Sub
 Endif
 If Temp3!=1! Then
    Room.Number=Temp!
    Call DisplayRoom
    Exit Sub
 Endif
 Strng="There was more than one room found."
 Call ErrorMessage
 Strng="^ Scroll Room  "+Chr$(60)+Chr$(217)+" Select Room ("+Ltrim$(Str$(Temp3!))+" found)."
 Out2=Nul
 Call StatusLine
 Room.Number=Temp!
 Var2!=Temp!
 Call DisplayRoom
 Do While Lost.Carrier=False
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       If TempX$=Chr$(13) Then
          Room.Number=Var2!
          Call RoomStatusLine
          Call DisplayRoom
          Exit Sub
       Endif
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          VarA=False
          For Var3!=Var2!-1! To 1! Step -1!
             Call Read.Record(RoomFile,Var3!)
             Strng=Rtrim$(RoomRecord.ShortDesc)
             Call InstrSUB(TempX,Strng,Temp$)
             If TempX Then
                VarA=True
                Var2!=Var3!
                Room.Number=Var3!
                Call DisplayRoom
                Exit For
             Else
                For Var=1 To 19
                   VarX!=RoomRecord.LongDesc(Var)
                   If VarX!>SFalse And VarX!<=Lof(RoomDescFile)/RoomDescLen Then
                      Call Read.Record(RoomDescFile,VarX!)
                      Strng=Rtrim$(Left$(BufferRecord.Buffer,78))
                      If Len(Strng) Then
                         Call InstrSUB(TempX,Strng,Temp$)
                         If TempX Then
                            VarA=True
                            Var2!=Var3!
                            Room.Number=Var3!
                            Call DisplayRoom
                            Exit For
                         Endif
                      Endif
                   Endif
                Next
                If VarA Then
                   Exit For
                Endif
             Endif
          Next
          If VarA=False Then
             Strng="This is the first room in the search."
             Call ErrorMessage
          Endif
       Case 80, 145, 160
          VarA=False
          For Var3!=Var2!+1! To Lof(RoomFile)/RoomRecLen
             Call Read.Record(RoomFile,Var3!)
             Strng=Rtrim$(RoomRecord.ShortDesc)
             Call InstrSUB(TempX,Strng,Temp$)
             If TempX Then
                VarA=True
                Var2!=Var3!
                Room.Number=Var3!
                Call DisplayRoom
                Exit For
             Else
                For Var=1 To 19
                   VarX!=RoomRecord.LongDesc(Var)
                   If VarX!>SFalse And VarX!<=Lof(RoomDescFile)/RoomDescLen Then
                      Call Read.Record(RoomDescFile,VarX!)
                      Strng=Rtrim$(Left$(BufferRecord.Buffer,78))
                      If Len(Strng) Then
                         Call InstrSUB(TempX,Strng,Temp$)
                         If TempX Then
                            VarA=True
                            Var2!=Var3!
                            Room.Number=Var3!
                            Call DisplayRoom
                            Exit For
                         Endif
                      Endif
                   Endif
                Next
                If VarA Then
                   Exit For
                Endif
             Endif
          Next
          If VarA=False Then
             Strng="This is the last room in the search."
             Call ErrorMessage
          Endif
       End Select
    End Select
 Loop
Error.Resume154:
 Exit Sub
Error.Trap154:
 Resume Error.Resume154
End Sub

Sub DisplayRoomClass
 On Local Error Goto Error.Trap155
 Room.MonClass=RoomRecord.MonClass
 If Room.MonClass<=SFalse Or Room.MonClass>Lof(MonClassFile)/MonClassRecLen Then
    Strng="The monster class is not in the monster class file range."
    Call ErrorMessage
    Exit Sub
 Endif
 TempD=True
 Call ANSI(4,33,44)
 For Var=7 To 11
    Call ANSI(2,Var,36)
    Strng=Space$(44)
    Call Scrn(Strng)
 Next
 Call ANSI(2,6,45)
 Strng="Monster Class:"+Str$(RoomRecord.MonClass)
 Call Scrn(Strng)
 Call Read.Record(MonClassFile,Room.MonClass)
 Call ANSI(4,37,44)
 For Temp2=1 To 5
    Temp3!=MonClassRecord.Monsters(Temp2)
    If Temp3!<=SFalse Or Temp3!>Lof(MonsterFile)/MonsterRecLen Then
       Call ANSI(2,Temp2+6,40)
       Strng="<zero>"
       Call Scrn(Strng)
    Else
       Call Read.Record(MonsterFile,Temp3!)
       Call ANSI(2,Temp2+6,40)
       Strng=Left$(MonsterRecord.MonsterName,20)
       Call Scrn(Strng)
    Endif
 Next
 For Temp2=6 To 10
    Temp3!=MonClassRecord.Monsters(Temp2)
    If Temp3!<=SFalse Or Temp3!>Lof(MonsterFile)/MonsterRecLen Then
       Call ANSI(2,Temp2+1,60)
       Strng="<zero>"
       Call Scrn(Strng)
    Else
       Call Read.Record(MonsterFile,Temp3!)
       Call ANSI(2,Temp2+1,60)
       Strng=Left$(MonsterRecord.MonsterName,20)
       Call Scrn(Strng)
    Endif
 Next
 Call RedisplayField
 Strng="<esc> Exit Monster Class Display"
 Out2=Nul
 Call StatusLine
 TempX$=Nul
 Do While TempX$<>Chr$(27)
    If Lost.Carrier Then
       Exit Do
    Endif
    Call Read.Keyboard(TempX$)
    Call MouseDriver(3)
    If Mouse.Button2 Then
       TempX$=Chr$(27)
    Endif
    If Mouse.Button Then
       Call MouseCheck
    Endif
 Loop
 Call ClearSubstats
 Call RoomStatusLine
Error.Resume155:
 Exit Sub
Error.Trap155:
 Resume Error.Resume155
End Sub

Sub JumpRoom
 On Local Error Goto Error.Trap156
 Select Case Selection
 Case 3 To 14
    If RoomRecord.Direct(Selection-2)<1 Or _
       RoomRecord.Direct(Selection-2)>Lof(RoomFile)/RoomRecLen Then
       Strng="The value is not within the existing room numbers."
       Call ErrorMessage
    Else
       Room.Number=RoomRecord.Direct(Selection-2)
       Call DisplayRoom
    Endif
 Case 17, 18
    If Rtrim$(RoomRecord.Custom1)>Nul Then
       If RoomRecord.Direct(13)>SFalse And RoomRecord.Direct(13)<=Lof(RoomFile)/RoomRecLen Then
          Room.Number=RoomRecord.Direct(13)
          Call DisplayRoom
          Exit Sub
       Endif
    Endif
    Strng="The value is not within the existing room numbers."
    Call ErrorMessage
 Case 19, 20
    If Rtrim$(RoomRecord.Custom2)>Nul Then
       If RoomRecord.Direct(14)>SFalse And RoomRecord.Direct(14)<=Lof(RoomFile)/RoomRecLen Then
          Room.Number=RoomRecord.Direct(14)
          Call DisplayRoom
          Exit Sub
       Endif
    Endif
    Strng="The value is not within the existing room numbers."
    Call ErrorMessage
 Case Else
    Strng="You must cursor to the room direction first."
    Call ErrorMessage
 End Select
Error.Resume156:
 Exit Sub
Error.Trap156:
 Resume Error.Resume156
End Sub

Sub EditSelectedRoom
 On Local Error Goto Error.Trap157
 Call RoomEdit
 Call Write.Record(RoomFile,Room.Number)
 Call RoomStatusLine
 TempX=Selection
 If TempX=2 Then
    Out3="Sysop Room Edit"
    Call DisplayEditScreen(1,20,Out3)
    Call RoomStatusLine
    Call DisplayRoom
 Else
    Call ShowRoom
 Endif
 Call RedisplayField
 If User.Index Then
    UserRecord.ObjectsCreated(7)=UserRecord.ObjectsCreated(7)+1#
    Var$=Lcase$(Rtrim$(UserRecord.CodeName))
    Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
    Call Write.Record(UserFile,User.Index)
 Else
    Var$="<local>"
 Endif
 Close #TempFile1
 Filename$=DND.Path+"created.dat"
 Open Filename$ For Append Shared As #TempFile1
 Var$=Var$+" edited room"+Str$(Room.Number)+" on "
 Var$=Var$+Format$(Now,"mm-dd-yyyy")+" "+Format$(Now,"hh:mm:ss")
 Print #TempFile1, Var$
 Close #TempFile1
Error.Resume157:
 Exit Sub
Error.Trap157:
 Resume Error.Resume157
End Sub

Sub NextRoom
 On Local Error Goto Error.Trap158
 If Room.Number>=Lof(RoomFile)/RoomRecLen Then
    Strng="This is the last room in the room file."
    Call ErrorMessage
 Else
    Call Write.Record(RoomFile,Room.Number)
    Room.Number=Room.Number+1!
    Call DisplayRoom
 Endif
Error.Resume158:
 Exit Sub
Error.Trap158:
 Resume Error.Resume158
End Sub

Sub PreviousRoom
 On Local Error Goto Error.Trap159
 If Room.Number<=1! Then
    Strng="This is the first room in the room file."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(RoomFile,Room.Number)
 Room.Number=Room.Number-1!
 Call DisplayRoom
Error.Resume159:
 Exit Sub
Error.Trap159:
 Resume Error.Resume159
End Sub

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

Sub RoomStatusLine
 On Local Error Goto Error.Trap161
 Strng="^ Cursor Select "+Chr$(60)+Chr$(217)
 Strng=Strng+" Enter Choice <esc> Exit ^h Help ^a Add ^n Next ^q Prev"
 Out2="^j Jump ^r Select ^w Search "
 Out2=Out2+"^e MonClass ^o Objects ^t Treasure ^g Containers"
 Call StatusLine
Error.Resume161:
 Exit Sub
Error.Trap161:
 Resume Error.Resume161
End Sub

Sub DisplayRoom
 On Local Error Goto Error.Trap152
 If Room.Number>SFalse And Room.Number<=Lof(RoomFile)/RoomRecLen Then
    Call Read.Record(RoomFile,Room.Number)
    For TempX=False To 20
       Call ShowRoom
    Next
    Call RedisplayField
 Endif
Error.Resume152:
 Exit Sub
Error.Trap152:
 Resume Error.Resume152
End Sub

Data1:
 Data 23,14,14,6,23,1,1
Data19:
 Data 23,29,29,20,23,1,1

Sub AddRoom
 On Local Error Goto Error.Trap23
 Room.Number=Lof(RoomFile)/RoomRecLen+1!
 RoomRecord.Action=SFalse
 RoomRecord.Custom1=Nul
 RoomRecord.Custom2=Nul
 For Var2=1 To MaxDirections
    RoomRecord.Direct(Var2)=SFalse
 Next
 RoomRecord.Direct(13)=SFalse
 RoomRecord.Direct(14)=SFalse
 For Var2=1 To 19
    RoomRecord.LongDesc(Var2)=SFalse
 Next
 RoomRecord.MonClass=SFalse
 RoomRecord.ShortDesc=Nul
 RoomRecord.First=SFalse
 RoomRecord.Last=SFalse
 RoomRecord.First2=SFalse
 RoomRecord.Last2=SFalse
 Call Write.Record(RoomFile,Room.Number)
 Call DisplayRoom
 If User.Index Then
    UserRecord.ObjectsCreated(7)=UserRecord.ObjectsCreated(7)+1#
    Var$=Lcase$(Rtrim$(UserRecord.CodeName))
    Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
    Call Write.Record(UserFile,User.Index)
 Else
    Var$="<local>"
 Endif
 Close #TempFile1
 Filename$=DND.Path+"created.dat"
 Open Filename$ For Append Shared As #TempFile1
 Var$=Var$+" created room"+Str$(Room.Number)+" on "
 Var$=Var$+Format$(Now,"mm-dd-yyyy")+" "+Format$(Now,"hh:mm:ss")
 Print #TempFile1, Var$
 Close #TempFile1
Error.Resume23:
 Exit Sub
Error.Trap23:
 Resume Error.Resume23
End Sub

Sub ShowRoom
 On Local Error Goto Error.Trap30
 Select Case TempX
 Case 0
    Call ANSI(4,33,44)
    Call ANSI(2,2,2)
    Strng="Room"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,7)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,7)
    Strng=Mid$(Str$(Room.Number),2)
    Call Scrn(Strng)
    Room.Treasure=SFalse
    Room.Objects=SFalse
    Temp2!=RoomRecord.First
    If Temp2! Then
       Do While Lost.Carrier=False
          Call Read.Record(RoomInvFile,Temp2!)
          If MessWorkRecord6.Room=SFalse Then
             Exit Do
          Endif
          Temp6!=MessWorkRecord6.Next
          If MessWorkRecord6.Index>SFalse Then
             Room.Treasure=Room.Treasure+1!
          Endif
          If MessWorkRecord6.Index<SFalse Then
             Room.Objects=Room.Objects+1!
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
    Room.Containers=SFalse
    Temp2!=RoomRecord.First2
    If Temp2! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Temp2!)
          Temp6!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Room.Containers=Room.Containers+1!
             Endif
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
    Call ANSI(4,33,44)
    Call ANSI(2,2,16)
    Strng="Treasure"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,25)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,25)
    Strng=Mid$(Str$(Room.Treasure),2)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,34)
    Strng="Objects"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,42)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,42)
    Strng=Mid$(Str$(Room.Objects),2)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,51)
    Strng="Containers"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    Call ANSI(2,2,62)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(2,2,62)
    Strng=Mid$(Str$(Room.Containers),2)
    Call Scrn(Strng)
 Case Else
    Call ANSI(4,37,40)
    Select Case TempX
    Case 1
       Call ANSI(2,4,2)
       Strng=Left$(RoomRecord.ShortDesc,78)
       Call Scrn(Strng)
    Case 2
       Call ANSI(2,7,2)
       For TempY=19 To 1 Step -1
          If RoomRecord.LongDesc(TempY)>SFalse Then
             Exit For
          Endif
       Next
       Strng="Lines:"+Str$(TempY)
       Call Scrn(Strng)
    Case 3
       Call ANSI(2,13,8)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,13,8)
       Strng=Mid$(Str$(RoomRecord.Direct(1)),2)
       Call Scrn(Strng)
    Case 4
       Call ANSI(2,15,7)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,15,7)
       Strng=Mid$(Str$(RoomRecord.Direct(2)),2)
       Call Scrn(Strng)
    Case 5
       Call ANSI(2,17,8)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,17,8)
       Strng=Mid$(Str$(RoomRecord.Direct(3)),2)
       Call Scrn(Strng)
    Case 6
       Call ANSI(2,19,7)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,19,7)
       Strng=Mid$(Str$(RoomRecord.Direct(4)),2)
       Call Scrn(Strng)
    Case 7
       Call ANSI(2,13,30)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,13,30)
       Strng=Mid$(Str$(RoomRecord.Direct(5)),2)
       Call Scrn(Strng)
    Case 8
       Call ANSI(2,15,30)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,15,30)
       Strng=Mid$(Str$(RoomRecord.Direct(6)),2)
       Call Scrn(Strng)
    Case 9
       Call ANSI(2,17,30)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,17,30)
       Strng=Mid$(Str$(RoomRecord.Direct(7)),2)
       Call Scrn(Strng)
    Case 10
       Call ANSI(2,19,30)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,19,30)
       Strng=Mid$(Str$(RoomRecord.Direct(8)),2)
       Call Scrn(Strng)
    Case 11
       Call ANSI(2,13,43)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,13,43)
       Strng=Mid$(Str$(RoomRecord.Direct(9)),2)
       Call Scrn(Strng)
    Case 12
       Call ANSI(2,15,45)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,15,45)
       Strng=Mid$(Str$(RoomRecord.Direct(10)),2)
       Call Scrn(Strng)
    Case 13
       Call ANSI(2,17,43)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,17,43)
       Strng=Mid$(Str$(RoomRecord.Direct(11)),2)
       Call Scrn(Strng)
    Case 14
       Call ANSI(2,19,44)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,19,44)
       Strng=Mid$(Str$(RoomRecord.Direct(12)),2)
       Call Scrn(Strng)
    Case 15
       Call ANSI(2,13,69)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,13,69)
       Strng=Mid$(Str$(RoomRecord.MonClass),2)
       Call Scrn(Strng)
    Case 16
       Call ANSI(2,15,67)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,15,67)
       Strng=Mid$(Str$(RoomRecord.Action),2)
       Call Scrn(Strng)
    Case 17
       Call ANSI(2,21,10)
       Strng=Space$(12)
       Call Scrn(Strng)
       Call ANSI(2,21,10)
       Strng=RoomRecord.Custom1
       Call Scrn(Strng)
    Case 18
       Call ANSI(2,21,29)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,21,29)
       Strng=Mid$(Str$(RoomRecord.Direct(13)),2)
       Call Scrn(Strng)
    Case 19
       Call ANSI(2,21,46)
       Strng=Space$(12)
       Call Scrn(Strng)
       Call ANSI(2,21,46)
       Strng=RoomRecord.Custom2
       Call Scrn(Strng)
    Case 20
       Call ANSI(2,21,65)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,21,65)
       Strng=Mid$(Str$(RoomRecord.Direct(14)),2)
       Call Scrn(Strng)
    End Select
 End Select
Error.Resume30:
 Exit Sub
Error.Trap30:
 Resume Error.Resume30
End Sub

Sub RoomEdit
 On Local Error Goto Error.Trap35
 Strng=Nul
 If Selection=2 Then
    Out2="^ Cursor Edit <esc> Exit Field"
 Else
    Out2="^ Cursor Edit "+Chr$(60)+Chr$(217)+" Exit Field"
 Endif
 Call StatusLine
 Restore RoomEditData
 For TempX=1 To Selection
    Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
 Next
 Select Case Selection
 Case 1
    Edit.Data(1)=Left$(RoomRecord.ShortDesc,78)
 Case 2
    Call ANSI(4,33,44)
    Call ANSI(2,3,2)
    Strng="Long Description:"
    Call Scrn(Strng)
    Call ANSI(4,37,40)
    For Var=4 To 22
       Call ANSI(2,Var,2)
       Strng=String$(78," ")
       Call Scrn(Strng)
    Next
    For Var=1 To 19
       Edit.Data(Var)=Nul
    Next
    For Var=1 To 19
       VarX!=RoomRecord.LongDesc(Var)
       If VarX!>SFalse And VarX!<=Lof(RoomDescFile)/RoomDescLen Then
          Call Read.Record(RoomDescFile,VarX!)
          Edit.Data(Var)=Left$(BufferRecord.Buffer,78)
          Call ANSI(2,Var+3,2)
          Strng=Rtrim$(Edit.Data(Var))
          Call Scrn(Strng)
       Endif
    Next
 Case 3
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(1)),2)
 Case 4
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(2)),2)
 Case 5
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(3)),2)
 Case 6
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(4)),2)
 Case 7
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(5)),2)
 Case 8
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(6)),2)
 Case 9
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(7)),2)
 Case 10
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(8)),2)
 Case 11
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(9)),2)
 Case 12
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(10)),2)
 Case 13
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(11)),2)
 Case 14
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(12)),2)
 Case 15
    Edit.Data(1)=Mid$(Str$(RoomRecord.MonClass),2)
 Case 16
    Edit.Data(1)=Mid$(Str$(RoomRecord.Action),2)
 Case 17
    Edit.Data(1)=Rtrim$(RoomRecord.Custom1)
 Case 18
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(13)),2)
 Case 19
    Edit.Data(1)=Rtrim$(RoomRecord.Custom2)
 Case 20
    Edit.Data(1)=Mid$(Str$(RoomRecord.Direct(14)),2)
 End Select
 Call ScreenEdit
 Select Case Selection
 Case 1
    RoomRecord.ShortDesc=Edit.Data(1)
 Case 2
    For TempY=19 To 1 Step -1
       Strng=Rtrim$(Edit.Data(TempY))
       If Len(Strng) Then
          Exit For
       Endif
    Next
    If TempY>False Then
       For TempZ=1 To TempY
          TempQ!=RoomRecord.LongDesc(TempZ)
          If TempQ!>SFalse And TempQ!<=Lof(RoomDescFile)/RoomDescLen Then
             Call Read.Record(RoomDescFile,TempQ!)
             BufferRecord.Buffer=Edit.Data(TempZ)
             Call Write.Record(RoomDescFile,TempQ!)
          Else
             TempQ!=Lof(RoomDescFile)/RoomDescLen+1!
             RoomRecord.LongDesc(TempZ)=TempQ!
             BufferRecord.Buffer=Edit.Data(TempZ)
             Call Write.Record(RoomDescFile,TempQ!)
          Endif
       Next
       For TempZ=TempY+1 To 19
          RoomRecord.LongDesc(TempZ)=SFalse
       Next
    Endif
 Case 3
    RoomRecord.Direct(1)=Int(Val(Edit.Data(1)))
 Case 4
    RoomRecord.Direct(2)=Int(Val(Edit.Data(1)))
 Case 5
    RoomRecord.Direct(3)=Int(Val(Edit.Data(1)))
 Case 6
    RoomRecord.Direct(4)=Int(Val(Edit.Data(1)))
 Case 7
    RoomRecord.Direct(5)=Int(Val(Edit.Data(1)))
 Case 8
    RoomRecord.Direct(6)=Int(Val(Edit.Data(1)))
 Case 9
    RoomRecord.Direct(7)=Int(Val(Edit.Data(1)))
 Case 10
    RoomRecord.Direct(8)=Int(Val(Edit.Data(1)))
 Case 11
    RoomRecord.Direct(9)=Int(Val(Edit.Data(1)))
 Case 12
    RoomRecord.Direct(10)=Int(Val(Edit.Data(1)))
 Case 13
    RoomRecord.Direct(11)=Int(Val(Edit.Data(1)))
 Case 14
    RoomRecord.Direct(12)=Int(Val(Edit.Data(1)))
 Case 15
    RoomRecord.MonClass=Int(Val(Edit.Data(1)))
 Case 16
    RoomRecord.Action=Int(Val(Edit.Data(1)))
 Case 17
    RoomRecord.Custom1=Ucase$(Rtrim$(Edit.Data(1)))
 Case 18
    RoomRecord.Direct(13)=Int(Val(Edit.Data(1)))
 Case 19
    RoomRecord.Custom2=Ucase$(Rtrim$(Edit.Data(1)))
 Case 20
    RoomRecord.Direct(14)=Int(Val(Edit.Data(1)))
 End Select
Error.Resume35:
 Exit Sub
Error.Trap35:
 Resume Error.Resume35
End Sub

RoomEditData:
 Data 4,2,2,78,1,4,1
 Data 4,2,2,78,19,4,1
 Data 13,8,8,8,1,13,1
 Data 15,7,7,8,1,15,1
 Data 17,8,8,8,1,17,1
 Data 19,7,7,8,1,19,1
 Data 13,30,30,8,1,13,1
 Data 15,30,30,8,1,15,1
 Data 17,30,30,8,1,17,1
 Data 19,30,30,8,1,19,1
 Data 13,43,43,8,1,13,1
 Data 15,45,45,8,1,15,1
 Data 17,43,43,8,1,17,1
 Data 19,44,44,8,1,19,1
 Data 13,69,69,8,1,13,1
 Data 15,67,67,8,1,15,1
 Data 21,10,10,12,1,21,1
 Data 21,29,29,8,1,21,1
 Data 21,46,46,12,1,21,1
 Data 21,65,65,8,1,21,1

Sub RoomSelect
 On Local Error Goto Error.Trap63
 Next.Field=False
 If TempX$=Chr$(9) Then
    TempX=77
 Endif
 Select Case TempX
 Case 77, 157, 116
    Select Case Selection
    Case 3 To 12
       Next.Field=Selection+4
    Case 17 To 19
       Next.Field=Selection+1
    End Select
 Case 15, 75, 155, 115
    Select Case Selection
    Case 7 To 16
       Next.Field=Selection-4
    Case 18 To 20
       Next.Field=Selection-1
    End Select
 Case 72, 141, 152
    Select Case Selection
    Case 2 To 20
       Next.Field=Selection-1
    End Select
 Case 80, 145, 160
    Select Case Selection
    Case 1 To 19
       Next.Field=Selection+1
    End Select
 Case 71, 119
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 79, 117
    If Selection<>20 Then
       Next.Field=20
    Endif
 Case 73, 132
    Select Case Selection
    Case 2 To 6
       Next.Field=1
    Case 8 To 10
       Next.Field=7
    Case 12 To 14
       Next.Field=11
    Case 16
       Next.Field=15
    Case 18 To 20
       Next.Field=17
    End Select
 Case 81, 118
    Select Case Selection
    Case 1 To 5
       Next.Field=6
    Case 7 To 9
       Next.Field=10
    Case 11 To 13
       Next.Field=14
    Case 15
       Next.Field=16
    Case 17 To 19
       Next.Field=20
    End Select
 End Select
 Call ShowField
Error.Resume63:
 Exit Sub
Error.Trap63:
 Resume Error.Resume63
End Sub

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

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

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

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

Sub EditRoomTreasure
 On Local Error Goto Error.Trap76
 Treasure.Number=1
 Call DisplayRoomTreasureScreen
 Do While Lost.Carrier=False
    Call RoomTreasureStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddRoomTreasure
       Case 4
          Call DeleteRoomTreasure
       Case 23
          Call SearchRoomTreasure
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousRoomTreasure
       Case 80, 145, 160
          Call NextRoomTreasure
       End Select
    End Select
 Loop
Error.Resume76:
 Exit Sub
Error.Trap76:
 Resume Error.Resume76
End Sub

Sub DeleteRoomTreasure
 On Local Error Goto Error.Trap77
 If Room.Treasure>SFalse Then
    Call Read.Record(RoomInvFile,Room.Index)
    If MessWorkRecord6.Room=Room.Number Then
       If MessWorkRecord6.Index>SFalse Then
          Call Delete.List.Node(Room.Index)
          Call Clear.List.Node
          Call Write.Record(RoomInvFile,Room.Index)
          Room.Treasure=Room.Treasure-1!
          Out2="The treasure has been deleted from the room."
          Call ErrorStatusLine
          Treasure.Number=1!
          Call DisplayRoomTreasureScreen
          TempX=False
          Call ShowRoom
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The treasure has not been deleted from the room."
 Call ErrorStatusLine
 Treasure.Number=1!
 Call DisplayRoomTreasureScreen
Error.Resume77:
 Exit Sub
Error.Trap77:
 Resume Error.Resume77
End Sub

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

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

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

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

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

Sub ShowRoomTreasure
 On Local Error Goto Error.Trap83
 TempD=True
 Call ANSI(4,33,44)
 For Var=7 To 11
    Call ANSI(2,Var,30)
    Strng=Space$(50)
    Call Scrn(Strng)
 Next
 Call ANSI(2,6,61)
 Strng=Space$(8)
 Call Scrn(Strng)
 Call ANSI(2,6,45)
 Strng="Treasure Number"+Str$(Treasure.Number)
 Call Scrn(Strng)
 If Treasure.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Treasure.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.TreasureName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(TreasureRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Weight:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(TreasureRecord.Weight),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Value:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(TreasureRecord.Gold),2)
 Call Scrn(Strng)
 Call ANSI(2,11,34)
 Strng="Hits:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(Abs(TreasureRecord.Plus)),2)
 Call Scrn(Strng)
 Call ANSI(2,7,60)
 Strng="Coins:"
 Call Scrn(Strng)
 If TreasureRecord.Coin Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Potion:"
 Call Scrn(Strng)
 If TreasureRecord.Potion Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Scroll:"
 Call Scrn(Strng)
 If TreasureRecord.Scroll Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If TreasureRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Key Number:"
 Call Scrn(Strng)
 If TreasureRecord.KeyNumber>SFalse Then
    Strng=Right$(Str$(TreasureRecord.KeyNumber+1000000!),6)
 Else
    Strng="0"
 Endif
 Call Scrn(Strng)
Error.Resume83:
 Exit Sub
Error.Trap83:
 Resume Error.Resume83
End Sub

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

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

Sub Add.List.Node(VarZ!)
 On Local Error Goto ErrorTrp27a
 Call Read.Record(RoomFile,Room.Number)
 If RoomRecord.First=SFalse Then
    RoomRecord.First=VarZ!
    RoomRecord.Last=VarZ!
    Call Write.Record(RoomFile,Room.Number)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(RoomInvFile,VarZ!)
    Exit Sub
 Endif
 MessWorkRecord6.Prev=RoomRecord.Last
 MessWorkRecord6.Next=SFalse
 Call Write.Record(RoomInvFile,VarZ!)
 Call Read.Record(RoomInvFile,RoomRecord.Last)
 MessWorkRecord6.Next=VarZ!
 Call Write.Record(RoomInvFile,RoomRecord.Last)
 Call Read.Record(RoomInvFile,VarZ!)
 RoomRecord.Last=VarZ!
 Call Write.Record(RoomFile,Room.Number)
ErrorRsm27a:
 Exit Sub
ErrorTrp27a:
 Resume ErrorRsm27a
End Sub

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

Sub Delete.List.Node(VarZ!)
 On Local Error Goto ErrorTrp32a
 Call Read.Record(RoomFile,Room.Number)
 If RoomRecord.First=VarZ! Then
    Call Read.Record(RoomInvFile,VarZ!)
    RoomRecord.First=MessWorkRecord6.Next
    Call Write.Record(RoomFile,Room.Number)
    If RoomRecord.First>SFalse Then
       Call Read.Record(RoomInvFile,RoomRecord.First)
       MessWorkRecord6.Prev=SFalse
       Call Write.Record(RoomInvFile,RoomRecord.First)
    Endif
 Else
    If RoomRecord.Last=VarZ! Then
       Call Read.Record(RoomInvFile,VarZ!)
       RoomRecord.Last=MessWorkRecord6.Prev
       Call Write.Record(RoomFile,Room.Number)
       If RoomRecord.Last>SFalse Then
          Call Read.Record(RoomInvFile,RoomRecord.Last)
          MessWorkRecord6.Next=SFalse
          Call Write.Record(RoomInvFile,RoomRecord.Last)
       Endif
    Else
       Call Read.Record(RoomInvFile,VarZ!)
       Previous.Node!=MessWorkRecord6.Prev
       Next.Node!=MessWorkRecord6.Next
       Call Read.Record(RoomInvFile,Previous.Node!)
       MessWorkRecord6.Next=Next.Node!
       Call Write.Record(RoomInvFile,Previous.Node!)
       Call Read.Record(RoomInvFile,Next.Node!)
       MessWorkRecord6.Prev=Previous.Node!
       Call Write.Record(RoomInvFile,Next.Node!)
    Endif
 Endif
ErrorRsm32a:
 Exit Sub
ErrorTrp32a:
 Resume ErrorRsm32a
End Sub

Sub ShowRoomObject
 On Local Error Goto Error.Trap118
 TempD=True
 Call ANSI(4,33,44)
 For Var=7 To 11
    Call ANSI(2,Var,30)
    Strng=Space$(50)
    Call Scrn(Strng)
 Next
 Call ANSI(2,6,58)
 Strng=Space$(8)
 Call Scrn(Strng)
 Call ANSI(2,6,45)
 Strng="Object Number"+Str$(Object.Number)
 Call Scrn(Strng)
 If Object.Index=SFalse Then
    Exit Sub
 Endif
 Call Read.Record(ObjectFile,Object.Index)
 Call ANSI(4,37,44)
 Call ANSI(2,7,34)
 Strng="Name:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ObjectName,20)
 Call Scrn(Strng)
 Call ANSI(2,8,34)
 Strng="Identifier:"
 Call Scrn(Strng)
 Strng=Left$(ObjectRecord.ShortName,14)
 Strng=Lcase$(Strng)
 Call Scrn(Strng)
 Call ANSI(2,9,34)
 Strng="Room Links:"
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink1),2)+","
 Call Scrn(Strng)
 Strng=Mid$(Str$(ObjectRecord.RoomLink2),2)
 Call Scrn(Strng)
 Call ANSI(2,10,34)
 Strng="Permanent:"
 Call Scrn(Strng)
 If ObjectRecord.Permanent Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,34)
 Strng="Hiding:"
 Call Scrn(Strng)
 If MessWorkRecord6.Plus=Hidden.Object Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,7,60)
 Strng="Hidden:"
 Call Scrn(Strng)
 If ObjectRecord.Hidden Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,8,60)
 Strng="Invisible:"
 Call Scrn(Strng)
 If ObjectRecord.Invisible Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,9,60)
 Strng="Trapped:"
 Call Scrn(Strng)
 If ObjectRecord.JailTrap Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,10,60)
 Strng="Locked:"
 Call Scrn(Strng)
 If ObjectRecord.DoorLock>1 Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
 Call ANSI(2,11,60)
 Strng="Relocks:"
 Call Scrn(Strng)
 If ObjectRecord.Relocks Then
    Call Scrn("Yes")
 Else
    Call Scrn("No")
 Endif
Error.Resume118:
 Exit Sub
Error.Trap118:
 Resume Error.Resume118
End Sub

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

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

Sub EditRoomObject
 On Local Error Goto Error.Trap112
 Object.Number=1!
 Call DisplayRoomObjectScreen
 Do While Lost.Carrier=False
    Call RoomObjectStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddRoomObject
       Case 4
          Call DeleteRoomObject
       Case 23
          Call SearchRoomObject
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousRoomObject
       Case 80, 145, 160
          Call NextRoomObject
       End Select
    End Select
 Loop
Error.Resume112:
 Exit Sub
Error.Trap112:
 Resume Error.Resume112
End Sub

Sub DeleteRoomObject
 On Local Error Goto Error.Trap113
 If Room.Objects>SFalse Then
    Call Read.Record(RoomInvFile,Room.Index)
    If MessWorkRecord6.Room=Room.Number Then
       If MessWorkRecord6.Index<SFalse Then
          Call Delete.List.Node(Room.Index)
          Call Clear.List.Node
          Call Write.Record(RoomInvFile,Room.Index)
          Room.Objects=Room.Objects-1!
          Out2="The object has been deleted from the room."
          Call ErrorStatusLine
          Object.Number=1!
          Call DisplayRoomObjectScreen
          TempX=False
          Call ShowRoom
          Exit Sub
       Endif
    Endif
 Endif
 Out2="The object has not been deleted from the room."
 Call ErrorStatusLine
 Object.Number=1!
 Call DisplayRoomObjectScreen
Error.Resume113:
 Exit Sub
Error.Trap113:
 Resume Error.Resume113
End Sub

Sub EditRoomContainers
 On Local Error Goto Error.Trap143c
 Container.Number=1
 Call DisplayRoomContainerScreen
 Do While Lost.Carrier=False
    Call GetRoomContainer
    Call RoomContainerStatusLine
    TempX$=Nul
    Do While TempX$=Nul
       If Lost.Carrier Then
          Exit Do
       Endif
       Call Read.Keyboard(TempX$)
       Call MouseDriver(3)
       If Mouse.Button2 Then
          TempX$=Chr$(27)
       Endif
       If Mouse.Button Then
          Call MouseCheck
          Exit Do
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddRoomContainer
       Case 4
          Call DeleteRoomContainer
       Case 23
          Call SearchRoomContainer
       Case 27
          Call ClearSubstats
          Exit Sub
       End Select
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          Call PreviousRoomContainer
       Case 80, 145, 160
          Call NextRoomContainer
       End Select
    End Select
 Loop
Error.Resume143c:
 Exit Sub
Error.Trap143c:
 Resume Error.Resume143c
End Sub

Sub DeleteRoomContainer
 On Local Error Goto Error.Trap144c
 VarQ=False
 Temp!=SFalse
 Call GetRoomContainer
 If Room.Containers>SFalse Then
    Inventory.Index!=RoomRecord.First2
    If Inventory.Index! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Inventory.Index!)
          Next.Index!=ContainerRecord.Next
          If ContainerRecord.DeletedContainer=False Then
             If ContainerRecord.WithinContainer=SFalse Then
                Temp!=Temp!+1!
                If Temp!=Container.Number Then
                   Call Delete.Room.Container(Inventory.Index!)
                   Call Clear.Container.Node
                   Call Write.Record(ContainerFile,Inventory.Index!)
                   VarQ=True
                   Exit Do
                Endif
             Endif
          Endif
          If Next.Index!=SFalse Then
             Exit Do
          Endif
          Inventory.Index!=Next.Index!
       Loop
    Endif
 Endif
 If VarQ=True Then
    Out2="The container has been deleted from the room."
    TempX=False
    Call ShowRoom
 Else
    Out2="The container was not deleted from the room."
 Endif
 Call ErrorStatusLine
 Container.Number=1
 Call DisplayRoomContainerScreen
Error.Resume144c:
 Exit Sub
Error.Trap144c:
 Resume Error.Resume144c
End Sub

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

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

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

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

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

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

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

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

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

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

Sub Drop.Container.In.Room(Var2!)
 On Local Error Goto ErrTrap48b
 VarA!=Lof(ContainerFile)/ContainerRecLen+1!
 Call Clear.Container
 ContainerRecord.ContainerName=TreasureRecord.TreasureName
 ContainerRecord.ContainerShort=TreasureRecord.ShortName
 ContainerRecord.ContainerMax=TreasureRecord.ContainerMax
 ContainerRecord.NamePrefix=TreasureRecord.ContainerPrefix
 ContainerRecord.Size=TreasureRecord.ContainerSize
 ContainerRecord.Material=TreasureRecord.ContainerMaterial
 If TreasureRecord.KeyNumber Then
    ContainerRecord.KeyNumber=TreasureRecord.KeyNumber
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 If TreasureRecord.Locked Then
    ContainerRecord.Closed=True
    ContainerRecord.Locked=True
 Endif
 ContainerRecord.RoomNumber=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!)
ErrResume48b:
 Exit Sub
ErrTrap48b:
 Resume ErrResume48b
End Sub

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

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