 Rem File: DndeditK.bas
 Rem Sub: EditTreasure
 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,"k")
    Close #TempFile1
    If Var=False Then
       Call Terminate.Program(True)
       End
    Endif
 Endif
Main.Resume:
 Call EditTreasure
 If Chained2 Then
    Chain DND.Path+"DNDEDIT.EXE"
 Endif
 Call Terminate.Program(True)
 End
Main.Error:
 Resume Main.Resume

Sub EditTreasure
 On Local Error Goto Error.Trap170
 Treasure.Number=1!
 If Lof(TreasureFile)=SFalse Then
    Call AddTreasure
 Endif
 Out3="Sysop Treasure Edit"
 Call DisplayEditScreen(3,38,Out3)
 Call TreasureStatusLine
 Call DisplayTreasure
 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(38)
          If Len(TempX$) Then
             Exit Do
          Endif
       Endif
       If Mouse.Row Or Mouse.Column Then
          Call MouseSelect(38)
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       If TempX=0 Then
          Call Write.Record(TreasureFile,Treasure.Number)
          Exit Do
       Endif
       Call TreasureSelect
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddTreasure
       Case 8
          Call Help(3)
          Out3="Sysop Treasure Edit"
          Call DisplayEditScreen(3,38,Out3)
          Call TreasureStatusLine
          Call DisplayTreasure
       Case 9
          Call TreasureSelect
       Case 13
          Call TreasureEdit
          Call Write.Record(TreasureFile,Treasure.Number)
          Call TreasureStatusLine
          TempX=Selection
          Call ShowTreasure
          Call RedisplayField
       Case 14
          Call NextTreasure
       Case 17
          Call PreviousTreasure
       Case 18
          Call SelectNextTreasure
          Call TreasureStatusLine
       Case 23
          Call SearchTreasure
       Case 27
          Call Write.Record(TreasureFile,Treasure.Number)
          Exit Sub
       End Select
    End Select
 Loop
Error.Resume170:
 Exit Sub
Error.Trap170:
 Resume Error.Resume170
End Sub

Sub NextTreasure
 On Local Error Goto Error.Trap171
 If Treasure.Number>=Lof(TreasureFile)/TreasureRecLen Then
    Strng="This is the last treasure in the treasure file."
    Call ErrorMessage
 Else
    Call Write.Record(TreasureFile,Treasure.Number)
    Treasure.Number=Treasure.Number+1!
    Call DisplayTreasure
 Endif
Error.Resume171:
 Exit Sub
Error.Trap171:
 Resume Error.Resume171
End Sub

Sub PreviousTreasure
 On Local Error Goto Error.Trap172
 If Treasure.Number>1! Then
    Call Write.Record(TreasureFile,Treasure.Number)
    Treasure.Number=Treasure.Number-1!
    Call DisplayTreasure
    Exit Sub
 Endif
 Strng="This is the first treasure in the treasure file."
 Call ErrorMessage
Error.Resume172:
 Exit Sub
Error.Trap172:
 Resume Error.Resume172
End Sub

Sub SelectNextTreasure
 On Local Error Goto Error.Trap173
 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 Treasure: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,18)
 Strng=Space$(6)
 Call Scrn(Strng)
 Call ANSI(4,37,44)
 Call ANSI(2,23,27)
 Strng="(1-"+Mid$(Str$(Lof(TreasureFile)/TreasureRecLen),2)+")"
 Multiplier=Len(Strng)+27
 Strng=Strng+" (+/-/x)"
 Call Scrn(Strng)
 Restore Data4
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Multiplier=False
 Temp2!=Int(Val(Edit.Data(1)))
 If Temp2!<=SFalse Or Temp2!>Lof(TreasureFile)/TreasureRecLen Then
    Strng="The treasure number is not within the treasure file range."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(TreasureFile,Treasure.Number)
 Treasure.Number=Temp2!
 Call DisplayTreasure
Error.Resume173:
 Exit Sub
Error.Trap173:
 Resume Error.Resume173
End Sub

Sub SearchTreasure
 On Local Error Goto Error.Trap174
 Call Write.Record(TreasureFile,Treasure.Number)
 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 Data5
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Call TreasureStatusLine
 Temp2!=Int(Val(Edit.Data(1)))
 Temp$=Lcase$(Edit.Data(1))
 If Temp2!>SFalse And Temp2!<=Lof(TreasureFile)/TreasureRecLen Then
    Treasure.Number=Temp2!
    Call DisplayTreasure
    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
 Temp4=Len(Temp$)
 Temp!=SFalse
 Temp3!=SFalse
 For Temp2!=1! To Lof(TreasureFile)/TreasureRecLen
    Call Read.Record(TreasureFile,Temp2!)
    Out3=Rtrim$(TreasureRecord.TreasureName)
    Call InstrSUB(TempX,Out3,Temp$)
    If TempX Then
       Temp3!=Temp3!+1!
       If Temp3!=1! Then
          Temp!=Temp2!
       Endif
       If Temp.Index Then
          If Temp3!=Temp.Index Then
             Treasure.Number=Temp2!
             Call DisplayTreasure
             Exit Sub
          Endif
       Endif
    Endif
 Next
 If Temp.Index>SFalse Then
    Strng="The treasure name was not found in the treasure file."
    Call ErrorMessage
    Call DisplayTreasure
    Exit Sub
 Endif
 If Temp3!=SFalse Then
    Strng="The treasure name was not found in the treasure file."
    Call ErrorMessage
    Call DisplayTreasure
    Exit Sub
 Endif
 If Temp3!=1! Then
    Treasure.Number=Temp!
    Call DisplayTreasure
    Exit Sub
 Endif
 Strng="There was more than one treasure found."
 Call ErrorMessage
 Strng="^ Scroll Treasure  "+Chr$(60)+Chr$(217)+" Select Treasure ("+Ltrim$(Str$(Temp3!))+" found)."
 Out2=Nul
 Call StatusLine
 Treasure.Number=Temp!
 Temp2!=Temp!
 Call Read.Record(TreasureFile,Treasure.Number)
 Call DisplayTreasure
 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
    Select Case Len(TempX$)
    Case 1
       If TempX$=Chr$(13) Then
          Treasure.Number=Temp2!
          Call TreasureStatusLine
          Call DisplayTreasure
          Exit Sub
       Endif
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       Select Case TempX
       Case 72, 141, 152
          TempA=False
          For Temp3!=Temp2!-1! To 1! Step -1!
             Call Read.Record(TreasureFile,Temp3!)
             Out3=Rtrim$(TreasureRecord.TreasureName)
             Call InstrSUB(TempX,Out3,Temp$)
             If TempX Then
                TempA=True
                Temp2!=Temp3!
                Treasure.Number=Temp3!
                Call DisplayTreasure
                Exit For
             Endif
          Next
          If TempA=False Then
             Strng="This is the first treasure in the search."
             Call ErrorMessage
          Endif
       Case 80, 145, 160
          TempA=False
          For Temp3!=Temp2!+1! To Lof(TreasureFile)/TreasureRecLen
             Call Read.Record(TreasureFile,Temp3!)
             Out3=Rtrim$(TreasureRecord.TreasureName)
             Call InstrSUB(TempX,Out3,Temp$)
             If TempX Then
                TempA=True
                Temp2!=Temp3!
                Treasure.Number=Temp3!
                Call DisplayTreasure
                Exit For
             Endif
          Next
          If TempA=False Then
             Strng="This is the last treasure in the search."
             Call ErrorMessage
          Endif
       End Select
    End Select
 Loop
