 Rem File: EditcmdF for Dndbbs Version v5.0a Release r2.0 Tweak t5.0a
 Rem $Include: 'edit.inc'

 On Error Goto ErrMain0
 If Chained2=False Then
    Call Open.Arrays
    Call Get.Config
    Call Increase.Files
    Call Make.FileNames
    Call Open.Files
    Call Reset.Cursor
    Call Detect.Share
    Call Save.Screen2(0)
    Call Passwrd9(Var,"f")
    If Var=False Then
       Call Terminate.Program
       End
    Endif
 Endif
 Call Edit.Counter
 Close
 Call Clear.Status.Line
 If Chained2 Then
    Chain DND.Path+"EDIT.EXE"
 Endif
 Call Terminate.Program
MainExit0:
 End
ErrMain0:
 Resume MainExit0

Sub Edit.Counter
 On Local Error Goto ErrMain0d
 Call Edit.Status.Line
 Close #TempFile1
 FileName=Usage.FileName
 Open FileName For Random Shared As #TempFile1 Len=26
 ' check length of usage file
 If Lof(TempFile1)=0 Then
    Field #TempFile1,26 As S$
    Lset S$="DND Usage File v"+Version$+Chr$(13)+Chr$(10)+Chr$(26) ' append eol
    Put #TempFile1,1
 Endif
 ' reset usage file
 Field #TempFile1,10 As D$, 8 As T$, 8 As X$
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Usage Edit v"+Left$(Version$,4)+" menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(625,"[1]")+"Display runs\pack counters"
       Call IO.O
       Strng=RT$(626,"[2]")+"Increase runs counter"
       Call IO.O
       Strng=RT$(627,"[3]")+"Reset runs date\time"
       Call IO.O
       Strng=RT$(628,"[4]")+"Clear runs counter"
       Call IO.O
       Strng=RT$(629,"[5]")+"Reset pack date\time"
       Call IO.O
       Strng=RT$(630,"[6]")+"Clear pack counter"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(631,"[7]")+"Print runs counter"
          Call IO.O
       Endif
    Endif
    Graphics.Off=False
    If Local.Mode=False Then
       Strng="Enter usage debug selection(1-6, Q to quit)? "
    Else
       Strng="Enter usage debug selection(1-7, Q to quit)? "
    Endif
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "1"
       If RT$(625,"[1]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          Get #TempFile1,2
          X#=Cvd(X$)
          Graphics.Off=True
          Strng="Last run date: "+D$+" "+T$+"."
          Call IO.O
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Get #TempFile1,3
          Y#=Cvd(X$)
          Strng="Last pack date: "+D$+" "+T$+". Packs:"+Str$(Y#)+"."
          Call IO.O
          Call Amount2(X#,Var$)
          Strng="Run number"+Var$+". Runmode: "+RunMode$+" ("+YearRelease$+")"
          Call IO.O
          Call More.Prompt
       Endif
    Case "2"
       If RT$(626,"[2]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Enter runs counter?"
          Call IO.I
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          X#=Int(Val(Out2)+.5)
          Get #TempFile1,2
          Lset D$=DateS$
          Lset T$=Format$(Now,"hh:mm:ss")
          Lset X$=Mkd$(X#)
          Put #TempFile1,2
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Call More.Prompt
       Endif
    Case "3"
       If RT$(627,"[3]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          Get #TempFile1,2
          Lset D$="01-01-1980"
          Lset T$="00:00:00"
          Put #TempFile1,2
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Graphics.Off=True
          Strng="Run date\time cleared."
          Call IO.O
          Call More.Prompt
       Endif
    Case "4"
       If RT$(628,"[4]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          Get #TempFile1,2
          Lset X$=Mkd$(0)
          Put #TempFile1,2
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Graphics.Off=True
          Strng="Run number cleared."
          Call IO.O
          Call More.Prompt
       Endif
    Case "5"
       If RT$(629,"[5]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Get #TempFile1,3
          Lset D$="01-01-1980"
          Lset T$="00:00:00"
          Put #TempFile1,3
          Graphics.Off=True
          Strng="Pack date\time reset."
          Call IO.O
          Call More.Prompt
       Endif
    Case "6"
       If RT$(630,"[6]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Lof(TempFile1)/26<2 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,2
          Endif
          If Lof(TempFile1)/26<3 Then
             Lset D$=DateS$
             Lset T$=Format$(Now,"hh:mm:ss")
             Lset X$=Mkd$(0#)
             Put #TempFile1,3
          Endif
          Get #TempFile1,3
          Lset X$=Mkd$(0#)
          Put #TempFile1,3
          Graphics.Off=True
          Strng="Pack counter reset."
          Call IO.O
          Call More.Prompt
       Endif
    Case "7"
       If RT$(631,"[7]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          If Local.Mode Then
             Strng="Printer port(1-3)? "
             Call IO.I
             VarP=Int(Val(Out2)+.5)
             If VarP>=1 And VarP<=3 Then
                Close #TempFile2
                VarP$="LPT"+Mid$(Str$(VarP),2)+":"
                Open VarP$ For Output As #TempFile2
                If Lof(TempFile1)/26<2 Then
                   Lset D$=DateS$
                   Lset T$=Format$(Now,"hh:mm:ss")
                   Lset X$=Mkd$(0#)
                   Put #TempFile1,2
                Endif
                Get #TempFile1,2
                X#=Cvd(X$)
                Graphics.Off=True
                Strng="Last run date: "+D$+" "+T$+"."
                Print #TempFile2,Strng
                If Lof(TempFile1)/26<3 Then
                   Lset D$=DateS$
                   Lset T$=Format$(Now,"hh:mm:ss")
                   Lset X$=Mkd$(0#)
                   Put #TempFile1,3
                Endif
                Get #TempFile1,3
                Y#=Cvd(X$)
                Strng="Last pack date: "+D$+" "+T$+". Packs:"+Str$(Y#)+"."
                Print #TempFile2,Strng
                Call Amount2(X#,Var$)
                Strng="Run number"+Var$+". Runmode: "+RunMode$+" ("+YearRelease$+")"
                Print #TempFile2,Strng
                Print #TempFile2,Chr$(12);
             Endif
          Endif
          Close #TempFile2
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
MainExit0d:
 Exit Sub
ErrMain0d:
 Data.Error=Err
 If Data.Error=6 Then
    Print "Overflow."
 Else
    Print "Error: ";Err
 Endif
 Resume MainExit0d
End Sub

Sub Amount(Var#,Var$)
 If Instr(Str$(Var#),"D") Then
    Var$=Str$(Var#)
 Else
    Var$=" "+Form$(Var#)
 Endif
End Sub

Sub Amount2(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
