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

Sub EditAction
 On Local Error Goto Error.Trap198
 Room.Action=1!
 If Lof(ActionFile)=SFalse Then
    Call AddAction
 Endif
 Out3="Sysop Action Edit"
 Call DisplayEditScreen(6,29,Out3)
 Call ActionStatusLine
 Call DisplayAction
 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(29)
          If Len(TempX$) Then
             Exit Do
          Endif
       Endif
       If Mouse.Row Or Mouse.Column Then
          Call MouseSelect(29)
       Endif
    Loop
    TempX=False
    Select Case Len(TempX$)
    Case 2
       TempX=Asc(Mid$(TempX$,2,1))
       If TempX=0 Then
          Call Write.Record(ActionFile,Room.Action)
          Exit Do
       Endif
       Call ActionSelect
    Case 1
       TempX=Asc(TempX$)
       Select Case TempX
       Case 1
          Call AddAction
       Case 8
          Call Help(6)
          Out3="Sysop Action Edit"
          Call DisplayEditScreen(6,29,Out3)
          Call ActionStatusLine
          Call DisplayAction
       Case 9
          Call ActionSelect
       Case 13
          Call ActionEdit
          Call Write.Record(ActionFile,Room.Action)
          Call ActionStatusLine
          TempX=Selection
          Call ShowAction
          Call RedisplayField
       Case 14
          Call NextAction
       Case 17
          Call PreviousAction
       Case 18
          Call SelectNextAction
          Call ActionStatusLine
       Case 27
          Call Write.Record(ActionFile,Room.Action)
          Exit Sub
       End Select
    End Select
 Loop
Error.Resume198:
 Exit Sub
Error.Trap198:
 Resume Error.Resume198
End Sub

Sub NextAction
 On Local Error Goto Error.Trap199
 If Room.Action>=Lof(ActionFile)/ActionRecLen Then
    Strng="This is the last action in the room file."
    Call ErrorMessage
 Else
    Call Write.Record(ActionFile,Room.Action)
    Room.Action=Room.Action+1!
    Call DisplayAction
 Endif
Error.Resume199:
 Exit Sub
Error.Trap199:
 Resume Error.Resume199
End Sub

Sub PreviousAction
 On Local Error Goto Error.Trap200
 If Room.Action>1! Then
    Call Write.Record(ActionFile,Room.Action)
    Room.Action=Room.Action-1!
    Call DisplayAction
    Exit Sub
 Endif
 Strng="This is the first action in the room file."
 Call ErrorMessage
Error.Resume200:
 Exit Sub
Error.Trap200:
 Resume Error.Resume200
End Sub

Sub SelectNextAction
 On Local Error Goto Error.Trap201
 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 Action: "
 Call Scrn(Strng)
 Call ANSI(4,37,40)
 Call ANSI(2,23,16)
 Strng=Space$(6)
 Call Scrn(Strng)
 Call ANSI(4,37,44)
 Call ANSI(2,23,25)
 Strng="(1-"+Mid$(Str$(Lof(ActionFile)/ActionRecLen),2)+")"
 Multiplier=Len(Strng)+25
 Strng=Strng+" (+/-/x)"
 Call Scrn(Strng)
 Restore Data10
 Read Xcoor, Ycoor, Column, Line.Length, Row, Max.Lines, Line.Number
 Edit.Data(1)=Nul
 Call ScreenEdit
 Multiplier=False
 Temp2!=Val(Edit.Data(1))
 If Temp2<=SFalse Or Temp2!>Lof(ActionFile)/ActionRecLen Then
    Strng="The action number is not within the room file range."
    Call ErrorMessage
    Exit Sub
 Endif
 Call Write.Record(ActionFile,Room.Action)
 Room.Action=Temp2!
 Call DisplayAction
Error.Resume201:
 Exit Sub
Error.Trap201:
 Resume Error.Resume201
End Sub

Data10:
 Data 23,16,16,6,23,1,1

