 Rem File: Cmd126.bas
 Rem Sub: Teams
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained=0 Then ' command line mode
    Call Get.Node
    Call Open.Arrays
    Call Get.Config
    Call Increase.Files
    Call Make.FileNames
    Call Reset.Cursor
    Call Detect.Share
    Call Open.Files
    Call Read.Options
    Call Valid.Node
    Call Save.Screen2(0)
    Color 14,0
    Print "DNDBBS CMD126 - Teams"
    Var$=Nul
    If Command$<>Nul Then
       Var$=Command$
    Endif
    Call Alt.Login(Var,Var$)
    If Var=False Then
       If Lost.Carrier=False Then
          Color 14,0
          Print "Codename not found."
       Endif
       Call More.Prompt
       Goto Main.Resume
    Endif
    Call Search.Mess.File(User.Index,Var1)
    If Var1 Then
       Color 14,0
       Print "Codename is in use."
       Call More.Prompt
       Goto Main.Resume
    Endif
    Call Get.User.Stats(Var)
    Timeon=Timeit!
    Time.Left=3600!
 Endif
 Call Teams
Main.Resume:
 If Chained=-2 Then
    Chain DND.Path+"DNDBBS.EXE"
 Endif
 Call Clear.Status.Line
 Call ScreenANSI(1,37,7)
 Color 7, 0
 Cls
 Call Save.Screen2(-1)
' Locate Max.Row,1,1
 If TempX=0 Then TempX=1
 Locate TempX,1,1
 Color 15,0
 Print
 Print "Now exiting Team Menu.."
 Color 7,0
 Call Decrease.Files
 End
Main.Error:
 Resume Main.Resume

Sub Teams
 On Local Error Goto Error.Trap59
 Gosub Get.Config
 If Chained=0 Then Option3=0
 If GuestLogin Then
    If GuestRecord.GuestAllowTeam=False Then
       Strng="Guests cannot use the team menu.."
       Call IO.O
       Exit Sub
    Endif
 Endif
 Do While Lost.Carrier=False
    Call Team.Status.Line
    Graphics.Off=False
    Strng="Team menu editor:"
    Call IO.O
    Graphics.Off=True
    If option1=false Then
       Strng="[*]reate team"
    Else
       Strng="[C]reate team"
    Endif
    Call IO.O
    If option2=false Then
       Strng="[*]eposit Gold"
    Else
       Strng="[D]eposit Gold"
    Endif
    Call IO.O
    If option3=false Then
       Strng="[*]nventory"
    Else
       Strng="[I]nventory"
    Endif
    Call IO.O
    If option4=false Then
       Strng="[*]oin team"
    Else
       Strng="[J]oin team"
    Endif
    Call IO.O
    If option5=false Then
       Strng="[*]ist teams"
    Else
       Strng="[L]ist teams"
    Endif
    Call IO.O
    If option6=false Then
       Strng="[*]ffline fights"
    Else
       Strng="[O]ffline fights"
    Endif
    Call IO.O
    If option7=false Then
       Strng="[*]refixed ANSI"
    Else
       Strng="[P]refixed ANSI"
    Endif
    Call IO.O
    If option8=false Then
       Strng="[*]esign from team"
    Else
       Strng="[R]esign from team"
    Endif
    Call IO.O
    If option9=false Then
       Strng="[*]how your team"
    Else
       Strng="[S]how your team"
    Endif
    Call IO.O
    If option10=false Then
       Strng="[*]op team list"
    Else
       Strng="[T]op team list"
    Endif
    Call IO.O
    If option11=false Then
       Strng="[*]ithdraw Gold"
    Else
       Strng="[W]ithdraw Gold"
    Endif
    Call IO.O
    Graphics.Off=False
    No.Input.Out="Q"
    Graphics.Off=False
    Strng="Enter team menu command: "
    Call IO.I
    Select Case Ucase$(Out2)
    Case "C"
       If option1 Then
          Call Create.Team
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "D"
       If option2 Then
          Call Add.Team.Gold
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "I"
       If option3 Then
          Call Team.Inventory
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "J"
       If option4 Then
          Call Join.Team
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "L"
       If option5 Then
          Call List.Teams
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "O"
       If option6 Then
          Call Offline.Fights
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "P"
       If option7 Then
          Call Change.Prefix
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "R"
       If option8 Then
          Call Resign.Team
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "S"
       If option9 Then
          Call Show.Team
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "T"
       If option10 Then
          Call Top.Ten.Teams
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "W"
       If option11 Then
          Call Take.Team.Gold
       Else
          Strng="Option disabled."
          Call IO.O
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Exit Sub
Get.Config:
 VarX=0
 Gosub Reset.Options
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD126]" Then
       Do
          VarX=VarX+1
          If VarX>Options.Lines Then
             Goto Next.Read
             Return
          Endif
          Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
          If Ucase$(Var$)="[END]" Then
             Goto Next.Read
             Return
          Endif
          Var=Instr(Var$,"=")
          If Var Then
             Var2$=Lcase$(Ltrim$(Rtrim$(Left$(Var$,Var-1))))
             Var3$=Lcase$(Ltrim$(Rtrim$(Mid$(Var$,Var+1))))
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD126.CFG"
 If Dir$(Filename$)="" Then
    Return
 Endif
 Open Filename$ For Input As #TempFile1
 Do
    If Eof(TempFile1) Then
       Exit Do
    Endif
    Line Input #TempFile1, Var$
    Var$=Ltrim$(Rtrim$(Var$))
    If Left$(Var$,1)<>";" Then
       VarX$=UserRecord.CodeName
       VarX$=Rtrim$(VarX$)
       VarX$=Ucase$(VarX$)
       If Ucase$(Var$)="["+VarX$+"]" Then
          VarZ=0
          Gosub Reset.Options
          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             If Ucase$(Var$)="[END]" Then
                If Chained=0 Then Option3=0
                Return
             Endif
             Var=Instr(Var$,"=")
             If Var Then
                Var2$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
                Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
                Gosub Parse.Options
             Endif
          Loop
       Endif
   Endif
 Loop
 If Chained=0 Then Option3=0
 Return
Reset.Options:
 Option1=-1: Option2=-1: Option3=-1: Option4=-1: Option5=-1
 Option6=-1: Option7=-1: Option8=-1: Option9=-1: Option10=-1: Option11=-1
 Return
Parse.Options:
 Select Case Var2$
 Case "create.team"
    Select Case Var3$
    Case "0", "false", "off"
       Option1=False
    End Select
 Case "deposit.Gold"
    Select Case Var3$
    Case "0", "false", "off"
       Option2=False
    End Select
 Case "inventory"
    Select Case Var3$
    Case "0", "false", "off"
       Option3=False
    End Select
 Case "join.team"
    Select Case Var3$
    Case "0", "false", "off"
       Option4=False
    End Select
 Case "list.teams"
    Select Case Var3$
    Case "0", "false", "off"
       Option5=False
    End Select
 Case "offline.fights"
    Select Case Var3$
    Case "0", "false", "off"
       Option6=False
    End Select
 Case "prefixed.ANSI"
    Select Case Var3$
    Case "0", "false", "off"
       Option7=False
    End Select
 Case "resign.from.team"
    Select Case Var3$
    Case "0", "false", "off"
       Option8=False
    End Select
 Case "show.your.team"
    Select Case Var3$
    Case "0", "false", "off"
       Option9=False
    End Select
 Case "top.team.list"
    Select Case Var3$
    Case "0", "false", "off"
       Option10=False
    End Select
 Case "withdraw.Gold"
    Select Case Var3$
    Case "0", "false", "off"
       Option11=False
    End Select
 End Select
 Return
Error.Resume59:
 Exit Sub
Error.Trap59:
 Resume Error.Resume59
End Sub

Sub Team.Status.Line
 On Local Error Goto Error.Trap60
 Temp$=UserRecord.CodeName
 Temp$=Rtrim$(Temp$)
 Temp$=Lcase$(Temp$)
 Mid$(Temp$,1,1)=Ucase$(Mid$(Temp$,1,1))
 Temp$=Temp$+" > "
 Temp$=Temp$+"team menu: "+Fclock$
 Temp$=Left$(Temp$,79)
 Temp$=Temp$+Space$(79-Len(Temp$))
 Call Display.Status.Line(True)
Error.Resume60:
 Exit Sub
Error.Trap60:
 Resume Error.Resume60
End Sub

Sub Join.Team
 On Local Error Goto Error.Trap61
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          Strng="You already belong to a team."
          Call IO.O
          Exit Sub
       Endif
    Next
 Next
 Do While Lost.Carrier=False
    Call List.Teams
    Graphics.Off=False
    No.Input.Out="Q"
    Strng="Enter team number(Q to quit)?"
    Call IO.I
    If Ucase$(Out2)="Q" Then
       Exit Do
    Endif
    Var!=Int(Val(Out2)+.5)
    Select Case Var!
    Case 1! To Lof(TeamFile)/TeamRecLen
       Call Read.Record(TeamFile,Var!)
       For Var2=1 To MaxTeamMembers
          Temp2$=Rtrim$(TeamRecord.Member(Var2))
          If Temp2$=Nul Then
             Strng="Enter team password: "
             Hidden=True
             Call IO.I
             Hidden=False
             Temp3$=Ltrim$(Rtrim$(Out2))
             Temp3$=Ucase$(Temp3$)
             Call Cryptograph(Temp3$)
             If Temp3$<>Rtrim$(TeamRecord.Pass) Then
                Strng="Illegal password!"
                Call IO.O
                Exit For
             Endif
             TeamRecord.Member(Var2)=UserRecord.Codename
             TeamRecord.UserIndex(Var2)=User.Index
             TeamRecord.Activated(Var2)=True
             Call Write.Record(TeamFile,Var!)
             Strng="You join the team."
             Call IO.O
             Exit Do
          Endif
       Next
       Strng="You can't join that team."
       Call IO.O
    Case Else
       Strng="You can't join that team."
       Call IO.O
    End Select
 Loop
Error.Resume61:
 Exit Sub
Error.Trap61:
 Resume Error.Resume61
End Sub

Sub Resign.Team
 On Local Error Goto Error.Trap62
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          Strng="Resign from team(y/n)? "
          Call IO.I
          If Yes Then
             TeamRecord.Member(VarX)=Nul
             TeamRecord.UserIndex(VarX)=SFalse
             TeamRecord.Activated(VarX)=False
             Call Write.Record(TeamFile,Var!)
             Strng="You resigned from your team."
             Call IO.O
          Endif
          Exit Sub
       Endif
    Next
 Next
 Strng="You do not belong to a team."
 Call IO.O
Error.Resume62:
 Exit Sub
Error.Trap62:
 Resume Error.Resume62
End Sub

