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

Sub Abort.Node
 On Local Error Goto Error.Trap181
 Call Get.Node(Var!,Var$)
 If Var!=SFalse Then
    If Temp>=1 And Temp<=MaxNodes Then
       If Temp<=Lof(MessWorkFile1)/MessWorkRecLen1 Then
          Call Read.Message.Record(MessWorkFile1,Temp+1)
          If MessWorkRecord1.ActiveNode Then
             Strng="Active node has no online user.."
             Call IO.O
             Strng="Are you sure you want to abort node "+Ucase$(Var$)+" to DOS(y/n)? "
             No.Input.Out="N"
             Call IO.I
             If Yes Then
                Call Read.Message.Record(MessWorkFile1,Temp+1)
                MessWorkRecord1.ActiveNode=False
                Call Write.Message.Record(MessWorkFile1,Temp+1)
                Strng="Abort message sent."
                Call IO.O
             Endif
             Exit Sub
          Endif
       Endif
    Endif
    Strng="You can't abort that node!"
    Call IO.O
    Exit Sub
 Endif
 ' Var! is online.
 If Temp>=1 And Temp<=MaxNodes Then
    Strng="Active node has online user.."
    Call IO.O
    Do While Lost.Carrier=False
       Graphics.Off=False
       Strng="Abort node menu:"
       Call IO.O
       Graphics.Off=True
       Strng="(A)bort node(to DOS)"
       Call IO.O
       Strng="(S)hut down node(Recycle)"
       Call IO.O
       Strng="(C)ancel abort"
       Call IO.O
       Strng="(H)elp on abort"
       Call IO.O
       Graphics.Off=False
       Strng="Enter selection(A/S/C/H)? "
       No.Input.Out="C"
       Call IO.I
       Select Case Ucase$(Out2)
       Case "A"
          VarQ1=1
          Exit Do
       Case "S"
          VarQ1=2
          Exit Do
       Case "C"
          Exit Sub
       Case "H"
          Call Out.File(Data.Path2+"ABORT2.DOC","")
       End Select
    Loop
    Select Case VarQ1
    Case 1
       If Temp=Node Then
          Strng="Abort this node to DOS(y/n)?"
          Call IO.I
          If Yes Then
             Call Hang.Up(11)
          Endif
       Else
          Strng="Are you sure you want to abort node "+Ucase$(Var$)+" to DOS(y/n)? "
          No.Input.Out="N"
          Call IO.I
          If Yes Then
             Call Shutdown.Message(1)
             Call Send.Mess(14,Var!,SFalse,"Abort")
          Endif
       Endif
    Case 2
       If Temp=Node Then
          Strng="Shutdown this node and recycle(y/n)?"
          Call IO.I
          If Yes Then
             Call Hang.Up(4)
          Endif
       Else
          Strng="Are you sure you want to shutdown node "+Ucase$(Var$)+" and recycle(y/n)? "
          No.Input.Out="N"
          Call IO.I
          If Yes Then
             Call Shutdown.Message(2)
             Call Send.Mess(33,Var!,SFalse,"Shutdown")
          Endif
       Endif
    End Select
    Exit Sub
 Endif
 Strng="You can't abort that node!"
 Call IO.O
Error.Resume181:
 Exit Sub
Error.Trap181:
 Resume Error.Resume181
End Sub

Sub Shutdown.Message(Var)
 On Local Error Goto Err.Trap31
 No.Input.Out="N"
 Strng="Send shutdown message(y/n)? "
 Call IO.I
 If No Then
    Exit Sub
 Endif
 Strng="Enter shutdown message(80 char.):"
 Call IO.O
 Strng="?"
 Line.Length=80
 Call IO.I
 Var1$=Out2
 Strng="Sending message.."
 Call IO.O
 Call Send.Mess(5,SFalse,SFalse,Var1$)
 Strng="Enter seconds to wait(1-360)/<enter>=none? "
 Call IO.I
 VarX=Int(Val(Out2)+.5)
 If VarX>=1 And VarX<=360 Then
    Strng="Waiting"+Str$(VarX)+" seconds. Enter Control-K to break.."
    Call IO.O
    Carriage.Return=True
    Graphics.Off=True
    Strng="..0   "
    Call IO.O
    VarY=False
    Do While Security.Guard
       Allow.Break=True
       Call Pause.Second
       If Break Then
          For VarZ=1 To 4
             Call Back.Space
          Next
          Allow.Break=False
          Break=False
          Carriage.Return=True
          Graphics.Off=True
          Strng="break"
          Call IO.O
          Exit Do
       Endif
       If Lost.Carrier Then
          Exit Do
       Endif
       For VarZ=1 To 4
          Call Back.Space
       Next
       VarY=VarY+1
       VarZ$=Mid$(Str$(VarY),2)
       VarZ$=VarZ$+Space$(4-Len(VarZ$))
       Strng=VarZ$
       Carriage.Return=True
       Graphics.Off=True
       Call IO.O
       If VarY>=VarX Then
          Exit Do
       Endif
    Loop
    Allow.Break=False
    Break=False
    Carriage.Return=False
    Call IO.O
 Endif
 If Var=1 Then
    Strng="Abort message sent."
 Else
    Strng="Shutdown message sent."
 Endif
 Call IO.O
Err.Resume31:
 Exit Sub
Err.Trap31:
 Resume Err.Resume31
End Sub

Sub Get.Node(Var!,Var$)
 On Local Error Goto ErrorTrap1
 Var!=SFalse
 Var$=Rtrim$(Ltrim$(Parsed.Command1))
 Select Case Len(Var$)
 Case 1
    Select Case Ucase$(Var$)
    Case "0" To "9" ' 1-10
       Temp=Val(Parsed.Command1)+1
       Call Read.Message.Record(MessWorkFile1,Temp+1)
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          Var!=MessWorkRecord1.UserIndex
          Exit Sub
       Endif
    Case "A" To "Z" ' 11-36
       Temp=Asc(Ucase$(Var$))-54
       Call Read.Message.Record(MessWorkFile1,Temp+1)
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          Var!=MessWorkRecord1.UserIndex
          Exit Sub
       Endif
    End Select
 Case 2
    VarX=Int(Val(Var$)+.5)
    If VarX>=10 And VarX<=99 Then
       Temp=VarX+27 ' 37-126
       Call Read.Message.Record(MessWorkFile1,Temp+1)
       Strng=Rtrim$(MessWorkRecord1.UserName)
       Call Valid.Name(Strng)
       If TempA Then
          Var!=MessWorkRecord1.UserIndex
          Exit Sub
       Endif
    Endif
 End Select
 Call Search.Mess(SFalse)
 If Temp! Then
    Temp=TempC
    Var!=MessWorkRecord1.UserIndex
    Select Case Temp
    Case 0 ' nul
       Var$="-"
    Case 1 To 10 ' 0-9
       Var$=Mid$(Str$(Temp-1),2)
    Case 11 To 36 ' A-Z
       Var$=Chr$(Temp+54)
    Case 37 To 126 ' 10-99
       Var$=Mid$(Str$(Temp-27),2)
    End Select
 Endif
ErrorResume1:
 Exit Sub
ErrorTrap1:
 Resume ErrorResume1
End Sub