Sub ActionStatusLine
 On Local Error Goto Error.Trap202
 Strng="^ Cursor Select "+Chr$(60)+Chr$(217)
 Strng=Strng+" Enter Choice <esc> Exit and Save ^h Help ^a add record"
 Out2="^n Next Action ^q Previous Action ^r Select Action"
 Call StatusLine
Error.Resume202:
 Exit Sub
Error.Trap202:
 Resume Error.Resume202
End Sub

Sub DisplayAction
 On Local Error Goto Error.Trap197
 If Room.Action>SFalse And Room.Action<=Lof(ActionFile)/ActionRecLen Then
    Call Read.Record(ActionFile,Room.Action)
    For TempX=False To 29
       Call ShowAction
    Next
    Call RedisplayField
 Endif
Error.Resume197:
 Exit Sub
Error.Trap197:
 Resume Error.Resume197
End Sub

Sub AddAction
 On Local Error Goto Error.Trap117
 Room.Action=Lof(ActionFile)/ActionRecLen+1!
 ActionRecord.Attribute1=False
 ActionRecord.Attribute2=False
 ActionRecord.EncounterRate=False
 ActionRecord.Fumble=False
 ActionRecord.HealthRate=False
 ActionRecord.HitPoints=False
 ActionRecord.Inventory=False
 ActionRecord.InvPercent=False
 ActionRecord.InvNumber=False
 ActionRecord.Level=False
 ActionRecord.Restrictions=False
 ActionRecord.RustRate=False
 ActionRecord.SpellTrigger=SFalse
 ActionRecord.StealRate=False
 ActionRecord.Telepercent=False
 For Var2=1 To 3
    ActionRecord.AttackMonster(Var2)=SFalse
    ActionRecord.MonsterTalk(Var2)=SFalse
    ActionRecord.MonsterTrigger(Var2)=SFalse
 Next
 For Var2=1 To 5
    ActionRecord.Teleport(Var2)=SFalse
 Next
 ActionRecord.Hidden=False
 ActionRecord.ItemForSale=SFalse
 ActionRecord.WishPercent=False
 ActionRecord.PoisonPercent=False
 Call Write.Record(ActionFile,Room.Action)
 Call DisplayAction
 UserRecord.ObjectsCreated(1)=UserRecord.ObjectsCreated(1)+1#
 If User.Index Then
    Call Write.Record(UserFile,User.Index)
 Endif
Error.Resume117:
 Exit Sub
Error.Trap117:
 Resume Error.Resume117
End Sub

