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

Sub Read.Help2
 On Local Error Goto ErrorTrp37
 Dim Quote2 As String*1
 Quote2=Chr$(34)
 Temp$=Stored.Parsed.Command1
 Var=TempX
 If Var>1 Then ' ?..
    Var=Var-1
    Call DisplayCats(Var)
    Exit Sub
 Endif
 If Var<True Then ' -2, -3, -4
    Var=Abs(Var)
    Select Case Var
    Case 2
       Call Display.Cat6
    Case 3
       Call Display.Cat7
    Case 4
       Call Display.Cat8
    End Select
    Exit Sub
 Endif
 If Var=True Then
    Temp$=Stored.Parsed.Command1
    Select Case Ucase$(Temp$)
    Case "DMCOMMANDS"
       Eat$ = Nul
    Case "DUNGEONMASTER"
       Eat$ = Nul
    Case Else
       If Left$(Temp$,Len(Config3(9)))<>Config3(9) Then
          Strng="Enter DM command, form: "+Config3(9)+"Help "+Config3(9)+"<command>"
          Call IO.O
          Strng="Also type "+Quote2+Config3(9)+"help dmcommands"+Quote2+" for additional "+Config3(9)+"help."
          Call IO.O
          Strng="For further help type "+Quote2+Config3(9)+"help dungeonmaster"+Quote2+"."
          Call IO.O
          Exit Sub
       Endif
       Temp$=Mid$(Temp$,Len(Config3(9))+1)
       Stored.Parsed.Command1=Temp$
    End Select
 Endif
 If Var=UnTrue Then
    Strng="Enter topic keyword to search: "
    Call IO.I
    Temp$=Out2
    If Len(Temp$)=False Then
       Exit Sub
    Endif
 Endif
 Temp$=Left$(Temp$,15)
 Temp$=Rtrim$(Temp$)
 Temp$=Ucase$(Temp$)
 If Len(Temp$)=False Then
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="Searching for "+Quote2+Ucase$(Temp$)+Quote2
 Call IO.O
 Graphics.Off=True
 Select Case Var
 Case True
    FileName=DMhelp.Filename
 Case Else
    FileName=Help.Filename2
 End Select
 Close #HelpFile2
 Open FileName For Random Shared As #HelpFile2 Len=HelpRecLen2
 Temp=1
 Temp5=1
 Allow.Break=True
 Break=False
 Continuous=False
 No=False
 Quit=False
 TempX$=Nul
 Do While Lost.Carrier=False
    Allow.Break=True
    Temp=Temp+1
    Call Read.HelpFile(HelpFile2,Temp)
    Temp2$=HelpRecord2.CommandName
    Temp2$=Rtrim$(Temp2$)
    Out2=Temp$
    Out3=Temp2$
    Call InstrSUB2(VarX)
    If Var=True Then
       Eat$=Nul
    Else
       If Temp2$="DMHELP" Then
          If Temp$<>"DMHELP" Then
             VarX=False
          Endif
       Endif
    Endif
    If VarX Then
       If Debug.Mode Then
          If Temp2$<>TempX$ Then
             TempX$=Temp2$
             Strng="Topic: "+Temp2$
             Call IO.O
             Temp5=Temp5+1
          Endif
       Endif
       Graphics.Off=True
       Strng=HelpRecord2.Text
       Strng=Rtrim$(Strng)
       If Len(Strng) Then
          Var2$=ANSIPrefixChar
          If Len(Var2$) Then
             Var3$=Var2$+"MO"
             If Instr(Ucase$(Strng),Var3$) Then
                Temp5=False
             Endif
             Var3$=Var2$+"CS"
             If Instr(Ucase$(Strng),Var3$) Then
                Temp5=False
             Endif
          Endif
       Endif
       ' Call Convert.String
       Call Convert.ANSI(True,VarQ,VarR)
       If No Or Quit Then
          Exit Do
       Endif
       Graphics.On=True
       Call IO.O
       Graphics.On=False
       If Break Then
          Goto End.Display
       Endif
       Temp5=Temp5+1
       If Temp5>=User.Pagelength-2 Then
          Temp5=False
          If Continuous=False Then
             Call More.Prompt
             If No Or Quit Then
                Exit Do
             Endif
          Endif
       Endif
    Endif
    If Temp>=Lof(HelpFile2)/HelpRecLen2 Then
       Exit Do
    Endif
 Loop
 If Temp5 Then
    Call More.Prompt
 Endif
 Graphics.Off=False
 Strng="Finish help search."
 Call IO.O
End.Display:
 Allow.Break=False
 Break=False