Error.Resume174:
 Exit Sub
Error.Trap174:
 Resume Error.Resume174
End Sub

Data4:
 Data 23,18,18,6,23,1,1
Data5:
 Data 23,33,33,30,23,1,1

Sub TreasureStatusLine
 On Local Error Goto Error.Trap175
 Strng="^ Cursor Select "+Chr$(60)+Chr$(217)
 Strng=Strng+" Enter Choice <esc> Exit and Save ^h Help ^a Add Record"
 Out2="^n Next Treasure ^q Previous Treasure ^r Select Treasure ^w Search Treasure"
 Call StatusLine
Error.Resume175:
 Exit Sub
Error.Trap175:
 Resume Error.Resume175
End Sub

Sub DisplayTreasure
 On Local Error Goto Error.Trap169
 If Treasure.Number>SFalse And Treasure.Number<=Lof(TreasureFile)/TreasureRecLen Then
    Call Read.Record(TreasureFile,Treasure.Number)
    For TempX=False To 38
       Call ShowTreasure
    Next
    Call RedisplayField
 Endif
Error.Resume169:
 Exit Sub
Error.Trap169:
 Resume Error.Resume169
End Sub

Sub ShowTreasure
 On Local Error Goto Error.Trap24
 Select Case TempX
 Case 0
    Call ANSI(4,37,44)
    Call ANSI(2,2,11)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,2)
    Strng="Treasure"+Str$(Treasure.Number)
    Call Scrn(Strng)
    Exit Sub
 Case Else
    Call ANSI(4,37,40)
    Select Case TempX
    Case 1
       Call ANSI(2,4,2)
       Strng=TreasureRecord.TreasureName
       Call Scrn(Strng)
    Case 2
       Call ANSI(2,6,2)
       Strng=Lcase$(TreasureRecord.ShortName)
       Call Scrn(Strng)
    Case 3
       Call ANSI(2,8,9)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,8,9)
       Strng=Mid$(Str$(TreasureRecord.Weight),2)
       Call Scrn(Strng)
    Case 4
       Call ANSI(2,10,8)
       Strng=Space$(22)
       Call Scrn(Strng)
       Call ANSI(2,10,8)
       Strng=Mid$(Str$(TreasureRecord.Gold),2)
       Call Scrn(Strng)
    Case 5
       Call ANSI(2,12,7)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,12,7)
       Strng=Mid$(Str$(Abs(TreasureRecord.Plus)),2)
       Call Scrn(Strng)
    Case 6
       Call ANSI(2,14,10)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,14,10)
       Strng=Mid$(Str$(TreasureRecord.Charges),2)
       Call Scrn(Strng)
    Case 7
       Call ANSI(2,15,17)
       Select Case TreasureRecord.Proficiency
       Case 1
          Strng="B" ' blunt
       Case 2
          Strng="P" ' pole
       Case 3
          Strng="S" ' sharp
       Case 4
          Strng="T" ' thrusting
       Case Else
          Strng="?"
       End Select
       Call Scrn(Strng)
       Call ANSI(4,37,44)
       Call ANSI(2,15,7)
       Strng="(B/P/S/T)"
       Call Scrn(Strng)
    Case 8
       Call ANSI(2,17,16)
       If TreasureRecord.Container Then
          Strng="1"
       Else
          ' A=armor
          ' B=boot
          ' H=helmet
          ' R=ring(left)
          ' S=shield
          ' T=bracer
          ' W=weapon
          ' C=cloak
          ' 2=ring(right)
          ' U=amulet
          Var=TreasureRecord.WeaponNumber
          If Var>=1 And Var<=10 Then
             Strng=Mid$("ABHRSTWC2U",Var,1)
          Else
             Strng="?"
          Endif
       Endif
       Call Scrn(Strng)
       Call ANSI(4,37,44)
       Call ANSI(2,17,2)
       Strng="[12ABCHRSTUW]
       Call Scrn(Strng)
    Case 9
       Call ANSI(2,19,12)
       Strng="?"
       If TreasureRecord.Vehicle Then
          Select Case TreasureRecord.VehicleType
          Case 0
             Strng="L" ' land
          Case 1
             Strng="A" ' air
          Case 2
             Strng="W" ' water
          Case 3
             Strng="X" ' all terrain
          End Select
       Endif
       Call Scrn(Strng)
       Call ANSI(4,37,44)
       Call ANSI(2,19,2)
       Strng="(A/L/W/X)"
       Call Scrn(Strng)
    Case 10
       Call ANSI(2,20,16)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,20,16)
       Strng=Mid$(Str$(TreasureRecord.ContainerMax),2)
       Call Scrn(Strng)
    Case 11
       Call ANSI(2,3,26)
       If TreasureRecord.Coin Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 12
       Call ANSI(2,5,27)
       If TreasureRecord.Potion Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 13
       Call ANSI(2,7,27)
       If TreasureRecord.Scroll Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 14
       Call ANSI(2,9,30)
       If TreasureRecord.Invisible Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 15
       Call ANSI(2,11,29)
       If TreasureRecord.Loadable Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 16
       Call ANSI(2,14,20)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,14,20)
       Strng=Mid$(Str$(TreasureRecord.AmmoLoads),2)
       Call Scrn(Strng)
    Case 17
       Call ANSI(2,15,31)
       If TreasureRecord.Ammunition Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 18
       Call ANSI(2,17,31)
       Strng=Space$(6)
       Call Scrn(Strng)
       Call ANSI(2,17,31)
       If TreasureRecord.KeyNumber>SFalse Then
          Strng=Right$(Str$(TreasureRecord.KeyNumber+1000000!),6)
       Else
          If TreasureRecord.MasterKey Then
             Strng="-1"
          Else
             Strng="0"
          Endif
       Endif
       Call Scrn(Strng)
    Case 19
       Call ANSI(2,19,28)
       If TreasureRecord.Spell Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 20
       Call ANSI(2,20,37)
       Strng=Space$(15)
       Call Scrn(Strng)
       Call ANSI(2,20,37)
       Strng=Rtrim$(TreasureRecord.ContainerPrefix)
       Call Scrn(Strng)
    Case 21
       Call ANSI(2,4,40)
       Var!=TreasureRecord.Spell
       If Var!>SFalse And Var!<=Lof(SpellFile)/SpellRecLen Then
          Call Read.Record(SpellFile,Var!)
          Strng=Left$(SpellRecord.SpellName,20)
       Else
          Strng="<none>"+Space$(14)
       Endif
       Call Scrn(Strng)
    Case 22
       Call ANSI(2,5,45)
       If TreasureRecord.RingType Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 23
       Call ANSI(2,8,53)
       ' [A]ny spell =  3
       ' [P]oison =  1
       ' [L]evel drain =  2
       ' [O]ffense spell =  3
       ' [X]All traps =  4
       ' [R]usting =  5
       ' [S]tealing =  6
       ' [I]nventory damage =  7
       ' [F]umbling =  8
       ' [T]eleporting =  9
       Var=TreasureRecord.RingType
       If Var>=1 And Var<=9 Then
          If TreasureRecord.RingSpell=True Then
             Var=1
          Else
             Var=Var+1
          Endif
          Strng=Mid$("APLOXRSIFT",Var,1)
       Else
          Strng="?"
       Endif
       Call Scrn(Strng)
       Call ANSI(4,37,44)
       Call ANSI(2,8,40)
       ' [A]ny spell
       ' [F]umbling
       ' [I]nventory damage
       ' [L]evel drain
       ' [O]ffense spell
       ' [P]oison
       ' [R]usting
       ' [S]tealing
       ' [T]eleporting
       ' [X]All traps
       Strng="[AFILOPRSTX]"
       Call Scrn(Strng)
    Case 24
       Call ANSI(2,10,40)
       Select Case TreasureRecord.RingSpell
       Case Is<SFalse
          Strng="<generic spell>"+Space$(5)
       Case Is>SFalse
          Var!=TreasureRecord.RingSpell
          If Var!>SFalse And Var!<=Lof(SpellFile)/SpellRecLen Then
             Call Read.Record(SpellFile,Var!)
             Strng=Left$(SpellRecord.SpellName,20)
          Endif
       Case Else
          Strng="<none>"+Space$(14)
       End Select
       Call Scrn(Strng)
    Case 25
       Call ANSI(2,11,46)
       If TreasureRecord.LightType Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 26
       Call ANSI(2,13,54)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,13,54)
       Strng=Mid$(Str$(TreasureRecord.LightCharges),2)
       Call Scrn(Strng)
    Case 27
       Call ANSI(2,15,45)
       If TreasureRecord.FuelType Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 28
       Call ANSI(2,17,53)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,17,53)
       Strng=Mid$(Str$(TreasureRecord.FuelCharges),2)
       Call Scrn(Strng)
    Case 29
       Call ANSI(2,19,47)
       If TreasureRecord.Edible Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 30
       Call ANSI(2,3,71)
       If TreasureRecord.Rustable Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 31
       Call ANSI(2,5,75)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,5,75)
       Strng=Mid$(Str$(TreasureRecord.RustPercent),2)
       Call Scrn(Strng)
    Case 32
       Call ANSI(2,7,72)
       If TreasureRecord.Stealable Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 33
       Call ANSI(2,9,76)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,9,76)
       Strng=Mid$(Str$(TreasureRecord.StealPercent),2)
       Call Scrn(Strng)
    Case 34
       Call ANSI(2,11,73)
       If TreasureRecord.Launchable Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 35
       Call ANSI(2,14,62)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,14,62)
       Strng=Mid$(Str$(TreasureRecord.LaunchLoads),2)
       Call Scrn(Strng)
    Case 36
       Call ANSI(2,15,74)
       If TreasureRecord.LaunchAmmo Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 37
       Call ANSI(2,17,70)
       If TreasureRecord.Movable Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 38
       Call ANSI(2,19,70)
       If TreasureRecord.Vehicle Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    End Select
 End Select