Sub ShowAction
 On Local Error Goto Error.Trap33
 Select Case TempX
 Case 0
    Call ANSI(4,37,44)
    Call ANSI(2,3,2)
    Strng="Triggers"
    Call Scrn(Strng)
    Call ANSI(2,3,50)
    Strng="Results"
    Call Scrn(Strng)
    Call ANSI(2,2,16)
    Strng=Space$(8)
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,2,2)
    Strng="Action Number "+Mid$(Str$(Room.Action),2)
    Call Scrn(Strng)
    Call ANSI(2,7,2)
    Strng="and/or"
    Call Scrn(Strng)
    Call ANSI(4,37,44)
    Call ANSI(2,10,67)
    Strng="(1-10)"
    Call Scrn(Strng)
    Call ANSI(4,33,44)
    Call ANSI(2,13,50)
    Strng="Fatigue/Vitality"
    Call Scrn(Strng)
    Call ANSI(4,37,44)
    Call ANSI(2,17,2)
    Strng="Direction Restriction"
    Call Scrn(Strng)
    Call ANSI(2,20,2)
    Strng="All results are from entering a room unless indicated by a trigger."
    Call Scrn(Strng)
 Case Else
    Call ANSI(4,37,40)
    Select Case TempX
    Case 1
       Call ANSI(2,4,17)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,4,17)
       Strng=Mid$(Str$(ActionRecord.MonsterTrigger(1)),2)
       Call Scrn(Strng)
    Case 2
       Call ANSI(2,6,18)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,6,18)
       Strng=Mid$(Str$(ActionRecord.MonsterTalk(1)),2)
       Call Scrn(Strng)
    Case 3
       Call ANSI(2,8,14)
       Strng=Space$(8)
       Call Scrn(Strng)
       Call ANSI(2,8,14)
       Strng=Mid$(Str$(ActionRecord.Teleport(1)),2)
       Call Scrn(Strng)
    Case 4
       Call ANSI(2,11,2)
       If ActionRecord.SpellTrigger<=SFalse Or _
       ActionRecord.SpellTrigger>Lof(SpellFile)/SpellRecLen Then
          Strng="<none>"
          Call Scrn(Strng)
          Strng=Space$(24)
          Call Scrn(Strng)
       Else
          Call Read.Record(SpellFile,ActionRecord.SpellTrigger)
          Strng=Left$(SpellRecord.SpellName,30)
          Call Scrn(Strng)
       Endif
    Case 5
       Call ANSI(2,13,14)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,13,14)
       Strng=Mid$(Str$(Abs(ActionRecord.Level)),2)
       Call Scrn(Strng)
    Case 6
       Call ANSI(2,15,16)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,15,16)
       Strng="n/a"
       If ActionRecord.Level<False Then
          Strng="min"
       Endif
       If ActionRecord.Level>False Then
          Strng="max"
       Endif
       Call Scrn(Strng)
    Case 7
       Call ANSI(2,18,4)
       If ActionRecord.Restrictions And 2 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 8
       Call ANSI(2,18,9)
       If ActionRecord.Restrictions And 4 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 9
       Call ANSI(2,18,14)
       If ActionRecord.Restrictions And 8 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 10
       Call ANSI(2,18,19)
       If ActionRecord.Restrictions And 16 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 11
       Call ANSI(2,18,25)
       If ActionRecord.Restrictions And 32 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 12
       Call ANSI(2,18,31)
       If ActionRecord.Restrictions And 64 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 13
       Call ANSI(2,18,37)
       If ActionRecord.Restrictions And 128 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 14
       Call ANSI(2,18,43)
       If ActionRecord.Restrictions And 256 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 15
       Call ANSI(2,18,49)
       If ActionRecord.Restrictions And 512 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 16
       Call ANSI(2,18,57)
       If ActionRecord.Restrictions And 1024 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 17
       Call ANSI(2,18,63)
       If ActionRecord.Restrictions And 2048 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 18
       Call ANSI(2,18,70)
       If ActionRecord.Restrictions And 4096 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 19
       Call ANSI(2,18,76)
       If ActionRecord.Restrictions And 8192 Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 20
       Call ANSI(2,4,62)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,4,62)
       Strng=Mid$(Str$(ActionRecord.HealthRate),2)
       Call Scrn(Strng)
    Case 21
       Call ANSI(2,6,65)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,6,65)
       Strng=Mid$(Str$(ActionRecord.EncounterRate),2)
       Call Scrn(Strng)
    Case 22
       Call ANSI(2,8,57)
       If ActionRecord.Fumble Then
          Call Scrn("Y")
       Else
          Call Scrn("N")
       Endif
    Case 23
       Call ANSI(2,10,74)
       Strng="  "
       Call Scrn(Strng)
       Call ANSI(2,10,74)
       Strng="?"
       Select Case ActionRecord.Inventory
       Case 1 To 10
          Strng=Mid$(Str$(ActionRecord.Inventory),2)
       End Select
       Call Scrn(Strng)
    Case 24
       Call ANSI(2,12,64)
       Select Case ActionRecord.HitPoints
       Case Is<False
          Strng="V"
       Case Is>False
          Strng="F"
       Case False
          Strng="?"
       End Select
       Call Scrn(Strng)
    Case 25
       Call ANSI(2,13,67)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,13,67)
       Strng=Mid$(Str$(Abs(ActionRecord.HitPoints)),2)
       Call Scrn(Strng)
    Case 26
       Call ANSI(2,15,60)
       Strng=Space$(4)
       Call Scrn(Strng)
       Call ANSI(2,15,60)
       Strng=Mid$(Str$(ActionRecord.RustRate),2,4)
       Call Scrn(Strng)
    Case 27
       Call ANSI(2,15,76)
       Strng=Space$(4)
       Call Scrn(Strng)
       Call ANSI(2,15,76)
       Strng=Mid$(Str$(ActionRecord.StealRate),2,4)
       Call Scrn(Strng)
    Case 28
       Call ANSI(2,16,68)
       Strng=Space$(3)
       Call Scrn(Strng)
       Call ANSI(2,16,68)
       Strng=Mid$(Str$(ActionRecord.InvPercent),2,3)
       Call Scrn(Strng)
    Case 29
       Call ANSI(2,17,61)
       Strng=Space$(5)
       Call Scrn(Strng)
       Call ANSI(2,17,61)
       Strng=Mid$(Str$(ActionRecord.InvNumber),2,5)
       Call Scrn(Strng)
    End Select
 End Select