ErrorRsm37:
 Exit Sub
ErrorTrp37:
 Resume ErrorRsm37
End Sub

Sub DisplayCats(Var)
 On Local Error Goto Err.Trp22a2
 Dim Quote2 As String*1
 Quote2=Chr$(34)
 Select Case Var
 Case 1
    Graphics.Off=True
    Strng="Type "+Quote2+"Hint"+Quote2+" or "+Quote2+"Help"+Quote2+" for short help on commands."
    Call IO.O
    Strng="Type "+Quote2+"Catalog"+Quote2+" or "+Quote2+"Commands"+Quote2+" for additional help on commands."
    Call IO.O
    Graphics.Off=False
 Case 2
    Call Display.Cat1
 Case 3
    Call Display.Cat2
 Case 4
    Call Display.Cat3
 Case 5
    If Normal.User=False Then
       Call Display.Cat4
    Else
       Strng="Probably not.."
       Call IO.O
    Endif
 Case 6
    If Normal.User=False Then
       Call Display.Cat5
    Else
       Strng="Probably not.."
       Call IO.O
    Endif
 Case Else
    Strng="Probably not.."
    Call IO.O
 End Select
Err.Rsm22a2:
 Exit Sub
Err.Trp22a2:
 Resume Err.Rsm22a2
End Sub

Sub Display.Cat1
 On Local Error Goto Err.Trp22a
 Redim Temp.ArrayS(1 To MaxUserCommands) As String
 VarZ=False
 For Var=1 To MaxUserCommands
    Call Read.Message.Record(MessWorkFile8,Var)
    Var$=UserCommandRecord.CommandSet(1)
    Var$=Rtrim$(Var$)
    Var$=Lcase$(Var$)
    If Var$="" Then
       Var$="<>"
    Endif
    If Var$<>"<>" Then
       Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
       VarZ=VarZ+1
       Temp.ArrayS(VarZ)=Var$
    Endif
 Next
 For VarS1=1 To VarZ
    For VarS2=VarS1+1 To VarZ
       If Temp.ArrayS(VarS1)>Temp.ArrayS(VarS2) Then
          Swap Temp.ArrayS(VarS1),Temp.ArrayS(VarS2)
       Endif
    Next
 Next
 Var2=False
 Var3=1
 Var2$=Nul
 Allow.Break=True
 Break=False
 Graphics.Off=False
 Strng="Catalog of commands."
 Call IO.O
 Graphics.Off=True
 For Var=1 To MaxUserCommands
    Var$=Temp.ArrayS(Var)
    Var$=Rtrim$(Var$)
    If Var$=Nul Then
       Exit For
    Endif
    Var2=Var2+1
    If Var2<5 Then
       Var2$=Var2$+Var$+Space$(15-Len(Var$))
    Else
       Var2$=Var2$+Var$
    Endif
    If Var2=5 Then
       Var2=False
       Strng=Var2$
       Var2$=Nul
       Call IO.O
       If Break Then
          Var2$=Nul
          Exit For
       Endif
       Var3=Var3+1
       If Var3>=User.PageLength-2 Then
          Var3=False
          Call More.Prompt
          If No Or Quit Then
             Exit For
          Endif
       Endif
    Endif
 Next
 Allow.Break=False
 Break=False
 If Len(Var2$) Then
    Strng=Rtrim$(Var2$)
    Call IO.O
    Call More.Prompt
 Endif
Err.Rsm22a:
 Exit Sub
Err.Trp22a:
 Resume Err.Rsm22a
End Sub