Error.Resume24:
 Exit Sub
Error.Trap24:
 Resume Error.Resume24
End Sub

Sub AddTreasure
 On Local Error Goto Error.Trap25
 Treasure.Number=Lof(TreasureFile)/TreasureRecLen+1!
 TreasureRecord.TreasureName=Nul
 TreasureRecord.ShortName=Nul
 TreasureRecord.Weight=False
 TreasureRecord.Gold=False
 TreasureRecord.Spell=False
 TreasureRecord.Plus=False
 TreasureRecord.Coin=False
 TreasureRecord.Locked=False
 TreasureRecord.KeyNumber=SFalse
 TreasureRecord.Scroll=False
 TreasureRecord.Charges=False
 TreasureRecord.Potion=False
 TreasureRecord.Loadable=False
 TreasureRecord.Ammunition=False
 TreasureRecord.AmmoLoads=False
 TreasureRecord.Invisible=False
 TreasureRecord.Permanent=False
 TreasureRecord.StaysInRoom=False
 TreasureRecord.Occupants=False
 TreasureRecord.Proficiency=False
 TreasureRecord.WeaponNumber=False
 TreasureRecord.RingType=False
 TreasureRecord.RingSpell=False
 TreasureRecord.Edible=False
 TreasureRecord.Rustable=False
 TreasureRecord.RustPercent=False
 TreasureRecord.Stealable=False
 TreasureRecord.StealPercent=False
 TreasureRecord.Launchable=False
 TreasureRecord.LaunchLoads=False
 TreasureRecord.LaunchAmmo=False
 TreasureRecord.Movable=False
 TreasureRecord.Vehicle=False
 TreasureRecord.VehicleType=False
 TreasureRecord.LightType=False
 TreasureRecord.LightCharges=False
 TreasureRecord.FuelType=False
 TreasureRecord.FuelCharges=False
 TreasureRecord.Container=False
 TreasureRecord.ContainerMax=False
 TreasureRecord.ContainerPrefix="in it"
 TreasureRecord.ContainerDisappears=False
 TreasureRecord.ContainerSize=False
 TreasureRecord.ContainerMaterial=False
 TreasureRecord.ContainerSelfImplodes=False
 TreasureRecord.PotionType=False
 TreasureRecord.NewPotion=False
 TreasureRecord.MixPotion=False
 TreasureRecord.TwoHanded=False
 TreasureRecord.RequireStr=False
 TreasureRecord.RequireDex=False
 TreasureRecord.RequireInt=False
 For Var=1 To 3
    TreasureRecord.RestrictItem(Var)=SFalse
 Next
 TreasureRecord.TrapType=False
 TreasureRecord.TrapHits=False
 TreasureRecord.TrapItem=SFalse
 TreasureRecord.MasterKey=False
 TreasureRecord.Liquid=False
 TreasureRecord.LiquidType=False
 TreasureRecord.LiquidFlags=False
 TreasureRecord.Prefix1=Nul
 TreasureRecord.StaysInRoom=0
 TreasureRecord.Occupants=0
 TreasureRecord.BindType=0
 TreasureRecord.TimesCursed=0
 TreasureRecord.TimesBlessed=0
 TreasureRecord.Persistent=0
 TreasureRecord.MaxPersistCharges=0
 TreasureRecord.PersistTime=0!
 TreasureRecord.DischargePersist=0!
 TreasureRecord.ProperName=""
 Call Write.Record(TreasureFile,Treasure.Number)
 Call DisplayTreasure
 UserRecord.ObjectsCreated(9)=UserRecord.ObjectsCreated(9)+1#
 If User.Index Then
    Call Write.Record(UserFile,User.Index)
 Endif