Error.Resume33:
 Exit Sub
Error.Trap33:
 Resume Error.Resume33
End Sub

Sub ActionEdit
 On Local Error Goto Error.Trap41
 Static Hits.Temp
 Restore ActionEditData
 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)=Mid$(Str$(ActionRecord.MonsterTrigger(1)),2)
 Case 2
    Edit.Data(1)=Mid$(Str$(ActionRecord.MonsterTalk(1)),2)
 Case 3
    Edit.Data(1)=Mid$(Str$(ActionRecord.Teleport(1)),2)
 Case 4
    If ActionRecord.SpellTrigger>SFalse And _
    ActionRecord.SpellTrigger<=Lof(SpellFile)/SpellRecLen Then
       Call Read.Record(SpellFile,ActionRecord.SpellTrigger)
       Edit.Data(1)=Left$(SpellRecord.SpellName,30)
    Else
       Call ANSI(4,37,40)
       Call ANSI(2,11,2)
       Strng=Space$(30)
       Call Scrn(Strng)
       Edit.Data(1)=Space$(30)
    Endif
 Case 5
    VarA=False
    If ActionRecord.Level<False Then
       VarA=True
    Endif
    Edit.Data(1)=Mid$(Str$(Abs(ActionRecord.Level)),2)
 Case 6
    If ActionRecord.Level<False Then
       Edit.Data(1)="min"
    Else
       If ActionRecord.Level>False Then
          Edit.Data(1)="max"
       Else
          Edit.Data(1)="n/a"
       Endif
    Endif
 Case 7 To 19
    If ActionRecord.Restrictions And 2^(Selection-6) Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 20
    Edit.Data(1)=Mid$(Str$(ActionRecord.HealthRate),2)
 Case 21
    Edit.Data(1)=Mid$(Str$(ActionRecord.EncounterRate),2)
 Case 22
    If ActionRecord.Fumble Then
       Edit.Data(1)="Y"
    Else
       Edit.Data(1)="N"
    Endif
 Case 23
    Call MakeBox(3,35,14,47)
    Call ANSI(4,37,40)
    For V=1 To 10
       Strng=Mid$(Str$(V),1)+"="
       Strng=Strng+InventoryNames(V)
       Strng=Left$(Strng,11)
       Strng=Strng+Space$(11-Len(Strng))
       Call ANSI(2,V+3,36)
       Call Scrn(Strng)
    Next
    Select Case ActionRecord.Inventory
    Case 1 To 10
       Edit.Data(1)=Mid$(Str$(ActionRecord.Inventory),2)
    Case Else
       Edit.Data(1)="?"
    End Select
 Case 24
    Edit.Data(1)="?"
    If ActionRecord.HitPoints>False Then
       Edit.Data(1)="F"
    Endif
    If ActionRecord.HitPoints<False Then
       Edit.Data(1)="V"
    Endif
 Case 25
    Edit.Data(1)=Mid$(Str$(Abs(ActionRecord.HitPoints)),2)
 Case 26
    Edit.Data(1)=Mid$(Str$(ActionRecord.RustRate),2,4)
 Case 27
    Edit.Data(1)=Mid$(Str$(ActionRecord.StealRate),2,4)
 Case 28
    Edit.Data(1)=Mid$(Str$(ActionRecord.InvPercent),2)
 Case 29
    Edit.Data(1)=Mid$(Str$(ActionRecord.InvNumber),2)
 End Select
 Strng="^ Cursor Edit   "
 Out2=Chr$(60)+Chr$(217)+" Exit Field"
 Call StatusLine
 Call ScreenEdit
 Edit.Data(1)=Rtrim$(Edit.Data(1))
 Edit.Data(1)=Lcase$(Edit.Data(1))
 Select Case Selection
 Case 1
    ActionRecord.MonsterTrigger(1)=Int(Val(Edit.Data(1)))
 Case 2
    ActionRecord.MonsterTalk(1)=Int(Val(Edit.Data(1)))
 Case 3
    ActionRecord.Teleport(1)=Int(Val(Edit.Data(1)))
 Case 4
    If Edit.Data(1)<>Nul Then
       For Temp2!=1! To Lof(SpellFile)/SpellRecLen
          Call Read.Record(SpellFile,Temp2!)
          If Left$(SpellRecord.SpellName,Len(Edit.Data(1)))=Edit.Data(1) Then
             ActionRecord.SpellTrigger=Temp2!
             Exit Sub
          Endif
       Next
       Strng="The spell was not found in the spell file."
       Call ErrorMessage
       Call ANSI(2,21,2)
       Strng=Space$(60)
       Call Scrn(Strng)
    Endif
    ActionRecord.SpellTrigger=SFalse
 Case 5
    ActionRecord.Level=Int(Val(Edit.Data(1)))
    If VarA Then
       ActionRecord.Level=-Abs(ActionRecord.Level)
    Endif
    TempX=6
    Call ShowAction
 Case 6
    If Edit.Data(1)="min" Then
       ActionRecord.Level=-Abs(ActionRecord.Level)
    Else
       If Edit.Data(1)="max" Then
          ActionRecord.Level=Abs(ActionRecord.Level)
       Else
          ActionRecord.Level=False
       Endif
    Endif
    TempX=5
    Call ShowAction
 Case 7 To 19
    If Ucase$(Edit.Data(1))="Y" Then
       ActionRecord.Restrictions=ActionRecord.Restrictions Or 2^(Selection-6)
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       ActionRecord.Restrictions=ActionRecord.Restrictions And Not 2^(Selection-6)
    Endif
 Case 20
    ActionRecord.HealthRate=Int(Val(Edit.Data(1)))
 Case 21
    ActionRecord.EncounterRate=Int(Val(Edit.Data(1)))
 Case 22
    If Ucase$(Edit.Data(1))="Y" Then
       ActionRecord.Fumble=True
    Endif
    If Ucase$(Edit.Data(1))="N" Then
       ActionRecord.Fumble=False
    Endif
 Case 23
    Call ANSI(4,37,44)
    For TempX=3 To 14
       Call ANSI(2,TempX,35)
       Strng=Space$(13)
       Call Scrn(Strng)
    Next
    Select Case Int(Val(Edit.Data(1)))
    Case 1 To 10
       ActionRecord.Inventory=Int(Val(Edit.Data(1)))
    Case Else
       ActionRecord.Inventory=False
    End Select
 Case 24
    Select Case Ucase$(Edit.Data(1))
    Case "F"
       Hits.Temp=1
       TempZ=Abs(ActionRecord.HitPoints)
       ActionRecord.HitPoints=1
       TempX=24
       Call ShowAction
       ActionRecord.HitPoints=TempZ
       Next.Field=25
       Call ShowField
       Call ActionEdit
       Exit Sub
    Case "V"
       Hits.Temp=True
       TempZ=-Abs(ActionRecord.HitPoints)
       ActionRecord.HitPoints=True
       TempX=24
       Call ShowAction
       ActionRecord.HitPoints=TempZ
       Next.Field=25
       Call ShowField
       Call ActionEdit
       Exit Sub
    Case Else
       Hits.Temp=False
       ActionRecord.HitPoints=False
       TempX=24
       Call ShowAction
       TempX=25
       Call ShowAction
    End Select
 Case 25
    If Hits.Temp=False Then
       Hits.Temp=1
    Endif
    ActionRecord.HitPoints=Val(Edit.Data(1))*Hits.Temp
    TempX=25
    Call ShowAction
    Next.Field=24
    Call ShowField
 Case 26
    ActionRecord.RustRate=Int(Val(Edit.Data(1)))
 Case 27
    ActionRecord.StealRate=Int(Val(Edit.Data(1)))
 Case 28
    VarX=Int(Val(Edit.Data(1)))
    If VarX>=False And VarX<=100 Then
       ActionRecord.InvPercent=Int(Val(Edit.Data(1)))
    Endif
 Case 29
    ActionRecord.InvNumber=Int(Val(Edit.Data(1)))
 End Select