Sub Display.Cat2
 On Local Error Goto Err.Trp22a1
 Redim Temp.ArrayS(1 To MaxUserCommands) As String
 VarZ=False
 For Var=1 To MaxUserCommands
    Call Read.Message.Record(MessWorkFile8,Var)
    Var$=UserCommandRecord.CommandSet(1)
    Var$=Rtrim$(Var$)
    Var$=Lcase$(Var$)
    If Var$="" Then
       Var$="<>"
    Endif
    If Var$<>"<>" Then
       Mid$(Var$,1,1)=Ucase$(Mid$(Var$,1,1))
       Select Case UserCommandRecord.CommandParam
       Case 1
          Var$=Var$+"<>"
       Case 2
          Var$=Var$+"<><>"
       Case 3
          Var$=Var$+"<><><>"
       End Select
       Var2$=UserCommandRecord.CommandSet(2)
       Var2$=Rtrim$(Var2$)
       Var2$=Lcase$(Var2$)
       If Var2$="" Then
          Var2$="<>"
       Endif
       If Var2$<>"<>" Then
          Mid$(Var2$,1,1)=Ucase$(Mid$(Var2$,1,1))
          Var2$="("+Var2$+")"
       Else
          Var2$=Nul
       Endif
       Var3$=UserCommandRecord.CommandSet(3)
       Var3$=Rtrim$(Var3$)
       Var3$=Lcase$(Var3$)
       If Var3$="" Then
          Var3$="<>"
       Endif
       If Var3$<>"<>" Then
          Mid$(Var3$,1,1)=Ucase$(Mid$(Var3$,1,1))
          Var3$="("+Var3$+")"
       Else
          Var3$=Nul
       Endif
       If Var2$<>Nul Or Var3$<>Nul Then
          Var$=Var$+Space$(18-Len(Var$))
          If Var2$<>Nul Then
             Var$=Var$+Var2$+Space$(15-Len(Var2$))
          Endif
          If Var3$<>Nul Then
             Var$=Var$+Var3$
          Endif
       Endif
       VarZ=VarZ+1
       Temp.ArrayS(VarZ)=Rtrim$(Var$)
    Endif
 Next
 For VarS1=1 To VarZ
    For VarS2=VarS1+1 To VarZ
       If Temp.ArrayS(VarS1)>Temp.ArrayS(VarS2) Then
          Swap Temp.ArrayS(VarS1),Temp.ArrayS(VarS2)
       Endif
    Next
 Next
 Var3=1
 Graphics.Off=False
 Strng="Catalog of synonyms. Where <> indicates required parameter."
 Call IO.O
 Graphics.Off=True
 Allow.Break=True
 Break=False
 Continuous=False
 For Var=1 To MaxUserCommands
    Var$=Temp.ArrayS(Var)
    Var$=Rtrim$(Var$)
    If Var$=Nul Then
       Exit For
    Endif
    Strng=Var$
    Call IO.O
    If Break Then
       Var3=False
       Exit For
    Endif
    Var3=Var3+1
    If Var3>=User.PageLength-2 Then
       Var3=False
       If Continuous=False Then
          Call More.Prompt
          If No Or Quit Then
             Exit For
          Endif
       Endif
    Endif
 Next
 Allow.Break=False
 Break=False
 If Var3 Then
    Call More.Prompt
 Endif
Err.Rsm22a1:
 Exit Sub
Err.Trp22a1:
 Resume Err.Rsm22a1
End Sub

Sub Display.Cat3
 On Local Error Goto Err.Trp22g
 Dim Quote2 As String*1
 Quote2=Chr$(34)
 Graphics.Off=False
 Strng="Current prefixes:"
 Call IO.O
 Graphics.Off=True
 Strng="Node commands: "
 If Len(Config3(78)) Then
    Strng=Strng+Quote2+Config3(78)+Quote2
 Else
    Strng=Strng+"<disabled>"
 Endif
 Call IO.O
 Strng="DM commands: "
 If Len(Config3(9)) Then
    Strng=Strng+Quote2+Config3(9)+Quote2
 Else
    Strng=Strng+"<disabled>"
 Endif
 Call IO.O
 Strng="Sysop commands: "
 If Len(Config3(79)) Then
    Strng=Strng+Quote2+Config3(79)+Quote2
 Else
    Strng=Strng+"<disabled>"
 Endif
 Call IO.O
 Strng="Repeat last command: "
 If Len(Config3(10)) Then
    Strng=Strng+Quote2+Config3(10)+Quote2
 Else
    Strng=Strng+"<disabled>"
 Endif
 Call IO.O
 Call More.Prompt
Err.Rsm22g:
 Exit Sub
Err.Trp22g:
 Resume Err.Rsm22g
End Sub

Sub Display.Cat4
 On Local Error Goto Err.Trp22e
 Graphics.Off=False
 Strng="Current ANSI prefixes:"
 Call IO.O
 Graphics.Off=True
 Call Display.ANSI.Prefixes
Err.Rsm22e:
 Exit Sub
Err.Trp22e:
 Resume Err.Rsm22e
End Sub