Sub Create.Team
 On Local Error Goto Error.Trap63
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          Strng="You already belong to a team."
          Call IO.O
          Exit Sub
       Endif
    Next
 Next
 Do While Lost.Carrier=False
    Graphics.Off=True
    Strng=Space$(16)+"+--->-----+---------+---------+"
    Call IO.O
    Strng="Enter team name: "
    Call IO.I
    Out2=Ltrim$(Rtrim$(Out2))
    If Len(Out2)>=4 And Len(Out2)<=30 Then
       Temp$=Ucase$(Out2)
       Exit Do
    Endif
 Loop
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    Out2=Rtrim$(TeamRecord.Name)
    Out2=Ucase$(Out2)
    If Out2=Temp$ Then
       Strng="Team name already exists."
       Call IO.O
       Exit Sub
    Endif
 Next
 Do While Lost.Carrier=False
    Graphics.Off=True
    Strng=Space$(20)+"+-->------+---------+"
    Call IO.O
    Hidden=True
    Strng="Enter team password: "
    Call IO.I
    Hidden=False
    Out2=Ltrim$(Rtrim$(Out2))
    If Len(Out2)>=3 And Len(Out2)<=20 Then
       Temp2$=Ucase$(Out2)
       Exit Do
    Endif
 Loop
 Do While Lost.Carrier=False
    Graphics.Off=True
    Strng=Space$(22)+"+-->------+---------+"
    Call IO.O
    Hidden=True
    Strng="Reenter team password: "
    Call IO.I
    Hidden=False
    Out3=Ltrim$(Rtrim$(Out2))
    If Len(Out3)>=3 And Len(Out3)<=20 Then
       Out3=Ucase$(Out3)
       If Temp2$<>Out3 Then
          Strng="Passwords don't match!"
          Call IO.O
          Exit Sub
       Endif
       Exit Do
    Endif
 Loop
 If Lost.Carrier Then
    Exit Sub
 Endif
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    If Rtrim$(TeamRecord.Name)=Nul Then
       Exit For
    Endif
 Next
 Strng=Lcase$(Temp$)
 Call Capitalize(Strng)
 Strng="Create team "+Quote$+Strng+Quote$+"(y/n)?"
 Call IO.I
 If No Then
    Strng="Team not created."
    Call IO.O
    Exit Sub
 Endif
 Call Cryptograph(Temp2$)
 TeamRecord.Name=Temp$
 TeamRecord.Pass=Temp2$
 For Var2=1 To MaxTeamMembers
    TeamRecord.Member(Var2)=Nul
    TeamRecord.UserIndex(Var2)=SFalse
    TeamRecord.Activated(Var2)=True
 Next
 TeamRecord.Member(1)=UserRecord.CodeName
 TeamRecord.UserIndex(1)=User.Index
 TeamRecord.Gold=False
 TeamRecord.Deleted=False
 TeamRecord.Prefix1=Nul
 TeamRecord.First=SFalse
 TeamRecord.Last=SFalse
 TeamRecord.First2=SFalse
 TeamRecord.Last2=SFalse
 For Var2!=1! To Lof(TeamInvFile)/MessWorkRecLen6
    Call Read.Record(TeamInvFile,Var2!)
    If MessWorkRecord6.User=Var! Then
       MessWorkRecord6.Room=SFalse
       MessWorkRecord6.User=SFalse
       MessWorkRecord6.Index=SFalse
       MessWorkRecord6.Charges=False
       MessWorkRecord6.Plus=False
       MessWorkRecord6.Prev=SFalse
       MessWorkRecord6.Next=SFalse
       Call Write.Record(TeamInvFile,Var2!)
    Endif
 Next
 Call Write.Record(TeamFile,Var!)
 Graphics.Off=False
 Strng="Team "+Mid$(Str$(Var!),2)+" created."
 Call IO.O
Error.Resume63:
 Exit Sub
Error.Trap63:
 Resume Error.Resume63
End Sub