Error.Resume41:
 Exit Sub
Error.Trap41:
 Resume Error.Resume41
End Sub

ActionEditData:
 Data 4,17,17,8,1,4,1
 Data 6,18,18,8,1,6,1
 Data 8,14,14,8,1,8,1
 Data 11,2,2,30,1,11,1
 Data 13,14,14,5,1,13,1
 Data 15,16,16,3,1,15,1
 Data 18,4,4,1,1,18,1
 Data 18,9,9,1,1,18,1
 Data 18,14,14,1,1,18,1
 Data 18,19,19,1,1,18,1
 Data 18,25,25,1,1,18,1
 Data 18,31,31,1,1,18,1
 Data 18,37,37,1,1,18,1
 Data 18,43,43,1,1,18,1
 Data 18,49,49,1,1,18,1
 Data 18,57,57,1,1,18,1
 Data 18,63,63,1,1,18,1
 Data 18,70,70,1,1,18,1
 Data 18,76,76,1,1,18,1
 Data 4,62,62,5,1,4,1
 Data 6,65,65,5,1,6,1
 Data 8,57,57,1,1,8,1
 Data 10,74,74,2,1,10,1
 Data 12,64,64,1,1,12,1
 Data 13,67,67,5,1,13,1
 Data 15,60,60,4,1,15,1
 Data 15,76,76,4,1,15,1
 Data 16,68,68,3,1,16,1
 Data 17,61,61,5,1,17,1