Sub Display.Cat5
 On Local Error Goto Err.Trp22f
 Graphics.Off=False
 Strng="Current string prefixes:"
 Call IO.O
 Graphics.Off=True
 Strng="Prefix  String"
 Call IO.O
 Strng="------  ------"
 Call IO.O
 Strng="[1]     user codename"
 Call IO.O
 Strng="[2]     user classname"
 Call IO.O
 Strng="[3]     date/time in form: mm/dd/yyyy hh:mm:ss"
 Call IO.O
 Strng="[4]     date in form: mm/dd/yyy"
 Call IO.O
 Strng="[5]     time in form: hh:mm:ss"
 Call IO.O
 Strng="[6]     formatted date/time in form: ddd dd mmm yy, hh:mma/p"
 Call IO.O
 Strng="[7]     user node (<nul>,0-9,A-Z,10-99)"
 Call IO.O
 Strng="[8]     user comm port (1-64)"
 Call IO.O
 Strng="[9]     user port (0-63)"
 Call IO.O
 Strng="[a]     date/time user logged on"
 Call IO.O
 Strng="[b]     program version"
 Call IO.O
 Strng="[c]     program release"
 Call IO.O
 Strng="[d]     program name (dndbbs)"
 Call IO.O
 Strng="[e]     program runmode"
 Call IO.O
 Strng="[f]     program run number"
 Call IO.O
 Call More.Prompt
 Strng="[g]     phone line#1"
 Call IO.O
 Strng="[h]     phone line#2"
 Call IO.O
 Strng="[i]     phone line#3"
 Call IO.O
 Strng="[j]     phone line#4"
 Call IO.O
 Strng="[k]     Sysop Name"
 Call IO.O
 Strng="[l]     Sysop Email"
 Call IO.O
 Strng="[m]     BBS name"
 Call IO.O
 Strng="[n]     BBS description"
 Call IO.O
 Strng="Phone lines 5-16 are [o] to [z]"
 Call IO.O
 Strng="Phone lines 17-127 are 17 to 127 enclosed in braces {}"
 Call IO.O
 Call More.Prompt
Err.Rsm22f:
 Exit Sub
Err.Trp22f:
 Resume Err.Rsm22f
End Sub

Sub Display.Cat6
 On Local Error Goto Err.Trp22b
 Graphics.Off=False
 Strng="Catalog of Sysop commands."
 Call IO.O
 Graphics.Off=True
 For Var=1 To MaxSysopCommands
    TempZ=Var+MaxUserCommands+MaxDMcommands
    Call Read.Message.Record(MessWorkFile8,TempZ)
    Var$=UserCommandRecord.CommandSet(1)
    Var$=Rtrim$(Var$)
    Var$=Lcase$(Var$)
    Mid$(Var$,1,1)=UCase$(Mid$(Var$,1,1))
    Var$=Config3(79)+Var$
    Strng=Var$
    Call IO.O
 Next
 Call More.Prompt
Err.Rsm22b:
 Exit Sub
Err.Trp22b:
 Resume Err.Rsm22b
End Sub

Sub Display.Cat7
 On Local Error Goto Err.Trp22c
 Graphics.Off=False
 Strng="Catalog of DM commands. Where <> indicates required parameter."
 Call IO.O
 Graphics.Off=True
 For Var=1 To MaxDMcommands
    TempZ=Var+MaxUserCommands
    Call Read.Message.Record(MessWorkFile8,TempZ)
    Var$=UserCommandRecord.CommandSet(1)
    Var$=Rtrim$(Var$)
    Var$=Lcase$(Var$)
    Mid$(Var$,1,1)=UCase$(Mid$(Var$,1,1))
    Var$=Config3(9)+Var$
    If UserCommandRecord.CommandParam>False Then
       Var$=Var$+"<>"
    Endif
    If UserCommandRecord.CommandParam=True Then
       If Var=9 Then
          Var$=Var$+"<>"
       Else
          Strng=Var$+"<>"
          Call IO.O
          Var$=Var$+"<><>"
       Endif
    Endif
    Strng=Var$
    Call IO.O
 Next
 Call More.Prompt
Err.Rsm22c:
 Exit Sub
Err.Trp22c:
 Resume Err.Rsm22c
End Sub

Sub Display.Cat8
 On Local Error Goto Err.Trp22d
 Graphics.Off=False
 Strng="Catalog of node commands."
 Call IO.O
 Graphics.Off=True
 For Var=1 To MaxNodeCommands
    TempZ=Var+MaxUserCommands+MaxDMcommands+MaxSysopCommands
    Call Read.Message.Record(MessWorkFile8,TempZ)
    Var$=UserCommandRecord.CommandSet(1)
    Var$=Rtrim$(Var$)
    Var$=Lcase$(Var$)
    Mid$(Var$,1,1)=UCase$(Mid$(Var$,1,1))
    Var$=Config3(78)+Var$
    Strng=Var$
    Call IO.O
 Next
 Call More.Prompt
Err.Rsm22d:
 Exit Sub
Err.Trp22d:
 Resume Err.Rsm22d
End Sub
