 Rem File: EditcmdE for Dndbbs Version v5.0a Release r2.0
 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,"e")
    If Var=False Then
       Call Terminate.Program
       End
    Endif
 Endif
 Call Edit.Profile
MainExit0:
 End
ErrMain0:
 Resume MainExit0
 End

Sub Edit.Profile
 On Local Error Goto ErrMain0c
 Call Edit.Status.Line
 If Lof(SicFile)=SFalse Then
    Call Add.Profile
 Endif
 Do While Lost.Carrier=False
    If TempC=False Then
       Graphics.Off=False
       Strng="Profile Edit utility v"+Left$(Version$,4)+" menu:"
       Call IO.O
       Graphics.Off=True
       Strng=RT$(606,"[A]")+"dd"
       Call IO.O
       Strng=RT$(607,"[C]")+"hange"
       Call IO.O
       Strng=RT$(608,"[L]")+"ist"
       Call IO.O
       If Local.Mode Then
          Strng=RT$(619,"[P]")+"rint"
          Call IO.O
       Endif
       Strng=RT$(609,"[S]")+"ort"
       Call IO.O
       Graphics.Off=False
    Endif
    Strng="SIC account edit option(q to quit)? "
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(606,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Add.Profile
          Temp5!=Lof(SicFile)/UserProfileRecLen
          Call Modify.Profile
       Endif
    Case "C"
       If RT$(607,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Find.Profile
          If Temp5! Then
             Call Modify.Profile
          Endif
       Endif
    Case "L"
       If RT$(608,"[L]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Show.Profiles
       Endif
    Case "P"
       If Local.Mode Then
          If RT$(619,"[P]")="[*]" Then
             Strng="Command restricted.."
             Call IO.O
          Else
             Call Print.Profiles
          Endif
       Endif
    Case "S"
       If RT$(609,"[S]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Call Sort.Profiles
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Close
 Call Clear.Status.Line
 If Chained2 Then
    Chain DND.Path+"EDIT.EXE"
 Endif
 Call Terminate.Program
MainExit0c:
 Exit Sub
ErrMain0c:
 Resume MainExit0c
End Sub

Sub Add.Profile
 On Local Error Goto ErrResume143
 Temp5!=Lof(SicFile)/UserProfileRecLen+1!
 Strng=None$
 Call Cryptograph(Strng)
 UserProfile.PassWord=Strng
 UserProfile.Account=Nul
 UserProfile.AccountLogin=None$
 UserProfile.Group=Nul
 UserProfile.GroupLogin=None$
 UserProfile.Library=Nul
 UserProfile.LibraryLogin=None$
 UserProfile.MaxRecords=10!
 UserProfile.TimeLimit=60!
 UserProfile.PrinterSelect=False
 UserProfile.TimeUsed=SFalse
 UserProfile.LastMonth=False
 UserProfile.MaxRuntime=6!
 For Temp=1 To MaxProfiles
    UserProfile.Commands(Temp)=False
 Next
 Filename=DND.Path+"profile.dat"
 If Dir$(Filename)<>Nul Then
    Close #TempFile1
    Open Filename For Input As #TempFile1
    For Temp=1 To MaxProfiles
       If Eof(TempFile1) Then
          Exit For
       Endif
       Input #TempFile1,TempC$,Temp2
       UserProfile.Commands(Temp)=Temp2
    Next
 Endif
 Call Write.Record(SicFile,Temp5!)
ErrExit143:
 Exit Sub
ErrResume143:
 Resume ErrExit143
End Sub

Sub Find.Profile
 On Local Error Goto ErrResume144
 Temp5!=SFalse
 Graphics.Off=False
 Strng="SIC account, or number"
 Strng=Strng+"(1-"+Mid$(Str$(Lof(SicFile)/UserProfileRecLen),2)+")? "
 No.Input.Out="1"
 Call IO.I
 Var2!=Int(Val(Out2))
 If Var2!>SFalse And Var2!<=Lof(SicFile)/UserProfileRecLen Then
    Call Read.Record(SicFile,Var2!)
    No.Input=True
    Temp5!=Var2!
    Exit Sub
 Endif
 Temp7!=SFalse
 Out2=Lcase$(Out2)
 If Instr(Out2,"#") Then
    Temp7!=Val(Mid$(Out2,Instr(Out2,"#")+1))
    Out2=Left$(Out2,Instr(Out2,"#")-1)
 Endif
 TempX!=SFalse
 No.Input=False
 For Var2!=1! To Lof(SicFile)/UserProfileRecLen
    Call Read.Record(SicFile,Var2!)
    Strng=Lcase$(Rtrim$(UserProfile.AccountLogin))
    Var3$=Out2
    Call InstrSUB4(VarX,Var3$,0)
    If VarX Then
       TempX!=TempX!+1!
       If Temp7!=SFalse Or TempX!=Temp7! Then
	  No.Input=True
	  Exit For
       Endif
    Endif
 Next
 If No.Input=False Then
    Strng="SIC account not found."
    Call IO.O
    Exit Sub
 Endif
 Temp5!=Var2!
ErrExit144:
 Exit Sub
ErrResume144:
 Resume ErrExit144
End Sub

Sub Modify.Profile
 On Local Error Goto ErrResume145
 Call Read.Record(SicFile,Temp5!)
 Do While Lost.Carrier=False
    Allow.Break=True
    Break=False
    For VarQ=1 To 9
       Call Display.Profile(True,VarQ)
       If Break Then
	  Exit For
       Endif
    Next
    Allow.Break=False
    Strng="SIC account change option(q to quit)? "
    Graphics.Off=False
    Line.Length=TempD
    No.Input.Out="Q"
    Call IO.I
    Select Case Ucase$(Out2)
    Case "A"
       If RT$(610,"[A]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Account login? "
          Call IO.I
          If Out2<>Nul Then
             Out2=Ucase$(Out2)
             Call Valid(Out2,8)
             If Out2=Nul Then
                Strng="Illegal characters in account."
                Call IO.O
             Else
                Out3=Out2
                Strng="Account directory? "
                Call IO.I
                If Out2<>Nul Then
                   Out2=Ucase$(Out2)
                   Call Valid(Out2,8)
                   If Out2=Nul Then
                      Strng="Illegal characters in directory."
                      Call IO.O
                   Else
                      UserProfile.AccountLogin=Out3
                      UserProfile.Account=Rtrim$(Out2)
                   Endif
                Endif
             Endif
          Endif
       Endif
    Case "B"
       If RT$(611,"[B]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Hidden=True
          Strng="Enter password? "
          Call IO.I
          Hidden=False
          Out3=Ucase$(Out2)
          Call Cryptograph(Out3)
          Hidden=True
          Strng="Enter password again? "
          Call IO.I
          Hidden=False
          Out2=Ucase$(Out2)
          Call Cryptograph(Out2)
          If Len(Out2)<>8 Or Len(Out3)<>8 Then
             Strng="Password must be eight characters."
             Call IO.O
          Else
             If Out2<>Out3 Then
                Strng="Passwords don't match!"
                Call IO.O
             Else
                UserProfile.PassWord=Out3
                Strng="Password changed."
                Call IO.O
             Endif
          Endif
       Endif
    Case "C"
       If RT$(612,"[C]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Group login? "
          Call IO.I
          If Out2<>Nul Then
             Out2=Ucase$(Out2)
             Call Valid(Out2,8)
             If Out2=Nul Then
                Strng="Illegal characters in group."
                Call IO.O
             Else
                Out3=Out2
                Strng="Group directory? "
                Call IO.I
                If Out2<>Nul Then
                   Out2=Ucase$(Out2)
                   Call Valid(Out2,8)
                   If Out2=Nul Then
                      Strng="Illegal characters in directory."
                      Call IO.O
                   Else
                      UserProfile.GroupLogin=Out3
                      UserProfile.Group=Rtrim$(Out2)
                   Endif
                Endif
             Endif
          Endif
       Endif
    Case "D"
       If RT$(613,"[D]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Library login? "
          Call IO.I
          If Out2<>Nul Then
             Out2=Ucase$(Out2)
             Call Valid(Out2,8)
             If Out2=Nul Then
                Strng="Illegal characters in library."
                Call IO.O
             Else
                Out3=Out2
                Strng="Library directory? "
                Call IO.I
                If Out2<>Nul Then
                   Out2=Ucase$(Out2)
                   Call Valid(Out2,8)
                   If Out2=Nul Then
                      Strng="Illegal characters in directory."
                      Call IO.O
                   Else
                      UserProfile.LibraryLogin=Out3
                      UserProfile.Library=Rtrim$(Out2)
                   Endif
                Endif
             Endif
          Endif
       Endif
    Case "E"
       If RT$(614,"[E]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Max. records(1-32767)? "
          No.Input.Out="10"
          Call IO.I
          Temp3!=Int(Val(Out2))
          If Temp3!>0! And Temp3!<=32767! Then
             UserProfile.MaxRecords=Temp3!
          Endif
       Endif
    Case "F"
       If RT$(615,"[F]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Monthly time limit in minutes(0=<unlimited>)? "
          No.Input.Out="10"
          Call IO.I
          Temp!=Int(Val(Out2))
          If Temp!>=0! Then
             UserProfile.TimeLimit=Temp!
             UserProfile.TimeUsed=0!
             d1$=format$(now,"mm-dd-yyyy")
             UserProfile.LastMonth = VAL(LEFT$(d1$, 2))
          Endif
       Endif
    Case "G"
       If RT$(616,"[G]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Allow printer select(y/n)? "
          No.Input.Out="N"
          Call IO.I
          UserProfile.PrinterSelect=Yes
       Endif
    Case "H"
       If RT$(617,"[H]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
          Strng="Max. program runtime in minutes(0=<unlimited>)? "
          No.Input.Out="10"
          Call IO.I
          Temp!=Int(Val(Out2))
          If Temp!>=0! Then
             UserProfile.MaxRuntime=Temp!
          Endif
       Endif
    Case "I"
       If RT$(618,"[I]")="[*]" Then
          Strng="Command restricted.."
          Call IO.O
       Else
       Filename=DND.Path+"profile.dat"
       If Dir$(Filename)=Nul Then
          Strng="Error reading profile.dat. Run 'Dndutil /w1'"
          Call IO.O
       Else
          Do While Lost.Carrier=False
             Graphics.Off=True
             If TempC=False Then
                Strng=RT$(620,"[C]")+"hange"
                Call IO.O
                Strng=RT$(621,"[D]")+"isable all"
                Call IO.O
                Strng=RT$(622,"[E]")+"nable all"
                Call IO.O
                Strng=RT$(623,"[L]")+"ist"
                Call IO.O
                Strng=RT$(624,"[R]")+"eset defaults"
                Call IO.O
                Graphics.Off=False
             Endif
             Strng="SIC command restriction edit option(q to quit)? "
             Line.Length=TempD
             No.Input.Out="Q"
             Call IO.I
             Select Case Ucase$(Out2)
             Case "C"
                If RT$(620,"[C]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   Strng="Enter command:"
                   Call IO.I
                   Out2=Ucase$(Out2)
                   If Len(Out2) Then
                      Close #TempFile1
                      Filename=DND.Path+"profile.dat"
                      If Dir$(Filename)<>Nul Then
                         Open Filename For Input As #TempFile1
                         Temp3=False
                         For Temp1=1 To MaxProfiles
                            If Eof(TempFile1) Then
                               Exit For
                            Endif
                            Input #TempFile1,Var$,Temp2
                            If Var$=Out2 Then
                               Temp3=True
                               Do While Lost.Carrier=False
                                  If TempC=False Then
                                     Graphics.Off=False
                                     Strng="Command restriction menu:"
                                     If UserProfile.Commands(Temp1)=True Then
                                        Strng=Strng+" (enabled)"
                                     Else
                                        Strng=Strng+" (disabled)"
                                     Endif
                                     Call IO.O
                                     Graphics.Off=True
                                     Strng=" (1)enable"
                                     Call IO.O
                                     Strng=" (2)disable"
                                     Call IO.O
                                     Strng=" (3)toggle"
                                     Call IO.O
                                     Strng=" (4)exit"
                                     Call IO.O
                                  Endif
                                  Graphics.Off=False
                                  Line.Length=TempD
                                  No.Input.Out="4"
                                  Strng="Enter option(1-4)? "
                                  Call IO.I
                                  Select Case Int(Val(Out2))
                                  Case 1
                                     UserProfile.Commands(Temp1)=True
                                     Strng="Command enabled."
                                     Call IO.O
                                  Case 2
                                     UserProfile.Commands(Temp1)=False
                                     Strng="Command disabled."
                                     Call IO.O
                                  Case 3
                                     V = UserProfile.Commands(Temp1)
                                     If V = -1 Then V = 0 Else V = -1
                                     UserProfile.Commands(Temp1)=V
                                     If V Then Strng="Command enabled."
                                     If V = 0 Then Strng="Command disabled."
                                     Call IO.O
                                  Case 4
                                     Exit For
                                  End Select
                               Loop
                            Endif
                         Next
                      Endif
                      If Temp3=False Then
                         Strng="Command not found."
                         Call IO.O
                      Endif
                   Endif
                Endif
             Case "D"
                If RT$(621,"[D]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   For Temp1=1 To MaxProfiles
                      UserProfile.Commands(Temp1)=False
                   Next
                   Strng="All commands disabled."
                   Call IO.O
                Endif
             Case "E"
                If RT$(622,"[E]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   For Temp1=1 To MaxProfiles
                      UserProfile.Commands(Temp1)=True
                   Next
                   Strng="All commands enabled."
                   Call IO.O
                Endif
             Case "L"
                If RT$(623,"[L]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   Call Display.Limits
                   Call More.Prompt
                   Allow.Break=True
                   Break=False
                   Continuous=False
                   Graphics.Off=True
                   VarZ=False
                   Close #TempFile1
                   Filename=DND.Path+"profile.dat"
                   If Dir$(Filename)<>Nul Then
                      Open Filename For Input As #TempFile1
                      For Temp1=1 To MaxProfiles
                         If Eof(TempFile1) Then
                            Exit For
                         Endif
                         Input #TempFile1,Var$,Temp2
                         Var$=Ltrim$(Str$(Temp1))+". "+Var$
                         If UserProfile.Commands(Temp1)=True Then
                            Strng=Var$+": enabled."
                         Else
                            If UserProfile.Commands(Temp1)=False Then
                               Strng=Var$+": disabled."
                            Else
                               Strng=Var$+": (error)."
                            Endif
                         Endif
                         Call IO.O
                         VarZ=VarZ+1
                         If Break Then
                            Exit For
                         Endif
                         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
                      Next
                      Allow.Break=False
                      If VarZ Then
                         Call More.Prompt
                      Endif
                   Endif
                Endif
             Case "R"
                If RT$(624,"[R]")="[*]" Then
                   Strng="Command restricted.."
                   Call IO.O
                Else
                   For Temp=1 To MaxProfiles
                      UserProfile.Commands(Temp)=False
                   Next
                   Filename=DND.Path+"profile.dat"
                   If Dir$(Filename)<>Nul Then
                      Close #TempFile1
                      Open Filename For Input As #TempFile1
                      For Temp=1 To MaxProfiles
                         If Eof(TempFile1) Then
                            Exit For
                         Endif
                         Input #TempFile1,TempC$,Temp2
                         UserProfile.Commands(Temp)=Temp2
                      Next
                      Strng="All commands reset."
                      Call IO.O
                   Else
                      Strng="Error reading profile."
                      Call IO.O
                   Endif
                Endif
             Case "Q"
                Exit Do
             End Select
          Loop
       Endif
       Endif
    Case "Q"
       Exit Do
    End Select
 Loop
 Call Write.Record(SicFile,Temp5!)
 Strng="SIC account modified."
 Call IO.O
ErrExit145:
 Exit Sub
ErrResume145:
 Resume ErrExit145
End Sub

Sub Show.Profiles
 On Local Error Goto ErrResume146
 Temp3!=Lof(SicFile)/UserProfileRecLen
 Call Get.Record.Range(Temp!,Temp2!,Temp3!)
 Allow.Break=True
 Break=False
 Continuous=False
 For Temp5!=Temp! To Temp2!
    Call Read.Record(SicFile,Temp5!)
    For VarQ=1 To 8
       Call Display.Profile(False,VarQ)
       If Break Then
	  Exit For
       Endif
    Next
    If Break Then
       Exit For
    Endif
    Call Display.Limits
    If Continuous=False Then
       Call More.Prompt
       If No Or Quit Then
	  Exit For
       Endif
    Endif
 Next
 Allow.Break=False
 Break=False
ErrExit146:
 Exit Sub
ErrResume146:
 Resume ErrExit146
End Sub

SUB Display.Limits
 On Local Error Goto ErrResume146x
 Var$ = Nul
 FOR Var1 = 1 TO MaxProfiles
    IF UserProfile.Commands(Var1) THEN
       Var$ = Var$ + "1"
    ELSE
       Var$ = Var$ + "0"
    END IF
 NEXT
 DO
    Var2$ = LEFT$(Var$, 4)
    Var$ = MID$(Var$, 5)
    IF LEN(Var2$) < 4 THEN
       Var2$ = Var2$ + STRING$(4 - LEN(Var2$), "1")
    END IF
    Var = False
    IF MID$(Var2$, 4, 1) = "1" THEN
       Var = Var + 1
    END IF
    IF MID$(Var2$, 3, 1) = "1" THEN
       Var = Var + 2
    END IF
    IF MID$(Var2$, 2, 1) = "1" THEN
       Var = Var + 4
    END IF
    IF MID$(Var2$, 1, 1) = "1" THEN
       Var = Var + 8
    END IF
    Var3$ = Var3$ + HEX$(Var)
    IF Var$ = Nul THEN
       EXIT DO
    END IF
 LOOP
 Strng = "Account limits value:"
 CALL IO.O
 Strng = Var3$
 CALL IO.O
ErrExit146x:
 Exit Sub
ErrResume146x:
 Resume ErrExit146x
End Sub

Sub Print.Profiles
 On Local Error Goto ErrResume146a
 Strng="Printer port(1-3)? "
 Call IO.I
 VarP=Int(Val(Out2))
 If VarP>=1 And VarP<=3 Then
    Close #TempFile1
    VarP$="LPT"+Mid$(Str$(VarP),2)+":"
    Open VarP$ For Output As #TempFile1
    Temp3!=Lof(SicFile)/UserProfileRecLen
    Call Get.Record.Range(Temp!,Temp2!,Temp3!)
    For Temp5!=Temp! To Temp2!
       Call Read.Record(SicFile,Temp5!)
       For VarQ=1 To 8
          Call Print.Profile(VarQ)
       Next
       Print #TempFile1,Chr$(12);
    Next
 Endif
ErrExit146a:
 Close #TempFile1
 Exit Sub
ErrResume146a:
 Resume ErrExit146a
End Sub

Sub Display.Profile(TempX,Var)
 On Local Error Goto ErrResume147
 If TempX Then
    If TempC Then
       Exit Sub
    Endif
 Endif
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="SIC account number"+Str$(Temp5!)+":"
 Call IO.O
 Graphics.Off=True
 Case 2
 Strng=Nul
 If TempX Then
    Strng=RT$(610,"[A]")
 Endif
 Out2=UserProfile.AccountLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Catalog account: "+Out2+", "
 Out2=UserProfile.Account
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Strng=Strng+"Directory: "+Out2
 If TempX Then
    Strng=Strng+" "+RT$(611,"[B]")+"Password: "+String$(8,Mask$)
 Endif
 Call IO.O
 Case 3
 Strng=Nul
 If TempX Then
    Strng=RT$(612,"[C]")
 Endif
 Out2=UserProfile.GroupLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Group account: "+Out2+", "
 Out2=UserProfile.Group
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Strng=Strng+"Directory: "+Out2
 Call IO.O
 Case 4
 Strng=Nul
 If TempX Then
    Strng=RT$(613,"[D]")
 Endif
 Out2=UserProfile.LibraryLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Library account: "+Out2+", "
 Out2=UserProfile.Library
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Strng=Strng+"Directory: "+Out2
 Call IO.O
 Case 5
 Strng=Nul
 If TempX Then
    Strng=RT$(614,"[E]")
 Endif
 Strng=Strng+"Max. records: "+Form$(Cdbl(UserProfile.MaxRecords))+" KB."
 Call IO.O
 Case 6
 Strng=Nul
 If TempX Then
    Strng=RT$(615,"[F]")
 Endif
 Strng=Strng+"Monthly time limit: "
 Var2=UserProfile.TimeLimit
 Select Case Var2
 Case 0!
    Strng=Strng+"<unlimited>"
 Case 1!
    Strng=Strng+"1 minute."
 Case ELSE
    Strng=Strng+Form$(Cdbl(Var2))+" minutes."
 END Select
 Call IO.O
 Case 7
 Strng=Nul
 If TempX Then
    Strng=RT$(616,"[G]")
 Endif
 Strng=Strng+"Printer select: "
 If UserProfile.PrinterSelect Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Call IO.O
 Case 8
 Strng=Nul
 If TempX Then
    Strng=RT$(617,"[H]")
 Endif
 Strng=Strng+"Max. program runtime: "
 Var2=UserProfile.MaxRuntime
 Select Case Var2
 Case 0!
    Strng=Strng+"<unlimited>"
 Case 1!
    Strng=Strng+"1 minute."
 Case ELSE
    Strng=Strng+Form$(Cdbl(Var2))+" minutes."
 END Select
 Call IO.O
 Case 9
 Strng=Nul
 If TempX Then
    Strng=RT$(618,"[I]")
 Endif
 Strng=Strng+"Command restrictions"
 Call IO.O
 End Select
ErrExit147:
 Exit Sub
ErrResume147:
 Resume ErrExit147
End Sub

Sub Print.Profile(Var)
 On Local Error Goto ErrResume147a
 Select Case Var
 Case 1
 Graphics.Off=False
 Strng="SIC account number"+Str$(Temp5!)+":"
 Print #TempFile1,Strng
 Graphics.Off=True
 Case 2
 Strng=Nul
 Out2=UserProfile.AccountLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Catalog account: "+Out2
 Out2=UserProfile.Account
 Out2=Rtrim$(Out2)
 Out2=Ucase$(Out2)
 Strng=Strng+", Directory: "+Out2
 Print #TempFile1,Strng
 Case 3
 Strng=Nul
 Out2=UserProfile.GroupLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Group account: "+Out2
 Out2=UserProfile.Group
 Out2=Rtrim$(Out2)
 Out2=Ucase$(Out2)
 Strng=Strng+", Directory: "+Out2
 Print #TempFile1,Strng
 Case 4
 Strng=Nul
 Out2=UserProfile.LibraryLogin
 Out2=Rtrim$(Out2)
 Out2=Lcase$(Out2)
 Mid$(Out2,1,1)=Ucase$(Mid$(Out2,1,1))
 Strng=Strng+"Library account: "+Out2
 Out2=UserProfile.Library
 Out2=Rtrim$(Out2)
 Out2=Ucase$(Out2)
 Strng=Strng+", Directory: "+Out2
 Print #TempFile1,Strng
 Case 5
 Strng=Nul
 Strng=Strng+"Max. records: "+Form$(Cdbl(UserProfile.MaxRecords))+" KB."
 Print #TempFile1,Strng
 Case 6
 Strng=Nul
 Strng=Strng+"Monthly time limit: "
 Var2=UserProfile.TimeLimit
 Select Case Var2
 Case 0!
    Strng=Strng+"<unlimited>"
 Case 1!
    Strng=Strng+"1 minute."
 Case ELSE
    Strng=Strng+Form$(Cdbl(Var2))+" minutes."
 END Select
 Print #TempFile1,Strng
 Case 7
 Strng=Nul
 Strng=Strng+"Printer select: "
 If UserProfile.PrinterSelect Then
    Strng=Strng+"Yes"
 Else
    Strng=Strng+"No"
 Endif
 Print #TempFile1,Strng
 Case 8
 Strng=Nul
 Strng=Strng+"Max. program runtime: "
 Var2=UserProfile.MaxRuntime
 Select Case Var2
 Case 0!
    Strng=Strng+"<unlimited>"
 Case 1!
    Strng=Strng+"1 minute."
 Case ELSE
    Strng=Strng+Form$(Cdbl(Var2))+" minutes."
 END Select
 Print #TempFile1,Strng
 Case 9
 Strng=Nul
 Strng=Strng+"Command restrictions"
 Print #TempFile1,Strng
 End Select
ErrExit147a:
 Exit Sub
ErrResume147a:
 Resume ErrExit147a
End Sub

Sub Sort.Profiles
 On Local Error Goto ErrResume147b
 Dim UserProfile2 As SicUserType
 Call Search.Mess2(Var2)
 If Var2 Then
    Strng="Can't sort while node/user online."
    Call IO.O
    Exit Sub
 Endif
 Strng="Sort profiles(y/n)? "
 Line.Length=TempD
 No.Input.Out="Y"
 Call IO.I
 If Yes Then
    Do While Lost.Carrier=False
       If TempC=False Then
          Graphics.Off=False
          Strng="Sort order menu:"
          Call IO.O
          Graphics.Off=True
          Strng=" (1)ascending"
          Call IO.O
          Strng=" (2)descending"
          Call IO.O
          Strng=" (3)exit"
          Call IO.O
       Endif
       Graphics.Off=False
       Line.Length=TempD
       No.Input.Out="3"
       Strng="Enter sort option(1-3)? "
       Call IO.I
       SortZ=Int(Val(Out2))
       If SortZ>=1 And SortZ<=2 Then
          Exit Do
       Endif
       If SortZ=3 Then Exit Sub
    Loop
    If SortZ Then
       Graphics.Off=True
       Carriage.Return=True
       Strng="Making backup of profiles file"
       Call IO.O
       FileName=Data.Path1+"ACCOUNTS.BAK"
       Close #TempFile1
       If Dir$(FileName)<>Nul Then
          Kill FileName
       Endif
       Open FileName For Random Shared As #TempFile1 Len=UserProfileRecLen
       VarD=False
       VarE=False
       VarF!=Timeit!
       For Temp3!=1! To Lof(SicFile)/UserProfileRecLen
          Call Read.Record(SicFile,Temp3!)
          Call Write.TempFile(10,Temp3!)
          Call Dot.Display(VarD,VarE,VarF!)
       Next
       Call IO.O
       Graphics.Off=True
       Carriage.Return=True
       Strng="Sorting profiles file"
       Call IO.O
       VarD=False
       VarE=False
       VarF!=Timeit!
       For Temp3!=1! To Lof(SicFile)/UserProfileRecLen-1!
          For Temp4!=Temp3!+1! To Lof(SicFile)/UserProfileRecLen
             Call Dot.Display(VarD,VarE,VarF!)
             Call Read.Record(SicFile,Temp3!)
             UserProfile2=UserProfile
             Var$=UserProfile.AccountLogin
             Var$=Lcase$(Rtrim$(Var$))
             Call Read.Record(SicFile,Temp4!)
             Var2$=UserProfile.AccountLogin
             Var2$=Lcase$(Rtrim$(Var2$))
             If SortZ=1 Then
                If Var$>Var2$ Then
                   Call Write.Record(SicFile,Temp3!)
                   UserProfile=UserProfile2
                   Call Write.Record(SicFile,Temp4!)
                Endif
             Endif
             If SortZ=2 Then
                If Var$<Var2$ Then
                   Call Write.Record(SicFile,Temp3!)
                   UserProfile=UserProfile2
                   Call Write.Record(SicFile,Temp4!)
                Endif
             Endif
          Next
       Next
       Call IO.O
       Strng="Profile file sorted."
       Call IO.O
       Call More.Prompt
    Endif
 Endif
 Exit Sub
ErrExit147b:
 Exit Sub
ErrResume147b:
 Resume ErrExit147b
End Sub