Sub ActionSelect
 On Local Error Goto Error.Trap70
 Next.Field=False
 If TempX$=Chr$(9) Then
    TempX=77
 Endif
 Select Case TempX
 Case 77, 157, 116
    Select Case Selection
    Case 1 To 5
       Next.Field=Selection+19
    Case 6
       Next.Field=26
    Case 7 To 18
       Next.Field=Selection+1
    Case 26
       Next.Field=27
    End Select
 Case 15, 75, 155, 115
    Select Case Selection
    Case 8 To 19
       Next.Field=Selection-1
    Case 20 To 23
       Next.Field=Selection-19
    Case 24, 25
       Next.Field=5
    Case 26
       Next.Field=6
    Case 27
       Next.Field=26
    End Select
 Case 72, 141, 152
    Select Case Selection
    Case 2 To 18, 21 To 26, 28, 29
       Next.Field=Selection-1
    Case 19
       Next.Field=29
    Case 27
       Next.Field=25
    End Select
 Case 80, 145, 160
    Select Case Selection
    Case 1 To 18, 20 To 25, 28
       Next.Field=Selection+1
    Case 26, 27
       Next.Field=28
    Case 29
       Next.Field=19
    End Select
 Case 71, 119
    If Selection<>1 Then
       Next.Field=1
    Endif
 Case 79, 117
    If Selection<>19 Then
       Next.Field=19
    Endif
 Case 73, 132
    Select Case Selection
    Case 2 To 7
       Next.Field=1
    Case 8 To 18
       Next.Field=7
    Case 19, 21 To 29
       Next.Field=20
    End Select
 Case 81, 118
    Select Case Selection
    Case 1 To 6
       Next.Field=7
    Case 7 To 18, 20 To 29
       Next.Field=19
    End Select
 End Select
 Call ShowField
Error.Resume70:
 Exit Sub
Error.Trap70:
 Resume Error.Resume70
End Sub