Error.Resume25:
 Exit Sub
Error.Trap25:
 Resume Error.Resume25
End Sub

Sub TreasureEdit
 On Local Error Goto Error.Trap37
 Static TempE
 ' display for ring type:
       ' [A]ny spell
       ' [F]umbling
       ' [I]nventory damage
       ' [L]evel drain
       ' [O]ffense spell
       ' [P]oison
       ' [R]usting
       ' [S]tealing
       ' [T]eleporting
       ' [X]All traps
 Restore TreasureEditData
 For TempX=1 To Selection
    Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
 Next
 TempE=False
 Select Case Selection
 Case 1
    Edit.Data(1)=TreasureRecord.TreasureName
 Case 2
    Edit.Data(1)=Lcase$(TreasureRecord.ShortName)
 Case 3
    Edit.Data(1)=Mid$(Str$(TreasureRecord.Weight),2)
 Case 4
    Edit.Data(1)=Mid$(Str$(TreasureRecord.Gold),2)
 Case 5
    Edit.Data(1)=Mid$(Str$(TreasureRecord.Plus),2)
 Case 6
    Edit.Data(1)=Mid$(Str$(TreasureRecord.Charges),2)
 Case 7
    Call MakeBox(3,62,8,77)
    Call ANSI(4,37,40)
    Call ANSI(2,4,63)
    Strng="B=Blunt       "
    Call Scrn(Strng)
    Call ANSI(2,5,63)
    Strng="P=Pole        "
    Call Scrn(Strng)
    Call ANSI(2,6,63)
    Strng="S=Sharp       "
    Call Scrn(Strng)
    Call ANSI(2,7,63)
    Strng="T=Thrusting   "
    Call Scrn(Strng)
    Select Case TreasureRecord.Proficiency
    Case 1
       Edit.Data(1)="B" ' blunt
    Case 2
       Edit.Data(1)="P" ' pole
    Case 3
       Edit.Data(1)="S" ' sharp
    Case 4
       Edit.Data(1)="T" ' thrusting
    Case Else
       Edit.Data(1)="?"
    End Select       
 Case 8
    Call MakeBox(3,62,15,79)
    Call ANSI(4,37,40)
    Call ANSI(2,4,63)
    Strng="1=Container     "
    Call Scrn(Strng)
    Call ANSI(2,5,63)
    Strng="2=Ring(right)   "
    Call Scrn(Strng)
    Call ANSI(2,6,63)
    Strng="A=Armor         "
    Call Scrn(Strng)
    Call ANSI(2,7,63)
    Strng="B=Boot          "
    Call Scrn(Strng)
    Call ANSI(2,8,63)
    Strng="C=Cloak         "
    Call Scrn(Strng)
    Call ANSI(2,9,63)
    Strng="H=Helmet        "
    Call Scrn(Strng)
    Call ANSI(2,10,63)
    Strng="R=Ring(left)    "
    Call Scrn(Strng)
    Call ANSI(2,11,63)
    Strng="S=Shield        "
    Call Scrn(Strng)
    Call ANSI(2,12,63)
    Strng="T=Bracers       "
    Call Scrn(Strng)
    Call ANSI(2,13,63)
    Strng="U=Amulet        "
    Call Scrn(Strng)
    Call ANSI(2,14,63)
    Strng="W=Weapon        "
    Call Scrn(Strng)
    If TreasureRecord.Container Then
       Edit.Data(1)="1"
    Else
       ' A=armor
       ' B=boot
       ' H=helmet
       ' R=ring(left)
       ' S=shield
       ' T=bracer
       ' W=weapon
       ' C=cloak
       ' 2=ring(right
       ' U=amulet
       Var=TreasureRecord.WeaponNumber
       If Var>=1 And Var<=10 Then
          Edit.Data(1)=Mid$("ABHRSTWC2U",Var,1)
       Else
          Edit.Data(1)="?"
       Endif
    Endif
 Case 9
    Call MakeBox(3,62,8,77)
    Call ANSI(4,37,40)
    Call ANSI(2,4,63)
    Strng="L=Land        "
    Call Scrn(Strng)
    Call ANSI(2,5,63)
    Strng="A=Air         "
    Call Scrn(Strng)
    Call ANSI(2,6,63)
    Strng="W=Water       "
    Call Scrn(Strng)
    Call ANSI(2,7,63)
    Strng="X=All Terrain "
    Call Scrn(Strng)
    Edit.Data(1)="?"
    If TreasureRecord.Vehicle Then
       Select Case TreasureRecord.VehicleType
       Case 0
          Edit.Data(1)="L" ' land
       Case 1
          Edit.Data(1)="A" ' air
       Case 2
          Edit.Data(2)="W" ' water
       Case 3
          Edit.Data(1)="X" ' all terrain
       End Select
    Endif
 Case 10
    Edit.Data(1)=Mid$(Str$(TreasureRecord.ContainerMax),2)
 Case 11
    If TreasureRecord.Coin Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 12
    If TreasureRecord.Potion Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 13
    If TreasureRecord.Scroll Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 14
    If TreasureRecord.Invisible Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 15
    If TreasureRecord.Loadable Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 16
    Call SearchAmmo(0)
    Call Read.Record(TreasureFile,Treasure.Number)
    TreasureRecord.AmmoLoads=TempX!
    Exit Sub
 Case 17
    If TreasureRecord.Ammunition Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 18
    If TreasureRecord.KeyNumber>SFalse Then
       Edit.data(1)=Right$(Str$(TreasureRecord.KeyNumber+1000000!),6)
    Else
       If TreasureRecord.MasterKey Then
          Edit.Data(1)="-1"
       Else
          Edit.Data(1)="0"
       Endif
    Endif
 Case 19
    If TreasureRecord.Spell Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 20
    Edit.Data(1)=TreasureRecord.ContainerPrefix
 Case 21
    Var!=TreasureRecord.Spell
    If Var!>SFalse And Var!<=Lof(SpellFile)/SpellRecLen Then
       Call Read.Record(SpellFile,Var!)
       Edit.Data(1)=Left$(SpellRecord.SpellName,20)
    Else
       Edit.Data(1)=Nul
       Call ANSI(4,37,40)
       Call ANSI(2,4,40)
       Strng=Space$(20)
       Call Scrn(Strng)
    Endif
 Case 22
    If TreasureRecord.RingType Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 23
    Call MakeBox(3,62,14,79)
    Call ANSI(4,37,40)
    Call ANSI(2,4,63)
    Strng="A=Any Spell     "
    Call Scrn(Strng)
    Call ANSI(2,5,63)
    Strng="I=Inv Damage    "
    Call Scrn(Strng)
    Call ANSI(2,6,63)
    Strng="F=Fumbling      "
    Call Scrn(Strng)
    Call ANSI(2,7,63)
    Strng="L=Level Drain   "
    Call Scrn(Strng)
    Call ANSI(2,8,63)
    Strng="O=Offense Spell "
    Call Scrn(Strng)
    Call ANSI(2,9,63)
    Strng="P=Poison        "
    Call Scrn(Strng)
    Call ANSI(2,10,63)
    Strng="R=Rusting       "
    Call Scrn(Strng)
    Call ANSI(2,11,63)
    Strng="S=Stealing      "
    Call Scrn(Strng)
    Call ANSI(2,12,63)
    Strng="T=Teleporting   "
    Call Scrn(Strng)
    Call ANSI(2,13,63)
    Strng="X=All Traps     "
    Call Scrn(Strng)
    ' [A]ny spell =  3
    ' [P]oison =  1
    ' [L]evel drain =  2
    ' [O]ffense spell =  3
    ' [X]All traps =  4
    ' [R]usting =  5
    ' [S]tealing =  6
    ' [I]nventory damage =  7
    ' [F]umbling =  8
    ' [T]eleporting =  9
    Var=TreasureRecord.RingType
    If Var>False And Var<=9 Then
       If TreasureRecord.RingSpell=True Then
          Var=1
       Else
          Var=Var+1
       Endif
       Edit.Data(1)=Mid$("APLOXRSIFT",Var,1)
    Else
       Edit.Data(1)="?"
    Endif
 Case 24
    Edit.Data(1)="<none>"
    If TreasureRecord.RingType=3 Then
       Var!=TreasureRecord.RingSpell
       If Var!=STrue Then
          Edit.Data(1)="<generic spell>"
       Else
          If Var!>SFalse And Var!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(SpellFile,Var!)
             Edit.Data(1)=Left$(SpellRecord.SpellName,20)
          Endif
       Endif
    Endif
 Case 25
    If TreasureRecord.LightType Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 26
    Edit.Data(1)=Mid$(Str$(TreasureRecord.LightCharges),2)
 Case 27
    If TreasureRecord.FuelType Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 28
    Edit.Data(1)=Mid$(Str$(TreasureRecord.FuelCharges),2)
 Case 29
    If TreasureRecord.Edible Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 30
    If TreasureRecord.Rustable Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 31
    Edit.Data(1)=Mid$(Str$(TreasureRecord.RustPercent),2)
 Case 32
    If TreasureRecord.Stealable Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 33
    Edit.Data(1)=Mid$(Str$(TreasureRecord.StealPercent),2)
 Case 34
    If TreasureRecord.Launchable Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 35
    Call SearchAmmo(-1)
    Call Read.Record(TreasureFile,Treasure.Number)
    TreasureRecord.LaunchLoads=TempX!
    Exit Sub
 Case 36
    If TreasureRecord.LaunchAmmo Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 37
    If TreasureRecord.Movable Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 38
    If TreasureRecord.Vehicle Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 End Select
 Strng="^ Cursor Edit   "
 Out2=Chr$(60)+Chr$(217)+" Exit Field"
 Call StatusLine
 Edit.Data(1)=Rtrim$(Edit.Data(1))
 Call ScreenEdit
 Select Case Selection
 Case 1
    TreasureRecord.TreasureName=Lcase$(Edit.Data(1))
 Case 2
    TreasureRecord.ShortName=Ucase$(Edit.Data(1))
 Case 3
    TreasureRecord.Weight=Val(Edit.Data(1))
 Case 4
    TreasureRecord.Gold=Val(Edit.Data(1))
 Case 5
    TreasureRecord.Plus=Val(Edit.Data(1))
 Case 6
    TreasureRecord.Charges=Val(Edit.Data(1))
 Case 7
    Call ANSI(4,37,44)
    For TempX=3 To 8
       Call ANSI(2,TempX,62)
       Strng=Space$(16)
       Call Scrn(Strng)
    Next
    Call ANSI(4,33,44)
    For Temp2=30 To 33
       Call ANSI(2,Array.Data(Temp2,1),Array.Data(Temp2,2))
       Strng=Title.Data(Temp2)
       Call Scrn(Strng)
    Next
    For TempX=30 To 33
       Call ShowTreasure
    Next
    Select Case Ucase$(Edit.Data(1))
    Case "B" ' blunt
       TreasureRecord.Proficiency=1
    Case "P" ' pole
       TreasureRecord.Proficiency=2
    Case "S" ' sharp
       TreasureRecord.Proficiency=3
    Case "T" ' thrusting
       TreasureRecord.Proficiency=4
    Case Else
       TreasureRecord.Proficiency=False
    End Select
 Case 8
    Call ANSI(4,37,44)
    For TempX=3 To 15
       Call ANSI(2,TempX,62)
       Strng=Space$(18)
       Call Scrn(Strng)
    Next
    Call ANSI(4,33,44)
    For Temp2=30 To 36
       Call ANSI(2,Array.Data(Temp2,1),Array.Data(Temp2,2))
       Strng=Title.Data(Temp2)
       Call Scrn(Strng)
    Next
    For TempX=30 To 36
       Call ShowTreasure
    Next
    Edit.Data(1)=Ucase$(Edit.Data(1))
    If Len(Edit.Data(1)) Then
       If Edit.Data(1)="1" Then
          TreasureRecord.Container=True
          TreasureRecord.ContainerMax=10
          TreasureRecord.WeaponNumber=False
       Else
          ' A=armor
          ' B=boot
          ' H=helmet
          ' R=ring(left)
          ' S=shield
          ' T=bracer
          ' W=weapon
          ' C=cloak
          ' 2=ring(right)
          ' U=amulet
          Var=Instr("ABHRSTWC2U",Edit.Data(1))
          If Var>=1 And Var<=10 Then
             TreasureRecord.Container=False
             TreasureRecord.ContainerMax=False
             TreasureRecord.WeaponNumber=Var
          Else
             TreasureRecord.Container=False
             TreasureRecord.ContainerMax=False
             TreasureRecord.WeaponNumber=False
          Endif
       Endif
    Endif
    Select Case TreasureRecord.WeaponNumber
    Case 4, 9
       TreasureRecord.RingType=3
       TreasureRecord.RingSpell=True
    Case Else
       TreasureRecord.RingType=False
       TreasureRecord.RingSpell=False
    End Select
 Case 9
    Call ANSI(4,37,44)
    For TempX=3 To 8
       Call ANSI(2,TempX,62)
       Strng=Space$(16)
       Call Scrn(Strng)
    Next
    Call ANSI(4,33,44)
    For Temp2=30 To 33
       Call ANSI(2,Array.Data(Temp2,1),Array.Data(Temp2,2))
       Strng=Title.Data(Temp2)
       Call Scrn(Strng)
    Next
    For TempX=30 To 33
       Call ShowTreasure
    Next
    If TreasureRecord.Vehicle Then
       Select Case Ucase$(Edit.Data(1))
       Case "L" ' land
          TreasureRecord.VehicleType=False
       Case "A" ' air
          TreasureRecord.VehicleType=1
       Case "W" ' water
          TreasureRecord.VehicleType=2
       Case "X" ' all terrain
          TreasureRecord.VehicleType=3
       Case Else
          TreasureRecord.VehicleType=3
       End Select
    Endif
 Case 10
    TreasureRecord.ContainerMax=Int(Val(Edit.Data(1)))
 Case 11
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Coin=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Coin=False
    Endif
 Case 12
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Potion=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Potion=False
    Endif
 Case 13
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Scroll=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Scroll=False
    Endif
 Case 14
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Invisible=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Invisible=False
    Endif
 Case 15
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Loadable=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Loadable=False
    Endif
 Case 17
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Ammunition=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Ammunition=False
    Endif
 Case 18
    If Val(Edit.Data(1))>=0 Then
       TreasureRecord.KeyNumber=Int(Val(Edit.Data(1)))
       TreasureRecord.MasterKey=0
    Else
       If Val(Edit.Data(1))=-1 Then
          TreasureRecord.KeyNumber=0!
          TreasureRecord.MasterKey=-1
       Endif
    Endif
 Case 19
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Spell=True
       TempX=Selection
       Call ShowTreasure
       Next.Field=21
       Call ShowField
       TempE=True
       Call TreasureEdit
       Exit Sub
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Spell=False
       TempX=21
       Call ShowTreasure
    Endif
 Case 20
    TreasureRecord.ContainerPrefix=Lcase$(Edit.Data(1))
 Case 21
    Edit.Data(1)=Rtrim$(Edit.Data(1))
    Edit.Data(1)=Lcase$(Edit.Data(1))
    If Edit.Data(1)=Nul Then
       TreasureRecord.Spell=SFalse
       TempX=19
       Call ShowTreasure
    Else
       For Temp2!=1! To Lof(SpellFile)/SpellRecLen
          Call Read.Record(SpellFile,Temp2!)
          If Left$(SpellRecord.SpellName,Len(Edit.Data(1)))=Edit.Data(1) Then
             TreasureRecord.Spell=Temp2!
             If TempE=False Then
                TempX=19
                Call ShowTreasure
             Endif
             Exit Sub
          Endif
       Next
       TreasureRecord.Spell=SFalse
       TempX=19
       Call ShowTreasure
       Strng="The spell was not found in the spell file."
       Call ErrorMessage
    Endif
 Case 22
    Call ANSI(4,37,40)
    Select Case Ucase$(Edit.Data(1))
    Case "Y"
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=4
       TreasureRecord.RingType=3
       TreasureRecord.RingSpell=True
    Case "N"
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=False
       TreasureRecord.RingType=False
       TreasureRecord.RingSpell=False
    End Select
 Case 23
    Call ANSI(4,37,44)
    For TempX=3 To 14
       Call ANSI(2,TempX,62)
       Strng=Space$(18)
       Call Scrn(Strng)
    Next
    Call ANSI(4,33,44)
    For Temp2=30 To 35
       Call ANSI(2,Array.Data(Temp2,1),Array.Data(Temp2,2))
       Strng=Title.Data(Temp2)
       Call Scrn(Strng)
    Next
    For TempX=30 To 35
       Call ShowTreasure
    Next
    ' [A]ny spell =  3
    ' [P]oison =  1
    ' [L]evel drain =  2
    ' [O]ffense spell =  3
    ' [X]All traps =  4
    ' [R]usting =  5
    ' [S]tealing =  6
    ' [I]nventory damage =  7
    ' [F]umbling =  8
    ' [T]eleporting =  9
    Edit.Data(1)=Ucase$(Edit.Data(1))
    Var=Instr("APLOXRSIFT",Edit.Data(1))
    Select Case Var
    Case 1
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=4
       TreasureRecord.RingType=3
       TreasureRecord.RingSpell=True
    Case 2 To 10
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=4
       TreasureRecord.RingType=Var-1
       TreasureRecord.RingSpell=False
    Case Else
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=False
       TreasureRecord.RingType=False
       TreasureRecord.RingSpell=False
    End Select
 Case 24
    Edit.Data(1)=Rtrim$(Edit.Data(1))
    Edit.Data(1)=Lcase$(Edit.Data(1))
    Select Case Edit.Data(1)
    Case Nul
       TreasureRecord.RingType=False
       TreasureRecord.RingSpell=False
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=False
    Case "<none>"
       TreasureRecord.RingType=3
       TreasureRecord.RingSpell=False
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=4
    Case "<generic spell>"
       TreasureRecord.RingType=3
       TreasureRecord.RingSpell=True
       TreasureRecord.Container=False
       TreasureRecord.ContainerMax=False
       TreasureRecord.WeaponNumber=4
    Case Else
       Var=False
       For Temp2!=1! To Lof(SpellFile)/SpellRecLen
          Call Read.Record(SpellFile,Temp2!)
          If Left$(SpellRecord.SpellName,Len(Edit.Data(1)))=Edit.Data(1) Then
             If SpellRecord.SpellType=Offense Or SpellRecord.SpellType=Invisibly Then
                Var=True
                Exit For
             Endif
          Endif
       Next
       If Var Then
          TreasureRecord.RingType=3
          TreasureRecord.RingSpell=Temp2!
          TreasureRecord.Container=False
          TreasureRecord.ContainerMax=False
          TreasureRecord.WeaponNumber=4
       Else
          TreasureRecord.RingType=False
          TreasureRecord.RingSpell=SFalse
          TreasureRecord.Container=False
          TreasureRecord.ContainerMax=False
          TreasureRecord.WeaponNumber=False
          Strng="The offense/invisible spell was not found in the spell file."
          Call ErrorMessage
       Endif
    End Select
 Case 25
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.LightType=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.LightType=False
    Endif
 Case 26
    TreasureRecord.LightCharges=Int(Val(Edit.Data(1)))
 Case 27
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.FuelType=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.FuelType=False
    Endif
 Case 28
    TreasureRecord.FuelCharges=Int(Val(Edit.Data(1)))
 Case 29
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Edible=1
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Edible=0
    Endif
 Case 30
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Rustable=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Rustable=False
    Endif
 Case 31
    TreasureRecord.RustPercent=Int(Val(Edit.Data(1)))
 Case 32
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Stealable=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Stealable=False
    Endif
 Case 33
    TreasureRecord.StealPercent=Int(Val(Edit.Data(1)))
 Case 34
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Launchable=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Launchable=False
    Endif
 Case 36
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.LaunchAmmo=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.LaunchAmmo=False
    Endif
 Case 37
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Movable=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Movable=False
    Endif
 Case 38
    If Ucase$(Edit.Data(1))="Y" Then
       TreasureRecord.Vehicle=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       TreasureRecord.Vehicle=False
    Endif
 End Select
 Select Case Selection
 Case 8, 20 To 22
    TempX=8
    Call ShowTreasure
    TempX=22
    Call ShowTreasure
    TempX=23
    Call ShowTreasure
    TempX=24
    Call ShowTreasure
 End Select