Sub Take.Team.Gold
 On Local Error Goto Error.Trap64
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          If TeamRecord.Gold=0# Then
             Strng="Your team has no gold!"
             Call IO.O
             Exit Sub
          Endif
          Call Amount5(TeamRecord.Gold,VarQ$)
          Strng="Your team has"+VarQ$+" Gold."
          Call IO.O
          Strng="Withdraw how much(1-"+Ltrim$(VarQ$)+",<all>)?"
          Call IO.I
          If Out2=Nul Then
             Exit Sub
          Endif
          If Lcase$(Out2)="all" Then
             Var#=TeamRecord.Gold
          Else
             Var#=Int(Val(Out2)+.5)
          Endif
          If Var#>False And Var#<=TeamRecord.Gold Then
             TeamRecord.Gold=TeamRecord.Gold-Var#
             Call Write.Record(TeamFile,Var!)
             UserRecord.Gold=UserRecord.Gold+Var#
             Call Write.Record(UserFile,User.Index)
             Call Amount5(Var#,VarQ$)
             Strng="You withdraw"+VarQ$+" Gold."
             Call IO.O
          Else
             Strng="You can't withdraw that much."
             Call IO.O
          Endif
          Exit Sub
       Endif
    Next
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume64:
 Exit Sub
Error.Trap64:
 Resume Error.Resume64
End Sub

Sub Add.Team.Gold
 On Local Error Goto Error.Trap65
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          If UserRecord.Gold=0# Then
             Strng="You have no gold!"
             Call IO.O
             Exit Sub
          Endif
          Call Amount5(UserRecord.Gold,VarQ$)
          Strng="You now have"+VarQ$+" Gold!"
          Call IO.O
          Strng="Deposit how much(1-"+Ltrim$(VarQ$)+",<all>)?"
          Call IO.I
          If Out2=Nul Then
             Exit Sub
          Endif
          If Lcase$(Out2)="all" Then
             Var#=UserRecord.Gold
          Else
             Var#=Int(Val(Out2)+.5)
          Endif
          If Var#>DFalse And Var#<=UserRecord.Gold Then
             UserRecord.Gold=UserRecord.Gold-Var#
             Call Write.Record(UserFile,User.Index)
             TeamRecord.Gold=TeamRecord.Gold+Var#
             Call Write.Record(TeamFile,Var!)
             Call Amount5(Var#,VarQ$)
             Strng="You deposit"+VarQ$+" Gold."
             Call IO.O
          Else
             Strng="You can't deposit that much."
             Call IO.O
          Endif
          Exit Sub
       Endif
    Next
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume65:
 Exit Sub
Error.Trap65:
 Resume Error.Resume65
End Sub

Sub Team.Inventory
 On Local Error Goto Error.Trap66
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          Call Edit.Team.Inventory(Var!,VarX)
          Exit Sub
       Endif
    Next
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume66:
 Exit Sub
Error.Trap66:
 Resume Error.Resume66
End Sub

Sub Edit.Team.Inventory(Var!,VarX)
 On Local Error Goto Error.Trap66z
 Do While Lost.Carrier=False
    Graphics.Off=True
    VarZ1!=SFalse
    VarZ2!=SFalse
    Var2!=TeamRecord.First
    If Var2! Then
       Do While Lost.Carrier=False
          Call Read.Record(TeamInvFile,Var2!)
          Var3!=MessWorkRecord6.Next
          Temp5!=MessWorkRecord6.Index
          If Temp5!<SFalse Then
             VarZ1!=VarZ1!+1!
          Else
             VarZ2!=VarZ2!+1!
          Endif
          If Var3!=SFalse Then
             Exit Do
          Endif
          Var2!=Var3!
       Loop
    Endif
    Strng="[T]reasure ("+Mid$(Str$(VarZ2!),2)+")"
    Call IO.O
    Strng="[O]bjects ("+Mid$(Str$(VarZ1!),2)+")"
    Call IO.O
    VarZ!=SFalse
    Var4!=TeamRecord.First2
    If Var4! Then
       Do While Lost.Carrier=False
          Call Read.Record(ContainerFile,Var4!)
          Var6!=ContainerRecord.Next
          If ContainerRecord.WithinContainer=SFalse Then
             If ContainerRecord.DeletedContainer=False Then
                VarZ!=VarZ!+1!
             Endif
          Endif
          If Var6!=SFalse Then
             Exit Do
          Endif
          Var4!=Var6!
       Loop
    Endif
    Strng="[C]ontainers ("+Mid$(Str$(VarZ!),2)+")"
    Call IO.O
    Graphics.Off=False
    Strng="Inventory edit option(q to quit)? "
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "T"
       Do While Lost.Carrier=False
          Graphics.Off=True
          Strng="[A]dd treasure to team"
          Call IO.O
          Strng="[G]et treasure from team"
          Call IO.O
          Strng="[L]ist team treasure"
          Call IO.O
          Graphics.Off=False
          Strng="Inventory treasure edit option(q to quit)? "
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             Call Add.Team.Treasure(Var!,VarX)
          Case "G"
             Call Get.Team.Treasure(Var!,VarX)
          Case "L"
             Call List.Team.Treasure
          Case "Q"
             Exit Do
          End Select
       Loop
    Case "O"
       Do While Lost.Carrier=False
          Graphics.Off=True
          Strng="[A]dd object to team"
          Call IO.O
          Strng="[G]et object from team"
          Call IO.O
          Strng="[L]ist team objects"
          Call IO.O
          Graphics.Off=False
          Strng="Inventory object edit option(q to quit)? "
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             Call Add.Team.Object(Var!,VarX)
          Case "G"
             Call Get.Team.Object(Var!,VarX)
          Case "L"
             Call List.Team.Objects
          Case "Q"
             Exit Do
          End Select
       Loop
    Case "C"
       Do While Lost.Carrier=False
          Graphics.Off=True
          Strng="[A]dd container to team"
          Call IO.O
          Strng="[G]et container from team"
          Call IO.O
          Strng="[L]ist team containers"
          Call IO.O
          Graphics.Off=False
          Strng="Inventory container edit option(q to quit)? "
          No.Input.Out="Q"
          Call IO.I
          Select Case Ucase$(Out2)
          Case "A"
             Call Add.Team.Container(Var!,VarX)
          Case "G"
             Call Get.Team.Container(Var!,VarX)
          Case "L"
             Call List.Team.Containers
          Case "Q"
             Exit Do
          End Select
       Loop
    Case "Q"
       Exit Do
    End Select
 Loop
Error.Resume66z:
 Exit Sub
Error.Trap66z:
 Resume Error.Resume66z
End Sub

Sub Add.Team.Treasure(Var!,VarX)
 On Local Error Goto Error.Trap67c
 Graphics.Off=False
 Strng="User treasure inventory number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 If Chained Then
    For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
       Call Read.Record(MessWorkFile6,Temp5!)
       If MessWorkRecord6.User=User.Index Then
          Out3=Nul
          Temp6!=MessWorkRecord6.Index
          If Temp6!>SFalse And Temp6!<=Lof(TreasureFile)/TreasureRecLen Then
             Call Read.Record(TreasureFile,Temp6!)
             Out3=Lcase$(Rtrim$(TreasureRecord.TreasureName))
             If Len(Out3) Then
                Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             Endif
             TempX!=TempX!+1!
             Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
             Call IO.O
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=False
                Call More.Prompt
                If No Or Quit Then
                   Exit For
                Endif
             Endif
          Endif
       Endif
    Next
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="You have no treasure.."
    Call IO.O
    EXit Sub
 Endif
 Graphics.Off=False
 Strng="Enter inventory treasure number to add(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 If Chained Then
    If Temp!>SFalse And Temp!<=Lof(MessWorkFile6)/MessWorkRecLen6 Then
       Temp7!=SFalse
       TempX=False
       For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
          Call Read.Record(MessWorkFile6,Temp5!)
          If MessWorkRecord6.User=User.Index Then
             Temp6!=MessWorkRecord6.Index
             If Temp6!>SFalse And Temp6!<=Lof(TreasureFile)/TreasureRecLen Then
                Temp7!=Temp7!+1!
                If Temp!=Temp7! Then
                   Temp7=MessWorkRecord6.Charges
                   TempX=True
                   Exit For
                Endif
             Endif
          Endif
       Next
       If TempX Then
          Call Read.Record(TreasureFile,Temp6!)
          Out3=Lcase$(Rtrim$(TreasureRecord.TreasureName))
          Temp8=False
          If TreasureRecord.Plus Then
             Temp8=TreasureRecord.Plus
          Endif
          ' add to team
          Var2!=Lof(TeamInvFile)/MessWorkRecLen6+1!
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.User=Var!
          MessWorkRecord6.Index=Temp6!
          MessWorkRecord6.Charges=Temp7
          MessWorkRecord6.Plus=Temp8
          Call Add.List.Node4(Var!,Var2!)
          ' remove from player
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.User=SFalse
          MessWorkRecord6.Index=SFalse
          MessWorkRecord6.Charges=False
          MessWorkRecord6.Plus=False
          MessWorkRecord6.Prev=SFalse
          MessWorkRecord6.Next=SFalse
          Call Write.Record(MessWorkFile6,Temp5!)
          Strng="You add "+Lcase$(Out3)+"."
          Call IO.O
          Exit Sub
       Endif
    Endif
 Endif
 Strng="You can't add that."
 Call IO.O
Error.Resume67c:
 Exit Sub
Error.Trap67c:
 Resume Error.Resume67c
End Sub

Sub Get.Team.Treasure(Var!,VarX)
 On Local Error Goto Error.Trap67d
 Graphics.Off=False
 Strng="Team treasure inventory number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Out3=Nul
       Temp5!=MessWorkRecord6.Index
       If Temp5!>SFalse And Temp5!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Temp5!)
          Out3=Rtrim$(TreasureRecord.TreasureName)
          Out3=Lcase$(Out3)
          Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
          TempX!=TempX!+1!
          Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
          Call IO.O
          VarZ=VarZ+1
          If VarZ>=User.Pagelength-2 Then
             VarZ=SFalse
             Call More.Prompt
             If No Or Quit Then
                Exit Do
             Endif
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no treasure.."
    Call IO.O
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Enter team inventory treasure number to get(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 If Temp!>SFalse And Temp!<=Lof(TeamInvFile)/MessWorkRecLen6 Then
    TempX=False
    Temp7!=SFalse
    Var2!=TeamRecord.First
    If Var2! Then
       Do While Lost.Carrier=False
          Call Read.Record(TeamInvFile,Var2!)
          Var3!=MessWorkRecord6.Next
          Temp6!=MessWorkRecord6.Index
          If Temp6!>SFalse Then
             Temp7!=Temp7!+1!
             If Temp!=Temp7! Then
                Temp7=MessWorkRecord6.Charges
                Temp8=MessWorkRecord6.Plus
                If Temp6!>SFalse And Temp6!<=Lof(TreasureFile)/TreasureRecLen Then
                   Call Read.Record(TreasureFile,Temp6!)
                   Out3=Lcase$(Rtrim$(TreasureRecord.TreasureName))
                   ' add to player
                   If Chained Then
                      Call Add.Inventory(Temp6!,Temp7)
                   Endif
                   ' remove from team
                   Call Delete.List.Node4(Var!,Var2!)
                   Call Clear.List.Node
                   Call Write.Record(TeamInvFile,Var2!)
                   Strng="You get "+Out3+"."
                   Call IO.O
                Endif
                Exit Sub
             Endif
          Endif
          If Var3!=SFalse Then
             Exit Do
          Endif
          Var2!=Var3!
       Loop
    Endif
 Endif
 Strng="You can't get that."
 Call IO.O
Error.Resume67d:
 Exit Sub
Error.Trap67d:
 Resume Error.Resume67d
End Sub

Sub List.Team.Treasure
 On Local Error Goto Error.Trap67x
 Graphics.Off=False
 Strng="Team treasure inventory number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Out3=Nul
       Temp5!=MessWorkRecord6.Index
       If Temp5!>SFalse And Temp5!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,Temp5!)
          Out3=Rtrim$(TreasureRecord.TreasureName)
          Out3=Lcase$(Out3)
          Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
          TempX!=TempX!+1!
          Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
          Call IO.O
          VarZ=VarZ+1
          If VarZ>=User.Pagelength-2 Then
             VarZ=SFalse
             Call More.Prompt
             If No Or Quit Then
                Exit Do
             Endif
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no treasure.."
    Call IO.O
    Exit Sub
 Endif
Error.Resume67x:
 Exit Sub
Error.Trap67x:
 Resume Error.Resume67x
End Sub

Sub Add.Team.Object(Var!,VarX)
 On Local Error Goto Error.Trap67a
 Graphics.Off=False
 Strng="User inventory object number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 If Chained Then
    For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
       Call Read.Record(MessWorkFile6,Temp5!)
       If MessWorkRecord6.User=User.Index Then
          Out3=Nul
          Temp6!=MessWorkRecord6.Index
          If Temp6!<SFalse Then
             Temp6!=Abs(Temp6!)
             If Temp6!>SFalse And Temp6!<=Lof(ObjectFile)/ObjectRecLen Then
                Call Read.Record(ObjectFile,Temp6!)
                Out3=Rtrim$(ObjectRecord.ObjectName)
             Endif
             Out3=Lcase$(Out3)
             If Len(Out3) Then
                Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             Endif
             TempX!=TempX!+1!
             Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
             Call IO.O
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=False
                Call More.Prompt
                If No Or Quit Then
                   Exit For
                Endif
             Endif
          Endif
       Endif
    Next
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="You have no objects.."
    Call IO.O
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Enter inventory object number to add(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 If Chained Then
    If Temp!>SFalse And Temp!<=Lof(MessWorkFile6)/MessWorkRecLen6 Then
       Temp7!=SFalse
       TempX=False
       For Temp5!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
          Call Read.Record(MessWorkFile6,Temp5!)
          If MessWorkRecord6.User=User.Index Then
             Temp6!=MessWorkRecord6.Index
             If Temp6!<SFalse Then
                TempZ!=Abs(Temp6!)
                If TempZ!>SFalse And TempZ!<=Lof(ObjectFile)/ObjectRecLen Then
                   Temp7!=Temp7!+1!
                   If Temp!=Temp7! Then
                      Temp7=MessWorkRecord6.Charges
                      TempX=True
                      Exit For
                   Endif
                Endif
             Endif
          Endif
       Next
       If TempX Then
          Temp8=False
          Call Read.Record(ObjectFile,TempZ!)
          Out3=Lcase$(Rtrim$(ObjectRecord.ObjectName))
          Out3=Lcase$(Out3)
          Var2!=Lof(TeamInvFile)/MessWorkRecLen6+1!
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.User=Var!
          MessWorkRecord6.Index=Temp6!
          MessWorkRecord6.Charges=Temp7
          MessWorkRecord6.Plus=Temp8
          Call Add.List.Node4(Var!,Var2!)
          MessWorkRecord6.Room=SFalse
          MessWorkRecord6.User=SFalse
          MessWorkRecord6.Index=SFalse
          MessWorkRecord6.Charges=False
          MessWorkRecord6.Plus=False
          MessWorkRecord6.Prev=SFalse
          MessWorkRecord6.Next=SFalse
          Call Write.Record(MessWorkFile6,Temp5!)
          Strng="You add "+Lcase$(Out3)+"."
          Call IO.O
          Exit Sub
       Endif
    Endif
 Endif
 Strng="You can't add that."
 Call IO.O
Error.Resume67a:
 Exit Sub
Error.Trap67a:
 Resume Error.Resume67a
End Sub

Sub Get.Team.Object(Var!,VarX)
 On Local Error Goto Error.Trap67b
 Graphics.Off=False
 Strng="Team object inventory number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Out3=Nul
       Temp5!=MessWorkRecord6.Index
       If Temp5!<SFalse Then
          Temp5!=Abs(Temp5!)
          If Temp5!>SFalse And Temp5!<=Lof(ObjectFile)/ObjectRecLen Then
             Call Read.Record(ObjectFile,Temp5!)
             Out3=Rtrim$(ObjectRecord.ObjectName)
             Out3=Lcase$(Out3)
             Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             TempX!=TempX!+1!
             Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
             Call IO.O
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=SFalse
                Call More.Prompt
                If No Or Quit Then
                   Exit Do
                Endif
             Endif
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no objects.."
    Call IO.O
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Enter team inventory object number to get(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 If Temp!>SFalse And Temp!<=Lof(TeamInvFile)/MessWorkRecLen6 Then
    TempX=False
    Temp7!=SFalse
    Var2!=TeamRecord.First
    If Var2! Then
       Do While Lost.Carrier=False
          Call Read.Record(TeamInvFile,Var2!)
          Var3!=MessWorkRecord6.Next
          Temp6!=MessWorkRecord6.Index
          If Temp6!<SFalse Then
             Temp7!=Temp7!+1!
             If Temp!=Temp7! Then
                Temp7=MessWorkRecord6.Charges
                Temp8=MessWorkRecord6.Plus
                Temp8!=Abs(Temp6!)
                If Temp8!>SFalse And Temp8!<=Lof(ObjectFile)/ObjectRecLen Then
                   Call Read.Record(ObjectFile,Temp8!)
                   Out3=Lcase$(Rtrim$(ObjectRecord.ObjectName))
                   ' add to player
                   If Chained Then
                      Call Add.Inventory(Temp6!,Temp7)
                   Endif
                   ' remove from team
                   Call Delete.List.Node4(Var!,Var2!)
                   Call Clear.List.Node
                   Call Write.Record(TeamInvFile,Var2!)
                   Strng="You get "+Out3+"."
                   Call IO.O
                Endif
                Exit Sub
             Endif
          Endif
          If Var3!=SFalse Then
             Exit Do
          Endif
          Var2!=Var3!
       Loop
    Endif
 Endif
 Strng="You can't get that."
 Call IO.O
Error.Resume67b:
 Exit Sub
Error.Trap67b:
 Resume Error.Resume67b
End Sub

Sub List.Team.Objects
 On Local Error Goto Error.Trap67y
 Graphics.Off=False
 Strng="Team object inventory number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 TempX!=SFalse
 Var2!=TeamRecord.First
 If Var2! Then
    Do While Lost.Carrier=False
       Call Read.Record(TeamInvFile,Var2!)
       Var3!=MessWorkRecord6.Next
       Out3=Nul
       Temp5!=MessWorkRecord6.Index
       If Temp5!<SFalse Then
          Temp5!=Abs(Temp5!)
          If Temp5!>SFalse And Temp5!<=Lof(ObjectFile)/ObjectRecLen Then
             Call Read.Record(ObjectFile,Temp5!)
             Out3=Rtrim$(ObjectRecord.ObjectName)
             Out3=Lcase$(Out3)
             Mid$(Out3,1,1)=Ucase$(Mid$(Out3,1,1))
             TempX!=TempX!+1!
             Strng="["+Mid$(Str$(TempX!),2)+"]"+Out3
             Call IO.O
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=SFalse
                Call More.Prompt
                If No Or Quit Then
                   Exit Do
                Endif
             Endif
          Endif
       Endif
       If Var3!=SFalse Then
          Exit Do
       Endif
       Var2!=Var3!
    Loop
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no objects.."
    Call IO.O
    Exit Sub
 Endif
Error.Resume67y:
 Exit Sub
Error.Trap67y:
 Resume Error.Resume67y
End Sub

Sub Add.Team.Container(Var!,VarX)
 On Local Error Goto Error.Trap67e
 Graphics.Off=False
 Strng="User inventory container number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 Allow.Break=True
 Break=False
 Continuous=False
 Var4!=UserRecord.First2
 TempX!=SFalse
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
             TempX!=TempX!+1!
             Strng=Mid$(Str$(TempX!),2)+"."+Out3
             If ContainerRecord.InvisibleContainer Then
                Strng=Strng+"[inv]"
             Endif
             If ContainerRecord.KeyNumber Then
                Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
             Endif
             Call IO.O
             If Break Then
                Exit Do
             Endif
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=False
                If Continuous=False Then
                   Call More.Prompt
                   If No Or Quit Then
                      Exit Do
                   Endif
                Endif
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var4!=Var6!
    Loop
 Endif
 Allow.Break=False
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="You have no containers.."
    Call IO.O
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Enter inventory container number to add(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 TempX=False
 Temp7!=SFalse
 Var4!=UserRecord.First2
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
             Temp7!=Temp7!+1!
             If Temp!=Temp7! Then
                TempA!=Var4!
                TempX=True
                Exit Do
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var4!=Var6!
    Loop
    If TempX Then
       ' move user container to team inventory..
       Call Delete.User.Container(TempA!)
       Call Read.Record(ContainerFile,TempA!)
       ContainerRecord.RoomNumber=SFalse
       ContainerRecord.UserNumber=Var!
       ContainerRecord.InvisibleContainer=False
       Call Add.Container.Team(Var!,TempA!)
       Strng="You add "+Lcase$(Out3)+"."
       Call IO.O
       Exit Sub
    Endif
 Endif
 Strng="You can't add that."
 Call IO.O
Error.Resume67e:
 Exit Sub
Error.Trap67e:
 Resume Error.Resume67e
End Sub

Sub Get.Team.Container(Var!,VarX)
 On Local Error Goto Error.Trap67f
 Graphics.Off=False
 Strng="Team inventory container number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 Allow.Break=True
 Break=False
 Continuous=False
 Var4!=TeamRecord.First2
 TempX!=SFalse
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
             TempX!=TempX!+1!
             Strng=Mid$(Str$(TempX!),2)+"."+Out3
             If ContainerRecord.InvisibleContainer Then
                Strng=Strng+"[inv]"
             Endif
             If ContainerRecord.KeyNumber Then
                Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
             Endif
             Call IO.O
             If Break Then
                Exit Do
             Endif
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=False
                If Continuous=False Then
                   Call More.Prompt
                   If No Or Quit Then
                      Exit Do
                   Endif
                Endif
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var4!=Var6!
    Loop
 Endif
 Allow.Break=False
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no containers.."
    Call IO.O
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Enter inventory container number to get(1-"+Mid$(Str$(TempX!),2)+")? "
 Call IO.I
 Temp!=Int(Val(Out2)+.5)
 TempX=False
 Temp7!=SFalse
 Var4!=TeamRecord.First2
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
             Temp7!=Temp7!+1!
             If Temp!=Temp7! Then
                TempA!=Var4!
                TempX=True
                Exit Do
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var4!=Var6!
    Loop
    If TempX Then
       ' move team container to user inventory..
       Call Delete.Team.Container(Var!,TempA!)
       Call Read.Record(ContainerFile,TempA!)
       ContainerRecord.RoomNumber=SFalse
       ContainerRecord.UserNumber=User.Index
       ContainerRecord.InvisibleContainer=False
       Call Add.User.Container(TempA!)
       Strng="You get "+Lcase$(Out3)+"."
       Call IO.O
       Exit Sub
    Endif
 Endif
 Strng="You can't get that."
 Call IO.O
Error.Resume67f:
 Exit Sub
Error.Trap67f:
 Resume Error.Resume67f
End Sub

Sub List.Team.Containers
 On Local Error Goto Error.Trap67z
 Graphics.Off=False
 Strng="Team inventory container number list:"
 Call IO.O
 Graphics.Off=True
 VarZ=False
 Allow.Break=True
 Break=False
 Continuous=False
 Var4!=TeamRecord.First2
 TempX!=SFalse
 If Var4! Then
    Do While Lost.Carrier=False
       Call Read.Record(ContainerFile,Var4!)
       Var6!=ContainerRecord.Next
       If ContainerRecord.WithinContainer=SFalse Then
          If ContainerRecord.DeletedContainer=False Then
             Out3=ContainerRecord.ContainerName
             Out3=Rtrim$(Out3)
             Out3=Lcase$(Out3)
             TempX!=TempX!+1!
             Strng=Mid$(Str$(TempX!),2)+"."+Out3
             If ContainerRecord.InvisibleContainer Then
                Strng=Strng+"[inv]"
             Endif
             If ContainerRecord.KeyNumber Then
                Strng=Strng+"(#"+Right$(Str$(ContainerRecord.KeyNumber+1000000!),6)+")"
             Endif
             Call IO.O
             If Break Then
                Exit Do
             Endif
             VarZ=VarZ+1
             If VarZ>=User.Pagelength-2 Then
                VarZ=False
                If Continuous=False Then
                   Call More.Prompt
                   If No Or Quit Then
                      Exit Do
                   Endif
                Endif
             Endif
          Endif
       Endif
       If Var6!=SFalse Then
          Exit Do
       Endif
       Var4!=Var6!
    Loop
 Endif
 Allow.Break=False
 If VarZ Then
    Call More.Prompt
 Endif
 If TempX!=SFalse Then
    Strng="The team has no containers.."
    Call IO.O
    Exit Sub
 Endif
Error.Resume67z:
 Exit Sub
Error.Trap67z:
 Resume Error.Resume67z
End Sub

Sub Change.Prefix
 On Local Error Goto Error.Trap64a
 Graphics.Off=True
 If ANSIPrefixChar=Nul Then
    Strng="ANSI prefix codes not enabled."
    Call IO.O
    Exit Sub
 Endif
 Out2=TeamRecord.Prefix1
 Out2=Rtrim$(Out2)
 Strng="Current ANSI prefix: "
 If Len(Out2) Then
    Strng=Strng+Out2
 Else
    Strng=Strng+"<none>"
 Endif
 Call IO.O
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    For VarX=1 To MaxTeamMembers
       Temp$=Rtrim$(TeamRecord.Member(VarX))
       If Temp$=Rtrim$(UserRecord.CodeName) Then
          Do While Lost.Carrier=False
             Graphics.Off=True
             Strng="Team ANSI prefix code(8 characters, ? for help):"
             Call IO.O
             Strng="?"
             No.Input.Out=Nul
             Call IO.I
             Out2=Ucase$(Out2)
             If Out2="?" Then
                CALL Display.ANSI.Prefixes
             Else
                CALL Check.ANSI.Prefix(V%)
                If V% Then
                   Strng="ANSI prefix reset."
                   Call IO.O
                   TeamRecord.Prefix1=Out2
                   Call Write.Record(TeamFile,Var!)
                Else
                   Strng="Invalid ANSI prefix."
                   Call IO.O
                   TeamRecord.Prefix1=Nul
                   Call Write.Record(TeamFile,Var!)
                Endif
                Exit Do
             Endif
          Loop
          Exit Sub
       Endif
    Next
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume64a:
 Exit Sub
Error.Trap64a:
 Resume Error.Resume64a
End Sub

Sub Add.List.Node4(VarY!,VarZ!)
 On Local Error Goto ErrorTrp27b
 If TeamRecord.First=SFalse Then
    TeamRecord.First=VarZ!
    TeamRecord.Last=VarZ!
    Call Write.Record(TeamFile,VarY!)
    MessWorkRecord6.Prev=SFalse
    MessWorkRecord6.Next=SFalse
    Call Write.Record(TeamInvFile,VarZ!)
    Exit Sub
 Endif
 MessWorkRecord6.Prev=TeamRecord.Last
 MessWorkRecord6.Next=SFalse
 Call Write.Record(TeamInvFile,VarZ!)
 Call Read.Record(TeamInvFile,TeamRecord.Last)
 MessWorkRecord6.Next=VarZ!
 Call Write.Record(TeamInvFile,TeamRecord.Last)
 Call Read.Record(TeamInvFile,VarZ!)
 TeamRecord.Last=VarZ!
 Call Write.Record(TeamFile,VarY!)
ErrorRsm27b:
 Exit Sub
ErrorTrp27b:
 Resume ErrorRsm27b
End Sub

Sub Delete.List.Node4(VarY!,VarZ!)
 On Local Error Goto ErrorTrp32a
 If TeamRecord.First=VarZ! Then
    Call Read.Record(TeamInvFile,VarZ!)
    TeamRecord.First=MessWorkRecord6.Next
    Call Write.Record(TeamFile,VarY!)
    If TeamRecord.First>SFalse Then
       Call Read.Record(TeamInvFile,TeamRecord.First)
       MessWorkRecord6.Prev=SFalse
       Call Write.Record(TeamInvFile,TeamRecord.First)
    Endif
 Else
    If TeamRecord.Last=VarZ! Then
       Call Read.Record(TeamInvFile,VarZ!)
       TeamRecord.Last=MessWorkRecord6.Prev
       Call Write.Record(TeamFile,VarY!)
       If TeamRecord.Last>SFalse Then
          Call Read.Record(TeamInvFile,TeamRecord.Last)
          MessWorkRecord6.Next=SFalse
          Call Write.Record(TeamInvFile,TeamRecord.Last)
       Endif
    Else
       Call Read.Record(TeamInvFile,VarZ!)
       Previous.Node!=MessWorkRecord6.Prev
       Next.Node!=MessWorkRecord6.Next
       Call Read.Record(TeamInvFile,Previous.Node!)
       MessWorkRecord6.Next=Next.Node!
       Call Write.Record(TeamInvFile,Previous.Node!)
       Call Read.Record(TeamInvFile,Next.Node!)
       MessWorkRecord6.Prev=Previous.Node!
       Call Write.Record(TeamInvFile,Next.Node!)
    Endif
 Endif
ErrorRsm32a:
 Exit Sub
ErrorTrp32a:
 Resume ErrorRsm32a
End Sub

Sub List.Teams
 On Local Error Goto Error.Trap68
 Graphics.Off=False
 Strng="Team List:"
 Call IO.O
 VarQ=False
 VarZ=False
 Allow.Break=True
 Break=False
 Continuous=False
 Graphics.Off=True
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    Strng=Lcase$(Rtrim$(TeamRecord.Name))
    If Len(Strng) And TeamRecord.Deleted=False Then
       VarQ=True
       Graphics.Off=True
       Carriage.Return=True
       Strng="["+Mid$(Str$(Var!),2)+"]"
       Call IO.O
       Strng=Rtrim$(TeamRecord.Name)
       Strng=Lcase$(Strng)
       Call Capitalize(Strng)
       Strng=Rtrim$(TeamRecord.Prefix1)+Strng
       Call Convert.ANSI(True,VarQ,VarR)
       Carriage.Return=True
       Graphics.On=True
       Call IO.O
       Graphics.On=False
       TempX=False
       For VarX=1 To MaxTeamMembers
          Temp2$=Rtrim$(TeamRecord.Member(VarX))
          If Len(Temp2$) Then
             TempX=TempX+1
          Endif
       Next
       If TempX=0 Then
          Out2=" <empty>"
       Else
          Out2=Str$(TempX)+" member"
          If TempX>1 Then
             Out2=Out2+"s"
          Endif
       Endif
       Strng=Strng+","+Out2+"."
       Call IO.O
       If Break Then
          Exit For
       Endif
       VarZ=VarZ+1
       If VarZ>=User.Pagelength-2 Then
          VarZ=False
          If Continuous=False Then
             Call More.Prompt
             If No Or Quit Then
                Exit For
             Endif
          Endif
       Endif
    Endif
 Next
 If VarQ=False Then
    VarZ=True
    Strng="No teams exist."
    Call IO.O
 Endif
 If VarZ Then
    Call More.Prompt
 Endif
Error.Resume68:
 Exit Sub
Error.Trap68:
 Resume Error.Resume68
End Sub

Sub Show.Team
 On Local Error Goto Error.Trap69
 Graphics.Off=False
 Strng="Team Member List:"
 Call IO.O
 Graphics.Off=True
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    If TeamRecord.Deleted=False Then
       For VarX=1 To MaxTeamMembers
          Temp2$=Rtrim$(TeamRecord.Member(VarX))
          If Temp2$=Rtrim$(UserRecord.CodeName) Then
             Graphics.Off=True
             Carriage.Return=True
             Strng="Team: ["+Mid$(Str$(Var!),2)+"]"
             Call IO.O
             Strng=Rtrim$(TeamRecord.Name)
             Strng=Lcase$(Strng)
             Call Capitalize(Strng)
             Strng=Rtrim$(TeamRecord.Prefix1)+Strng
             Call Convert.ANSI(True,VarQ,VarR)
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Strng="Team Members:"
             Call IO.O
             For VarY=1 To MaxTeamMembers
                Strng=Rtrim$(TeamRecord.Member(VarY))
                If Len(Strng) Then
                   Strng=Lcase$(Strng)
                   Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
                   Strng=Mid$(Str$(VarY),2)+"."+Strng
                   Call Read.Record(UserFile2,TeamRecord.UserIndex(VarY))
                   Strng=Strng+" (level "+Form$(Cdbl(UserRecord2.Level))+")"
                   If TeamRecord.Activated(VarY) Then
                      Strng=Strng+" [active]"
                   Endif
                   Call IO.O
                Endif
             Next
             Call Amount5(TeamRecord.Gold,VarQ$)
             Strng="Team Gold:"+VarQ$
             Call IO.O
             Break=False
             Temp3#=DFalse
             VarZ1#=0#
             VarZ2#=0#
             Var2!=TeamRecord.First
             If Var2! Then
                Do While Lost.Carrier=False
                   Call Read.Record(TeamInvFile,Var2!)
                   Var3!=MessWorkRecord6.Next
                   Temp5!=MessWorkRecord6.Index
                   If Temp5!<SFalse Then
                      VarZ1#=VarZ1#+1#
                   Else
                      VarZ2#=VarZ2#+1#
                   Endif
                   Temp3#=Temp3#+1#
                   If Var3!=SFalse Then
                      Exit Do
                   Endif
                   Var2!=Var3!
                   Call Check.Carrier
                   Call Check.Break
                   If Break Then
                      Exit Do
                   Endif
                Loop
             Endif
             Break=False
             VarZ#=0#
             Var2!=TeamRecord.First2
             If Var2! Then
                Do While Lost.Carrier=False
                   Call Read.Record(ContainerFile,Var2!)
                   Var3!=ContainerRecord.Next
                   If ContainerRecord.WithinContainer=SFalse Then
                      If ContainerRecord.DeletedContainer=False Then
                         VarZ#=VarZ#+1#
                         Temp3#=Temp3#+1#
                      Endif
                   Endif
                   If Var3!=SFalse Then
                      Exit Do
                   Endif
                   Var2!=Var3!
                   Call Check.Carrier
                   Call Check.Break
                   If Break Then
                      Exit Do
                   Endif
                Loop
             Endif

             Strng="Team inventory:"
             Call IO.O

             Call Amount(VarZ1#,VarQ$)
             Out2=VarQ$+" item"
             If VarZ1#<>1# Then
                Out2=Out2+"s"
             Endif

             Strng="  Objects:"+Out2
             Call IO.O

             Call Amount(VarZ2#,VarQ$)
             Out2=VarQ$+" item"
             If VarZ2#<>1# Then
                Out2=Out2+"s"
             Endif

             Strng="  Treasure:"+Out2
             Call IO.O

             Call Amount(VarZ#,VarQ$)
             Out2=VarQ$+" item"
             If VarZ#<>1# Then
                Out2=Out2+"s"
             Endif

             Strng="  Containers:"+Out2
             Call IO.O

             Call Amount(Temp3#,VarQ$)
             Out2=VarQ$+" item"
             If Temp3#<>1# Then
                Out2=Out2+"s"
             Endif

             Strng="  Total:"+Out2
             Call IO.O
             Call More.Prompt
             Exit Sub
          Endif
       Next
    Endif
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume69:
 Exit Sub
Error.Trap69:
 Resume Error.Resume69
End Sub

Sub Offline.Fights
 On Local Error Goto Error.Trap69a
 For Var!=1! To Lof(TeamFile)/TeamRecLen
    Call Read.Record(TeamFile,Var!)
    If TeamRecord.Deleted=False Then
       For VarX=1 To MaxTeamMembers
          Temp2$=Rtrim$(TeamRecord.Member(VarX))
          If Temp2$=Rtrim$(UserRecord.CodeName) Then
             If TeamRecord.Activated(VarX) Then
                TeamRecord.Activated(VarX)=False
                Strng=" not "
             Else
                TeamRecord.Activated(VarX)=True
                Strng=" now "
             Endif
             Strng="You are"+Strng+"activated for offline team player fights."
             Call IO.O
             Call Write.Record(TeamFile,Var!)
             Exit Sub
          Endif
       Next
    Endif
 Next
 Strng="You don't belong to a team."
 Call IO.O
Error.Resume69a:
 Exit Sub
Error.Trap69a:
 Resume Error.Resume69a
End Sub

Sub Top.Ten.Teams
 On Local Error Goto ErrTrap10
 Allow.Break=False
 Break=False
 Graphics.Off=False
 Strng="Top ten teams. "
 If Local.Mode Then
    Var$="Press <ctrl-break>/<ctrl-c> to interrupt."
 Else
    Var$="Press <control-c>/<control-k> to interrupt."
 Endif
 Strng=Strng+Var$
 Call IO.O
 Graphics.Off=True
 TempX!=Lof(TeamFile)/TeamRecLen
 If TempX!=SFalse Then
    Strng="No teams exist."
    Call IO.O
    Exit Sub
 Endif
 Close #TempFile1
 FileName=DND.Path+"SORT1"+NodeX+".SWP"
 Open FileName For Random Shared As #TempFile1 Len=12
 Field #TempFile1,4 As U$,8 As Z$
 Allow.Break=True
 Break=False
 Do While Lost.Carrier=False
    Allow.Break=True
    Strng="DNDBBS v"+Version$+" r"+Release$+" Top Ten Team Rankings For "+Fclock$+"."
    Call IO.O
    If Break Then
       Exit Do
    Endif
    Strng=Nul
    Call IO.O
    If Break Then
       Exit Do
    Endif
    TempZ!=SFalse
    For Var1!=1! To TempX!
       Call Read.Record(TeamFile,Var1!)
       Strng=Rtrim$(TeamRecord.Name)
       Strng=Lcase$(Strng)
       If Len(Strng) And TeamRecord.Deleted=False Then
          TempQ=False
          TempA#=DFalse
          For Var2=1 To MaxTeamMembers
             Temp2$=Rtrim$(TeamRecord.Member(Var2))
             If Len(Temp2$) Then
                VarY!=TeamRecord.UserIndex(Var2)
                If VarY!>SFalse And VarY!<=Lof(UserFile2)/UserRecLen Then
                   Call Read.Record(UserFile2,VarY!)
                   Strng=UserRecord2.CodeName
                   If Left$(Strng,9)<>Deleted$ Then
                      TempQ=True
                      If UserRecord2.Level>=1 Then
                         TempA#=TempA#+Cdbl(UserRecord2.PermanentKilled*UserRecord2.Level*10)+ _
                         Cdbl(UserRecord2.PlayersKilled*UserRecord2.Level*2)+ _
                         Cdbl(UserRecord2.MonstersKilled*UserRecord2.Level)
                      Endif
                   Endif
                Endif
             Endif
          Next
          If TempQ Then
             If TempA#>DFalse Then
                TempZ!=TempZ!+1!
                Lset U$=Mks$(Var1!)
                Lset Z$=Mkd$(TempA#)
                Put #TempFile1,TempZ!
             Endif
          Endif
       Endif
    Next
    If TempZ!>SFalse Then
       For VarS1!=1! To TempZ!
          For VarS2!=VarS1!+1! To TempZ!
             Get #TempFile1,VarS1!
             TempZ1!=Cvs(U$)
             TempX1#=Cvd(Z$)
             Get #TempFile1,VarS2!
             TempZ2!=Cvs(U$)
             TempX2#=Cvd(Z$)
             If TempX1#<TempX2# Then
                Lset U$=Mks$(TempZ1!)
                Lset Z$=Mkd$(TempX1#)
                Put #TempFile1,VarS2!
                Lset U$=Mks$(TempZ2!)
                Lset Z$=Mkd$(TempX2#)
                Put #TempFile1,VarS1!
             Endif
          Next
       Next
    Endif
    If TempZ!>10! Then
       TempZ!=10!
    Endif
    If User.LineLength=40 Then
       Strng="Teamname                       Members"
       Call IO.O
       Strng="Gold               Ranking"
       Call IO.O
       Call Display.Line(38)
    Else
       Strng="Teamname                       Members Gold               Ranking"
       Call IO.O
       Call Display.Line(65)
    Endif
    If Break Then
       Exit Do
    Endif
    TempX=False
    For Temp1!=1! To TempZ!
       Get #TempFile1,Temp1!
       TempX!=Cvs(U$)
       TempZ#=Cvd(Z$)
       Call Read.Record(TeamFile,TempX!)
       Strng=TeamRecord.Name
       Strng=Rtrim$(Strng)
       Strng=Lcase$(Strng)
       Call Capitalize(Strng)
       Strng=Left$(Strng,30)
       VarQ=31-Len(Strng)
       If Rtrim$(Strng)<>Nul Then
          Strng=Rtrim$(TeamRecord.Prefix1)+Strng
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
	  Call IO.O
          Graphics.On=False
          TempQ=False
          For Temp2=1 To MaxTeamMembers
             VarY!=TeamRecord.UserIndex(Temp2)
             If VarY!>SFalse And VarY!<=Lof(UserFile2)/UserRecLen Then
                Call Read.Record(UserFile2,VarY!)
                Var2$=UserRecord2.CodeName
                If Left$(Var2$,9)<>Deleted$ Then
                   TempQ=TempQ+1
                Endif
             Endif
          Next
          Strng=Space$(VarQ)
          Strng=Strng+Mid$(Str$(TempQ),2)
          If User.LineLength=40 Then
             Call IO.O
          Else
             Strng=Strng+Space$(8-Len(Str$(TempQ)))
          Endif
          Temp#=TeamRecord.Gold
          Strng=Strng+Str$(Temp#)
          Strng=Strng+Space$(19-Len(Str$(Temp#)))
          Strng=Strng+Str$(TempZ#)
          TempX=True
          Call IO.O
          If Break Then
             Exit Do
          Endif
       Endif
    Next
    Exit Do
 Loop
 Allow.Break=False
 Break=False
 If TempX=False Then
    Strng="No teams have top scores."
    Call IO.O
 Endif
 Call More.Prompt
 Close #TempFile1
 If Dir$(FileName)<>"" Then
    Kill FileName
 Endif
ErrResume10:
 Exit Sub
ErrTrap10:
 Resume ErrResume10
End Sub

Sub Add.Container.Team(Var!,VarA!)
 On Local Error Goto ErrResume141h
 Call Read.Record(TeamFile,Var!)
 If TeamRecord.First2=SFalse Then
    TeamRecord.First2=VarA!
    TeamRecord.Last2=VarA!
    Call Write.Record(TeamFile,Var!)
    ContainerRecord.Prev=SFalse
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
 Else
    ContainerRecord.Prev=TeamRecord.Last2
    ContainerRecord.Next=SFalse
    Call Write.Record(ContainerFile,VarA!)
    Call Read.Record(ContainerFile,TeamRecord.Last2)
    ContainerRecord.Next=VarA!
    Call Write.Record(ContainerFile,TeamRecord.Last2)
    Call Read.Record(ContainerFile,VarA!)
    TeamRecord.Last2=VarA!
    Call Write.Record(TeamFile,Var!)
 Endif
ErrExit141h:
 Exit Sub
ErrResume141h:
 Resume ErrExit141h
End Sub

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

Sub Clear.Status.Line
 On Local Error Goto Error.Trap58a
 Temp$=Space$(79)
 Call Display.Status.Line(False)
Error.Resume58a:
 Exit Sub
Error.Trap58a:
 Resume Error.Resume58a
End Sub

Sub Alt.Login(Var,Var$)
 On Local Error Goto ErrorTrp25
 If Instr(Var$,"/N:") Then
    Var$=Left$(Var$,Instr(Var$,"/N:")-1)
 Endif
 Out2=Nul
 Var=False
 If Len(Var$) Then
    Var2=Instr(Var$,Chr$(34))
    If Var2 Then
       Var$=Mid$(Var$,Var2+1)
       Var2=Instr(Var$,Chr$(34))
       If Var2 Then
          Out2=Left$(Var$,Var2-1)
          If Out2=Nul Then
             Exit Sub
          Endif
       Else
          Exit Sub
       Endif
    Else
       Exit Sub
    Endif
 Endif
Start.Login:
 If Out2=Nul Then
    Graphics.Off=False
    Strng="Enter codename(?=list,*=search): "
    Call IO.I
 Endif
 Strng=Lcase$(Rtrim$(Out2))
 Out2=Nul
 If Len(Strng)=0 Then
    Exit Sub
 Endif
 If Strng="?" Then
    Temp1=False
    For Temp1!=1! To Lof(UserFile)/UserRecLen
       Call Read.Record(UserFile,Temp1!)
       Out3=UserRecord.CodeName
       Out3=Lcase$(Rtrim$(Out3))
       If Out3<>"<deleted>" Then
          Strng=Out3
          Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
          Strng=Rtrim$(UserRecord.Prefix1)+Strng
          Call Convert.ANSI(True,VarQ,VarR)
          Carriage.Return=True
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          Strng=Strng+" (level "+Form$(Cdbl(UserRecord.Level))+")"
          If UserRecord.ClassType=AsstDM Then
             Strng=Strng+" [AsstDM]"
          Endif
          If UserRecord.ClassType=DM Then
             Strng=Strng+" [DM]"
          Endif
          If UserRecord.Flags And Special.Char4 Then
             Strng=Strng+" [Sysop]"
          Endif
          Call Search.Mess.File(Temp1!,Var1)
          If Var1 Then
             Strng=Strng+" {online}"
          Endif
          Call IO.O
          Temp1=Temp1+1
          If Temp1>=User.Pagelength-2 Then
             Temp1=False
             Call More.Prompt
             If No Or Quit Then
                Exit For
             Endif
          Endif
       Endif
    Next
    If Temp1 Then
       Call More.Prompt
    Endif
    Out2=Nul
    Goto Start.Login
 Endif
 If Strng="*" Then
    Strng="Enter codename search(?,* allowed): "
    Call IO.I
    Var2$=Lcase$(Out2)
    Temp1=False
    Var2=False
    For Temp1!=1! To Lof(UserFile)/UserRecLen
       Call Read.Record(UserFile,Temp1!)
       Out3=UserRecord.CodeName
       Out3=Lcase$(Rtrim$(Out3))
       If Out3<>"<deleted>" Then
          Out2=Var2$
          Call InstrSUB2(VarX)
          If VarX Then
             Var2=True
             Strng=Out3
             Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
             Strng=Rtrim$(UserRecord.Prefix1)+Strng
             Call Convert.ANSI(True,VarQ,VarR)
             Carriage.Return=True
             Graphics.On=True
             Call IO.O
             Graphics.On=False
             Strng=Strng+" (level "+Form$(Cdbl(UserRecord.Level))+")"
             If UserRecord.ClassType=AsstDM Then
                Strng=Strng+" [AsstDM]"
             Endif
             If UserRecord.ClassType=DM Then
                Strng=Strng+" [DM]"
             Endif
             If UserRecord.Flags And Special.Char4 Then
                Strng=Strng+" [Sysop]"
             Endif
             Call Search.Mess.File(Temp1!,Var1)
             If Var1 Then
                Strng=Strng+" {online}"
             Endif
             Call IO.O
             Temp1=Temp1+1
             If Temp1>=User.Pagelength-2 Then
                Temp1=False
                Call More.Prompt
                If No Or Quit Then
                   Exit For
                Endif
             Endif
          Endif
       Endif
    Next
    If Var2=False Then
       Strng="Codename not found."
       Call IO.O
    Endif
    If Temp1 Then
       Call More.Prompt
    Endif
    Out2=Nul
    Goto Start.Login
 Endif
 For User.Index=1! To Lof(UserFile)/UserRecLen
    Call Read.Record(UserFile,User.Index)
    Out3=UserRecord.CodeName
    Out3=Lcase$(Rtrim$(Out3))
    If Strng=Out3 Then
       Var=True ' valid name
       Exit Sub
    Endif
 Next
 User.Index=SFalse
 Exit Sub
ErrorRsm25:
 Exit Sub
ErrorTrp25:
 Security.Guard=False
 Resume ErrorRsm25
End Sub

Sub Get.Node
 On Local Error Goto Node.Error
 Var$=Command$
 Var$=Ltrim$(Rtrim$(Var$))
 If Instr(Var$,"/N:") Then
    Var$=Mid$(Var$,Instr(Var$,"/N:")+3)
    Select Case Len(Var$)
    Case 0
       Node=0
       NodeX=Nul
       Exit Sub
    Case 1 ' 0-9,A-Z
       Select Case Var$
       Case "0" To "9"
          Node=Val(Var$)+1
          NodeX=Var$
       Case "A" To "Z"
          Node=Asc(Var$)-54
          NodeX=Var$
       Case Else
          Goto Node.Error
       End Select
    Case 2 ' 10-99
       VarX=Int(Val(Var$)+.5)
       If VarX>=10 And VarX<=99 Then
          Node=VarX+27 ' 37-126
          NodeX=Mid$(Str$(VarX),2) ' 10-99
       Else
          Goto Node.Error
       Endif
    Case Else
       Goto Node.Error
    End Select
 Endif
 Exit Sub
Node.Error:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error reading node. Node must be <nul>,0-9,A-Z,10-99."
 Call Terminate.Program
End Sub

Sub Valid.Node
 On Local Error Goto ErrorTrap11
 If Node>=False And Node<=MaxNodes Then
    VarX2=Node+1
    Call Read.Message.Record(MessWorkFile1,VarX2)
    If MessWorkRecord1.ActiveNode Then
       If Rtrim$(NodeX)=Nul Then
          Strng="Node -, already active."
       Else
          Strng="Node "+NodeX+", already active."
       Endif
       Goto ErrorTrap11
    Else
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          If Rtrim$(NodeX)=Nul Then
             Strng="Node -, active codename."
          Else
             Strng="Node "+NodeX+", active codename."
          Endif
          Goto ErrorTrap11
       Endif
    Endif
 Else
    Strng="Node "+Quote$+NodeX+Quote$+" is not a valid node number."
    Goto ErrorTrap11
 Endif
ErrorResume11:
 Exit Sub
ErrorTrap11:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3=Strng
 Call Terminate.Program
End Sub

Sub Open.Arrays
 On Local Error Goto Array.Error
 Call Plex.Function(26)
 If (OutregsX.AX And &HFF)=&HFF Then
    Local.ANSI.Color=True
 Else
    Local.ANSI.Color=False
 Endif
 Local.Avatar.Color=False
 Call Plex.Function(27)
 If (OutregsX.AX And &HFF)=&HFF Then
    If (OutregsX.DX And &HFF)=&H16 Then
       Local.Avatar.Color=True
    Endif
 Endif
 Local.Mode=True
 Lost.Carrier=False
 Call Read.Rows(Max.Row)
 Locate Max.Row,1,1
 Call VideoInt(15,0)
 Video.Page=OutregsX.BX
Redim Alignment.Name1(1 To MaxAlignment) As String*7,_
 Alignment.Name2(1 To MaxAlignment) As String*7,_
 Class.Name(1 To MaxClassNames) As String*15,_
 Direction(1 To MaxDirections) As String*9,_
 High.Class.Name(1 To MaxClassNames) As String*15,_
 InventoryNames(1 To MaxItems) As String*8,_
 Numeral(1 To MaxNumerals) As String*5,_
 Race(1 To MaxRaces) As String*8,_
 Room.Array(1 To MaxRoomArrays) As String*40,_
 Stat(1 To MaxStats) As String*12,_
 Training.Stats(1 To MaxClassNames,1 To MaxTrainStats) As Integer,_
 Weapon.Type.Name(1 To MaxWeapons) As String*9
 Exit Sub
Array.Error:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error opening arrays. Free more RAM."
 Call Terminate.Program
End Sub

Sub Get.Config
 On Local Error Goto Config.Error
 DND.Path=Environ$("DNDBBS")
 If DND.Path<>Nul Then
    If Right$(DND.Path,1)<>"\" Then
       DND.Path=DND.Path+"\"
    Endif
 Endif
 FileName=DND.Path+"DND"+NodeX+".CFG"
 Close #TempFile1
 Open FileName For Input Shared As #TempFile1
 Line Input #TempFile1,Var$
 For Temp1=1 To MaxConfigArray1
    Input #TempFile1,Var!
 Next
 For Temp1=1 To MaxConfigArray2
    Input #TempFile1,Var%
    Select Case Temp1
    Case 48
       Allow.High.Class=Var%
    Case 81
       Allow.Remote.Edit=Var%
    Case 86
       User.Echo=Var%
    Case 87
       User.Linefeeds=Var%
    Case 88
       User.Linelength=Var%
    Case 89
       User.Pagelength=Var%
    Case 90
       User.Wordwrap=Var%
    Case 111
       Disable.DM=Var%
    Case 112
       Disable.Nodes=Var%
    Case 113
       Disable.Sysop=Var%
    End Select
 Next
 For Temp1=1 To MaxConfigArray3
    Line Input #TempFile1,Var$
    Select Case Temp1
    Case 1
       Prelog.FileName=Var$
    Case 3
       Welcome.FileName=Var$
    Case 4
       Notice.FileName=Var$
    Case 11
       Data.Path1=Var$
    Case 12
       MonClass.FileName=Var$
    Case 13
       MonTalk.FileName=Var$
    Case 15
       File.Extension1=Var$
    Case 16
       Room.FileName=Var$
    Case 17
       Object.FileName=Var$
    Case 18
       Monster.FileName=Var$
    Case 19
       Treasure.FileName=Var$
    Case 20
       Spell.FileName=Var$
    Case 21
       User.FileName=Var$
    Case 22
       NonPlayer.FileName=Var$
    Case 28
       Logoff.FileName=Var$
    Case 38
       Logoff.Help.FileName=Var$
    Case 51
       Usage.FileName=Var$
    Case 52
       Data.Path2=Var$
    Case 53
       Data.Path3=Var$
    Case 54
       Data.Path4=Var$
    Case 55
       Help.FileName1=Var$
    Case 56
       Help.Filename2=Var$
    Case 57
       Team.FileName=Var$
    Case 58
       Public.FileName=Var$
    Case 59
       Message.Base.FileName=Var$
    Case 60
       Private.FileName=Var$
    Case 61
       Help.FileName3=Var$
    Case 62
       File.Extension2=Var$
    Case 65
       Catalog.FileName=Var$
    Case 68
       MessWork.FileName=Var$
    Case 71
       Action.FileName=Var$
    Case 72
       Day.File.FileName=Var$
    Case 76
       Help.FileName4=Var$
    Case 80
       Container.FileName=Var$
    Case 85
       ANSIPrefixChar=Var$
    Case 86
       UserInv.FileName=Var$
    Case 87
       CtnInv.FileName=Var$
    Case 88
       TeamInv.FileName=Var$
    Case 89
       RoomInv.FileName=Var$
    Case 90
       MonInv.FileName=Var$
    Case 91
       Inline.FileName2=Var$
    Case 92
       Inline.FileName1=Var$
    Case 93
       Room.Desc.FileName=Var$
    End Select
 Next
 For Temp1=1 To 10
    For Temp2=1 To 4
       Input #TempFile1,Training.Stats(Temp1,Temp2)
    Next
 Next
 For Temp1=1 To 20
    Line Input #TempFile1,Room.Array(Temp1)
 Next
 MessWork.FileName=Data.Path3+MessWork.FileName
 For Temp1=1 To 10
    Line Input #TempFile1,High.Class.Name(Temp1)
 Next
 For Temp1=1 To 8
    Line Input #TempFile1,Race(Temp1)
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Class.Name(Temp1)
 Next
 For Temp1=1 To 7
    Line Input #TempFile1,Stat(Temp1)
 Next
 For Temp1=1 To 12
    Line Input #TempFile1,Direction(Temp1)
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Numeral(Temp1)
 Next
 For Temp1=1 To 4
    Line Input #TempFile1,Weapon.Type.Name(Temp1)
 Next
 For Temp1=1 To 3
    Line Input #TempFile1,Alignment.Name1(Temp1)
 Next
 For Temp1=1 To 3
    Line Input #TempFile1,Alignment.Name2(Temp1)
 Next
 For Temp1=1 To MaxUserCommands
    Line Input #TempFile1,Var$
    For Temp2=1 To 3
       Line Input #TempFile1,Var$
    Next
    Input #TempFile1,Var%
    For Temp2=1 To 8
       Input #TempFile1,Var%
    Next
    For Temp2=1 To 4
       Input #TempFile1,Var%
    Next
    Input #TempFile1,Var%
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxDMcommands
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
    For Temp2=1 To 3
       Input #TempFile1,Var%
    Next
 Next
 For Temp1=1 To MaxSysopCommands
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxNodeCommands
    Line Input #TempFile1,Var$
    For Temp2=1 To 8
       Input #TempFile1,Var%
    Next
 Next
 For Temp1=1 To MaxLetters
    Input #TempFile1,Var%
 Next
 For Temp1=1 To MaxStrips
    Line Input #TempFile1,Var$
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,Var$
    Input #TempFile1,Var%
    Input #TempFile1,Var%
 Next
 For Temp1=1 To 10
    Line Input #TempFile1,InventoryNames(Temp1)
 Next
 Exit Sub
Config.Error:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error reading "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Run Dndcnfg."
 Call Terminate.Program
End Sub

Sub Increase.Files
 On Local Error Goto Increase.Error
 Close
 Call StdinInt(62,0)
 PSP.Segment=OutregsX.BX
 Def Seg=PSP.Segment
 Command.Line=&H80
 Command.Tail=Command.Line+60
 For Var=1 To 54
    Poke Command.Tail+Var-1,&HFF
 Next
 For Var=1 To 4
    File.Handle=Peek(&H18+Var-1)
    Poke Command.Tail+Var-1,File.Handle
 Next
 Poke &H32,54
 Poke &H34,Command.Tail
 Def Seg
 Close
 Exit Sub
Increase.Error:
 Color 14,0
 Out2="Error increasing file handles."+Chr$(13)+Chr$(10)
 Out3="Increase files= in config.sys or config.nt, or run Dndcnfg."
 Call Terminate.Program
End Sub

Sub Make.FileNames
 On Local Error Goto Make.Error
 Out2=Environ$("DNDDAT")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path1=Out2
 Endif
 Out2=Environ$("DNDDOC")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path2=Out2
 Endif
 Out2=Environ$("DNDTEMP")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path3=Out2
 Endif
 Out2=Environ$("DNDMESS")
 If Out2<>Nul Then
    If Right$(Out2,1)<>"\" Then
       Out2=Out2+"\"
    Endif
    Data.Path4=Out2
 Endif
 DOS.Exit="EDTDOS"+Rtrim$(NodeX)+".BAT"
 Day.File.FileName=Data.Path1+Day.File.FileName
 Catalog.FileName=Data.Path2+Catalog.FileName+File.Extension2
 Logoff.FileName=Data.Path1+Logoff.FileName+File.Extension1
 Notice.FileName=Data.Path1+Notice.FileName+File.Extension1
 Prelog.FileName=Data.Path1+Prelog.FileName+File.Extension1
 Welcome.FileName=Data.Path1+Welcome.FileName+File.Extension1
 User.FileName=Data.Path1+User.FileName+File.Extension1
 NonPlayer.FileName=Data.Path1+NonPlayer.FileName+File.Extension1
 Room.FileName=Data.Path1+Room.FileName+File.Extension1
 Object.FileName=Data.Path1+Object.FileName+File.Extension1
 Monster.FileName=Data.Path1+Monster.FileName+File.Extension1
 Treasure.FileName=Data.Path1+Treasure.FileName+File.Extension1
 MonTalk.FileName=Data.Path1+MonTalk.FileName+File.Extension1
 MonClass.FileName=Data.Path1+MonClass.FileName+File.Extension1
 Spell.FileName=Data.Path1+Spell.FileName+File.Extension1
 Action.FileName=Data.Path1+Action.FileName+File.Extension1
 Team.FileName=Data.Path1+Team.FileName+File.Extension1
 Container.FileName=Data.Path1+Container.FileName+File.Extension1
 Message.Base.FileName=Data.Path4+Message.Base.FileName+File.Extension1
 Logon.Help.FileName=Data.Path1+Help.FileName3+File.Extension1
 UserInv.FileName=Data.Path1+UserInv.FileName+File.Extension1
 CtnInv.FileName=Data.Path1+CtnInv.FileName+File.Extension1
 TeamInv.FileName=Data.Path1+TeamInv.FileName+File.Extension1
 RoomInv.FileName=Data.Path1+RoomInv.FileName+File.Extension1
 MonInv.FileName=Data.Path1+MonInv.FileName+File.Extension1
 Room.Desc.FileName=Data.Path1+Room.Desc.FileName+File.Extension1
 Usage.FileName=Data.Path1+Usage.FileName+File.Extension1
 Help.FileName1=Data.Path1+Help.FileName1+File.Extension1
 Help.FileName2=Data.Path1+Help.FileName2+File.Extension1
 Logoff.Help.FileName=Data.Path1+Logoff.Help.FileName+File.Extension1
 Exit Sub
Make.Error:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error making "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Increase files= in config.sys or run Dndcnfg."+Chr$(13)+Chr$(10)
 Call Terminate.Program
End Sub

Sub Open.Files
 On Local Error Goto Open.Error
 Close
 ActionRecLen=Len(ActionRecord)
 BufferRecLen=Len(BufferRecord)
 ContainerRecLen=Len(ContainerRecord)
 HelpRecLen1=Len(HelpRecord1)
 HelpRecLen2=Len(HelpRecord2)
 HelpRecLen3=Len(HelpRecord3)
 MessBaseRecLen=Len(MessageBaseRecord)
 MessageRecLen=Len(BufferRecord)
 MonsterRecLen=Len(MonsterRecord)
 NewMessRecLen=Len(NewMessages)
 TableRecLen=Len(TableRecord)
 UserRecLen=Len(UserRecord)
 UserProfileRecLen=Len(UserProfile)
 MonClassRecLen=Len(MonClassRecord)
 MonTalkRecLen=Len(BufferRecord)
 NonPlayerRecLen=Len(MonsterRecord)
 ObjectRecLen=Len(ObjectRecord)
 RoomDescLen=Len(BufferRecord)
 RoomRecLen=Len(RoomRecord)
 SpellRecLen=Len(SpellRecord)
 TeamRecLen=Len(TeamRecord)
 TreasureRecLen=Len(TreasureRecord)
 MessWorkRecLen1=Len(MessWorkRecord1)
 MessWorkRecLen2=Len(MessWorkRecord2)
 MessWorkRecLen3=Len(MessWorkRecord3)
 MessWorkRecLen5=Len(MessWorkRecord5)
 MessWorkRecLen4=Len(MessWorkRecord4)
 MessWorkRecLen6=Len(MessWorkRecord6)
 MessWorkRecLen7=Len(MessWorkRecord7)
 FileName=DND.Path+"ACCOUNTS.SIC"
 Open FileName For Random Shared As #SicFile Len=UserProfileRecLen

 FileName=User.FileName
 Open FileName For Random Shared As #UserFile Len=UserRecLen
 Open FileName For Random Shared As #UserFile2 Len=UserRecLen

 FileName=NonPlayer.FileName
 Open FileName For Random Shared As #NonPlayerFile Len=NonPlayerRecLen
 FileName=Room.FileName
 Open FileName For Random Shared As #RoomFile Len=RoomRecLen
 FileName=Object.FileName
 Open FileName For Random Shared As #ObjectFile Len=ObjectRecLen
 FileName=Monster.FileName
 Open FileName For Random Shared As #MonsterFile Len=MonsterRecLen
 FileName=Treasure.FileName
 Open FileName For Random Shared As #TreasureFile Len=TreasureRecLen
 FileName=MonTalk.FileName
 Open FileName For Random Shared As #MonTalkFile Len=MonTalkRecLen
 FileName=MonClass.FileName
 Open FileName For Random Shared As #MonClassFile Len=MonClassRecLen
 FileName=Spell.FileName
 Open FileName For Random Shared As #SpellFile Len=SpellRecLen
 FileName=Action.FileName
 Open FileName For Random Shared As #ActionFile Len=ActionRecLen
 FileName=Help.FileName1
 Open FileName For Random Shared As #HelpFile1 Len=HelpRecLen1
 FileName=Team.FileName
 Open FileName For Random Shared As #TeamFile Len=TeamRecLen
 FileName=Container.FileName
 Open FileName For Random Shared As #ContainerFile Len=ContainerRecLen
 FileName=Message.Base.FileName
 Open FileName For Random Shared As #MessBaseFile Len=MessBaseRecLen
 FileName=UserInv.FileName
 Open FileName For Random Shared As #UserInvFile Len=MessWorkRecLen6
 FileName=CtnInv.FileName
 Open FileName For Random Shared As #CtnInvFile Len=MessWorkRecLen6
 FileName=TeamInv.FileName
 Open FileName For Random Shared As #TeamInvFile Len=MessWorkRecLen6
 FileName=RoomInv.FileName
 Open FileName For Random Shared As #RoomInvFile Len=MessWorkRecLen6
 FileName=MonInv.FileName
 Open FileName For Random Shared As #MonInvFile Len=MessWorkRecLen6
 FileName=Room.Desc.FileName
 Open FileName For Random Shared As #RoomDescFile Len=RoomDescLen
 FileName=MessWork.FileName+"1"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile1 Len=MessWorkRecLen1
 FileName=MessWork.FileName+"2"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile2 Len=MessWorkRecLen2
 FileName=MessWork.FileName+"6"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile6 Len=MessWorkRecLen6
 FileName=MessWork.FileName+"7"+File.Extension1
 Open FileName For Random Shared As #MessWorkFile7 Len=MessWorkRecLen7
 Exit Sub
Open.Error:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error opening "+Lcase$(FileName)+" (error:"+Str$(Err)+"). Increase files= in config.sys or run Dndcnfg."+Chr$(13)+Chr$(10)
 Call Terminate.Program
End Sub

Sub Read.Options
 On Local Error Goto Error.Trap13
 Redim Options.Array(1 To 165) As String
 Options.Lines=165
 Var=0
 Close #TempFile1
 Filename=DND.Path+"option"+nodex+".cfg"
 If Dir$(Filename)<>Nul Then
    Open Filename For Input As #TempFile1
    Do
       If Eof(TempFile1) Then
          Exit Do
       Endif
       Line Input #TempFile1, Var$
       Var$=Rtrim$(Var$)
       If Left$(Var$,1)=";" Then
          Eat$ = Nul
       Else
          If Len(Var$) Then
             Var=Var+1
             If Var>Options.Lines Then
                Options.Lines=Options.Lines+10
                Redim Preserve Options.Array(1 To Options.Lines) As String
             Endif
             Options.Array(Var)=Var$
          Endif
       Endif
    Loop
 Endif
 Options.Lines=Var
Error.Resume13:
 Exit Sub
Error.Trap13:
 Color 14,0
 Out2="CMD126 Module - Teams"+Chr$(13)+Chr$(10)
 Out3="Error"+Str$(Err)+" reading "+FileName+". Edit file and restart."
 Call Terminate.Program
 Resume Error.Resume13
End Sub

Sub Reset.Cursor
 On Local Error Goto ErrMain13
 Call ScreenANSI(1,37,7)
 Locate Max.Row-1,1,1
 Graphics.Off=False
 Line.Length=False
MainExit13:
 Exit Sub
ErrMain13:
 Resume MainExit13
End Sub

Sub Detect.Share
 On Local Error Goto ErrResume149b
 Call Plex.Function(16)
 If (OutregsX.AX And &HFF)=&HFF Then
    Share.Installed=True
 Else
    Share.Installed=False
 Endif
 Windows.Detected = False
 Call Plex.Function(22)
 If OutregsX.BX>0 Then
    Windows.Detected = True
    ' store windows version
    Win.Minor=OutregsX.BX And &HFF
    Win.Major=(OutregsX.BX And &HFF00)/256
 Endif
ErrExit149b:
 Exit Sub
ErrResume149b:
 Resume ErrExit149b
End Sub

Sub Read.Rows(Var)
 On Local Error Goto Error.Trap62x
 Temp1=50
 Locate 50,1,0
 Var=50
 Exit Sub
Next.Trap1:
 Temp1=43
 Locate 43,1,0
 Var=43
 Exit Sub
Next.Trap2:
 Temp1=25
 Locate 25,1,0
 Var=25
 Exit Sub
Next.Trap3:
 Var=12
Error.Resume62x:
 Exit Sub
Error.Trap62x:
 If Temp1=50 Then
    Resume Next.Trap1
 Endif
 If Temp1=43 Then
    Resume Next.Trap2
 Endif
 If Temp1=25 Then
    Resume Next.Trap3
 Endif
 Resume Error.Resume62x
End Sub

Sub Search.Mess.File(Var1!,Var2)
 On Local Error Goto ErrMain41
 Var2=False
 For TempA=False To MaxNodes
    Call Read.Message.Record(MessWorkFile1,TempA+1)
    Var$=MessWorkRecord1.UserName
    Select Case Rtrim$(Lcase$(Var$))
    Case "login", "logoff", "relogin"
       TempB=False
    Case Deleted$, Offline$
       TempB=False
    Case Else
       TempB=True
    End Select
    If TempB Then
       If MessWorkRecord1.UserIndex=Var1! Then
          Var2=True
          Exit For
       Endif
    Endif
 Next
MainExit41:
 Exit Sub
ErrMain41:
 Resume MainExit41
End Sub

Sub Save.Screen2(Var)
 On Local Error Goto Error.Trap62z
 If Var=False Then
    VarX3=(Max.Row-1)*80+80
    Redim Temp.ArrayY(VarX3) As Long
    Redim Temp.ArrayZ(VarX3) As Double
    For Var1=1 To Max.Row
       For Var2=1 To 80
          TempZ1=Screen(Var1,Var2)
          TempZ2=Screen(Var1,Var2,1)
          VarX2=(Var1-1)*80+Var2
          Temp.ArrayY(VarX2)=TempZ1
          Temp.ArrayZ(VarX2)=TempZ2
       Next
    Next
 Else
    Cls
    For VarX=Max.Row To 1 Step -1
       For VarY=1 To 80
          VarX2=(VarX-1)*80+VarY
          If Temp.ArrayY(VarX2)<>32 Then
             Goto Next.Line
          Endif
       Next
    Next
Next.Line:
    TempX=VarX
    For Var1=1 To VarX ' Max.Row
       For Var2=1 To 80
          VarX2=(Var1-1)*80+Var2
          VarB=Int(Temp.ArrayZ(VarX2)/16)
          VarF=Temp.ArrayZ(VarX2) Mod 16
          TempZ1=Temp.ArrayY(VarX2)
          Locate Var1,Var2,0
          Color VarF,VarB
          Print Chr$(TempZ1);
       Next
    Next
 Endif
Error.Resume62z:
 Exit Sub
Error.Trap62z:
 Resume Error.Resume62z
End Sub

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