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

Function ValidDate(Var$)
 On Local Error Goto DateError
 Var$=Rtrim$(Var$)
 If Len(Var$)=10 Then ' mm-dd-yyyy
    For Var=1 To 10
       V$=Mid$(Var$,Var,1)
       Select Case Var
       Case 1, 2, 4, 5, 7, 8, 9, 10
          If V$>="0" And V$<="9" Then
             Eat$ = Nul
          Else
             Goto DateResume
          Endif
       Case Else
          If V$ <> "-" Then
             Goto DateResume
          Endif
       End Select
    Next
 Endif
 Temp#=DateValue(Var$)
 If Temp# Then
    TempC$=Var$
    ValidDate=True
    Exit Function
 Endif
DateResume:
 ValidDate=False
 Exit Function
DateError:
 Resume DateResume
End Function

Sub Old.System.News
 On Local Error Goto Error.Trap20
 Gosub Get.Config
 Filename=DND.Path+"SYSNEWS.DAT"
 If Dir$(Filename)=Nul Then
    Strng="No system news for "+DateS$
    Call IO.O
    Exit Sub
 Endif
 Close #TempFile1
 Open Filename For Input Shared As #TempFile1
 Do While Lost.Carrier=False
    No.Input.Out="01-01-1980"
    Strng="Enter system news date to start scan at(form: MM-DD-YYYY)?"
    Call IO.I
    VarZ$=Out2
    TempA=ValidDate(VarZ$)
    If TempA=False Then
       Strng="Invalid date. Set from 01-01-1980 to 12-31-2078"
       Call IO.O
    Else
       Temp#=DateValue(VarZ$)
       Exit Do
    Endif
 Loop
 Var2$=Nul
 If Option1 Then
    No.Input.Out="N"
    Strng="Search subject text(y/n)? "
    Call IO.I
    If Yes Then
       Strng="Enter text(?, * allowed): "
       Call IO.I
       Var2$=Lcase$(Out2)
    Endif
 Endif
 Var=False
 VarX=False
 Temp=1
 Allow.Break=True
 Break=False
 Continuous=False
 Do While Security.Guard
    If Lost.Carrier Then
       Exit Do
    Endif
    If Eof(TempFile1) Then
       Exit Do
    Endif
    ' date: 01-01-1980 subject: text
    Line Input #TempFile1,Strng
    If Lcase$(Left$(Strng,6))="date: " Then
       Var=False
       Temp2#=DateValue(Mid$(Strng,7,10))
       If Temp2#>=Temp# Then
          Var=True
          If Len(Var2$) Then
             Strng2=Lcase$(Ltrim$(Mid$(Strng,17)))
             If Left$(Strng2,8)="subject:" Then
                Strng2=Ltrim$(Mid$(Strng2,9))
                If Len(Strng2) Then
                   Out2 = Lcase$(Var2$)
                   Out3 = Lcase$(Strng2)
                   Call InstrSUB2(Var) ' see if out2 in out3
                Endif
             Endif
          Endif
          If Var Then
             VarX=True
             Graphics.Off=False
             Call IO.O
             Temp=Temp+1
          Endif
       Endif
    Else
       If Var Then
          No=0:Quit=0
          Graphics.Off=True
          Call Convert.String
          Call Convert.ANSI(True,VarQ,VarR)
          If No Or Quit Then ' possible moreprompt
             Strng=Nul:Out2=Nul
             Exit Do
          Endif
          Graphics.On=True
          Call IO.O
          Graphics.On=False
          If Break Then
             Exit Do
          Endif
          Temp=Temp+1
          If Temp>=User.PageLength-2 Then
             Temp=False
             If Continuous=False Then
                Call More.Prompt
                If No Or Quit Then
                   Exit Do
                Endif
             Endif
          Endif
       Endif
    Endif
 Loop
 Allow.Break=False
 Break=False
 Graphics.Off=False
 If VarX=False Then
    Strng="No system news found."
 Else
    Strng="End of system news."
 Endif
 Call IO.O
 Call More.Prompt
 Exit Sub
Get.Config:
 Option1=True
 Do
    VarX=VarX+1
    If VarX>Options.Lines Then
       Goto Next.Read
       Exit Do
    Endif
    Var$=Ltrim$(Rtrim$(Options.Array(VarX)))
    If Ucase$(Var$)="[CMD193]" 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$=Ltrim$(Rtrim$(Left$(Var$,Var-1)))
             Var3$=Ltrim$(Rtrim$(Mid$(Var$,Var+1)))
             Gosub Parse.Options
          Endif
       Loop
    Endif
 Loop
 Return
Next.Read:
 Close #TempFile1
 Filename$=DND.Path+"CMD193.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
          Option1=True
          Do
             If Eof(TempFile1) Then
                Exit Do
             Endif
             Line Input #TempFile1, Var$
             If Ucase$(Var$)="[END]" Then
                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
 Return
Parse.Options:
 Select Case Lcase$(Var2$)
 Case "allow.subject.search"
    Select Case Var3$
    Case "0", "false", "off"
       Option1=0
    End Select
 End Select
 Return
Error.Resume20:
 Exit Sub
Error.Trap20:
 Strng="Invalid date."
 Call IO.O
 Resume Error.Resume20
End Sub