Error.Resume37:
 Exit Sub
Error.Trap37:
 Resume Error.Resume37
End Sub

Sub SearchAmmo(Var)
 On Local Error Goto Error.Trap87z
 Call Write.Record(TreasureFile,Treasure.Number)
 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 TreasureData3
 Read Xcoor, Ycoor, Column, Line.Length, Max.Lines, Row, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Temp2!=Int(Val(Edit.Data(1)))
 TempX!=SFalse
 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!)
       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
    Next
 Endif
 If Temp2!=SFalse Then
    Out2="The treasure ammo was not found in the treasure file."
    Call ErrorStatusLine
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Temp2!)
 If Var=False Then
    If TreasureRecord.Ammunition Then
       TempX!=Temp2!
    Endif
 Else
    If TreasureRecord.LaunchAmmo Then
       TempX!=Temp2!
    Endif
 Endif
 If TempX!=SFalse Then
    Out2="The treasure ammo was not found in the treasure file."
    Call ErrorStatusLine
 Endif
Error.Resume87z:
 Exit Sub
Error.Trap87z:
 Resume Error.Resume87z
End Sub

TreasureEditData:
 Data 4,2,2,30,1,4,1
 Data 6,2,2,30,1,6,1
 Data 8,9,9,5,1,8,1
 Data 10,8,8,22,1,10,1
 Data 12,7,7,5,1,12,1
 Data 14,10,10,5,1,14,1
 Data 15,17,17,1,1,15,1
 Data 17,16,16,1,1,17,1
 Data 19,12,12,1,1,19,1
 Data 20,16,16,3,1,20,1
 Data 3,26,26,1,1,3,1
 Data 5,27,27,1,1,5,1
 Data 7,27,27,1,1,7,1
 Data 9,30,30,1,1,9,1
 Data 11,29,29,1,1,11,1
 Data 14,20,20,8,1,14,1
 Data 15,31,31,1,1,15,1
 Data 17,31,31,6,1,17,1
 Data 19,28,28,1,1,19,1
 Data 20,37,37,15,1,20,1
 Data 4,40,40,20,1,4,1
 Data 5,45,45,1,1,5,1
 Data 8,53,53,1,1,8,1
 Data 10,40,40,20,1,10,1
 Data 11,46,46,1,1,11,1
 Data 13,54,54,5,1,13,1
 Data 15,45,45,8,1,15,1
 Data 17,53,53,1,1,17,1
 Data 19,47,47,1,1,19,1
 Data 3,71,71,1,1,3,1
 Data 5,75,75,3,1,5,1
 Data 7,72,72,1,1,7,1
 Data 9,76,76,3,1,9,1
 Data 11,73,73,1,1,11,1
 Data 14,62,62,8,1,14,1
 Data 15,74,74,1,1,15,1
 Data 17,70,70,1,1,17,1
 Data 19,70,70,1,1,19,1

TreasureData3:
 Data 23,33,33,30,1,23,1

Sub TreasureSelect
 On Local Error Goto Error.Trap65
 Next.Field=False
 If TempX$=Chr$(9) Then
    TempX=77
 Endif
 Select Case TempX
 Case 77, 157, 116
    Select Case Selection
    Case 1 To 10
       Next.Field=Selection+10
    Case 11 To 20
       Next.Field=Selection+10
    Case 21 To 29
       Next.Field=Selection+9
    End Select
 Case 15, 75, 155, 115
    Select Case Selection
    Case 11 To 20
       Next.Field=Selection-10
    Case 21 To 29
       Next.Field=Selection-10
    Case 30 To 38
       Next.Field=Selection-9
    End Select
 Case 72, 141, 152
    If Selection>1 Then
       Next.Field=Selection-1
    Endif
 Case 80, 145, 160
    If Selection<38 Then
       Next.Field=Selection+1
    Endif
 Case 71, 119
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 79, 117
    If Selection<>38 Then
       Next.Field=38
    Endif
 Case 73, 132
    Select Case Selection
    Case 2 To 10
       Next.Field=1
    Case 12 To 20
       Next.Field=11
    Case 22 To 29
       Next.Field=21
    Case 31 To 38
       Next.Field=30
    End Select
 Case 81, 118
    Select Case Selection
    Case 1 To 9
       Next.Field=10
    Case 11 To 19
       Next.Field=20
    Case 21 To 28
       Next.Field=29
    Case 30 To 37
       Next.Field=38
    End Select
 End Select
 Call ShowField
Error.Resume65:
 Exit Sub
Error.Trap65:
 Resume Error.Resume65
End Sub
