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

Sub Display.Memory
 On Local Error Goto ErrorTrp40
 Graphics.Off=False
 Call System.Type
 Strng="System: "+Strng
 Call IO.O
 Call Get.Machine.Name(Var$)
 If Var$=Nul Then
    Var$="<none>"
 Endif
 Graphics.Off=True
 Strng="Machine: "+Rtrim$(Var$)
 Call IO.O
 Strng="Program: "+ProgramName$+" v"+Version$+" r"+Release$
 Call IO.O
 Strng="Task Mode: "+OSbit$
 Call IO.O
 Strng="Task Node: "
 If Rtrim$(NodeX)=Nul Then
    Strng=Strng+"-"
 Else
    Strng=Strng+NodeX
 Endif
 Call IO.O
 If BBS.Mode Then
    Strng="Door node: "
    If BBS.Mode=-2 Then
       Strng=Strng+"<telnet>"
    Else
       If Rtrim$(Door.Node)=Nul Then
          Strng=Strng+"-"
       Else
          Strng=Strng+Rtrim$(Door.Node)
       Endif
    Endif
    Call IO.O
    Strng=Rtrim$(Door.Name)
    If Len(Strng) Then
       Strng=Lcase$(Strng)
       Mid$(Strng,1,1)=Ucase$(Mid$(Strng,1,1))
       Strng="Door name: "+Strng
       Call IO.O
    Endif
 Endif
 Strng="Publish date: 06-10-2021"
 Call IO.O
 Call More.Prompt
 If No Or Quit Then
    Exit Sub
 Endif
 Graphics.Off=False
 Strng="File system:"
 Call IO.O
 Graphics.Off=True
 Strng="Dnddat="+Config3(11) ' \dnddat
 Call IO.O
 Strng="Dnddoc="+Config3(52) ' \dnddoc
 Call IO.O
 ' \dndtemp (ram drive)
 If Drive.Override Then
    Strng="Dndtemp(RAM drive)="+Ucase$(Chr$(Drive.Override))+":\"
 Else
    Strng="Dndtemp(RAM drive)="+Config3(53)
 Endif
 Call IO.O
 Strng="Dndmess="+Config3(54) ' \dndmess
 Call IO.O
 Strng="Dnddoor="+Config3(84) ' \rbbs
 Call IO.O
 If Continuous=False Then
    Call More.Prompt
    If No Or Quit Then
       Exit Sub
    Endif
 Endif
 Graphics.Off=False
 Strng="Available system resources:"
 Call IO.O
 Graphics.Off=True
 If OS2.Detected=False Then
    Out2=Format$(Fre(-2),"#,##0;;")
    Strng="Stack space: "+Out2+" B."
    Call IO.O
 Endif
 If OS2.Detected Then
    Strng="OS/2 free memory."
    Call IO.O
 Else
    Call Get.Free.Memory
    Strng="Data space: "+Strng+"."
    Call IO.O
 Endif
 Strng="256.00 MB"
 Temp#=0#
 f$="freedisk.out"
 If Dir$(f$)<>"" Then
    Close #TempFile1
    Open f$ For Input As #TempFile1
    If Eof(TempFile1)=0 Then
       Line Input #TempFile1,v$
       Temp#=Int(Val(v$))
       Call Make.Format(Temp#)
    Endif
 Endif
 Strng="Disk space: "+Strng+"."
 Call IO.O
 If Continuous=False Then
    Call More.Prompt
    If No Or Quit Then
       Exit Sub
    Endif
 Endif
 Graphics.Off=False
 Strng="System settings:"
 Call IO.O
 Graphics.Off=True
 If Mouse.Present Then
    Strng="Mouse detected."
    Call IO.O
 Else
    Strng="Mouse not detected."
    Call IO.O
 Endif
 If Share.Installed Then
    Strng="Share installed."
    Call IO.O
 Else
    Call Plex.Function(16)
    If (OutregsX.AX And &HFF)=&HFF Then
       Strng="Share disabled."
       Call IO.O
    Else
       Strng="Share not installed."
       Call IO.O
    Endif
 Endif
 If Low.Mem.Use Then
    Strng="Low memory usage on."
 Else
    Strng="Low memory usage off.
 Endif
 Call IO.O
 If Supported.Call=False Then
    Strng="Windows timer installed."
    Call IO.O
 Endif
 If Equate.Debug Then
    Strng="Equate debug enabled."
    Call IO.O
 Endif
 If Config2(63) Then
    Strng="Equation parser on."
 Else
    Strng="Equation parser off."
 Endif
 Call IO.O
 If Local.Mode=False Then
    Strng="No"
    If Fossil.Active Then
       Strng="Yes"
       If Fossil.Active=1 Then
          Strng=Strng+": X00"
       Endif
    Endif
    Strng="Fossil active: "+Strng+"."
    Call IO.O
 Endif
 Strng="Screen:"+Str$(Max.Row)+"x"+Mid$(Str$(User.LineLength),2)
 Call IO.O
 If Local.ANSI.Color Then
    Strng="Local ANSI color."
    Call IO.O
 Endif
 If Local.Avatar.Color Then
    Strng="Local Avatar color."
    Call IO.O
 Endif
 If Remote.ANSI.Color Then
    Strng="Remote ANSI color."
    Call IO.O
 Endif
 If Remote.Avatar.Color Then
    Strng="Remote Avatar color."
    Call IO.O
 Endif
 If Debug.Mode Then
    Strng="Debug mode on."
    Call IO.O
 Endif

 Call StdinInt(62,0)
 PSP.Segment=OutregsX.BX
 Def Seg=PSP.Segment
 X=Peek(&H32)
 Def Seg
 Strng="File handles:"+Str$(X-4)
 Call IO.O

 If Config2(55) Then
    Strng="Offline user fights on."
 Else
    Strng="Offline user fights off."
 Endif
 Call IO.O

 If Continuous=False Then
    Call More.Prompt
    If No Or Quit Then
       Exit Sub
    Endif
 Endif
 If Debug.Mode Then
    Graphics.Off=False
    Strng="Debug info:"
    Call IO.O
    Graphics.Off=True
    Strng="Inline.filename1="+Inline.Filename1
    Call IO.O
    Strng="Inline.filename2="+Inline.Filename2
    Call IO.O
    Strng="Video page="+Right$("0000"+Hex$(Video.Page),4)+"H"
    Call IO.O
    Call VideoInt(15,0)
    Var=OutregsX.AX And &HFF
    Strng="Video mode="+Right$("0000"+Hex$(Var),4)+"H"
    Call IO.O
    If Continuous=False Then
       Call More.Prompt
    Endif
 Endif
 Graphics.Off=True
ErrorRsm40:
 Exit Sub
ErrorTrp40:
 Resume ErrorRsm40
End Sub

Sub System.Type
 On Local Error Goto ErrTrap11
 If Windows.Detected Then
    If Win.Major=4 Then
       If Win.Minor>10 Then
          Strng="Win ME"
       Else
          If Win.Minor=10 Then
             Strng="Win 98"
          Else
             If Win.Minor=3 Then
                Strng="Win 95B"
             Else
                Strng="Win 95"
             Endif
          Endif
       Endif
    Else
       If Win.Major>4 Then
          Strng="WinX" ' OS past 98
       Else
          Strng="Win"+Str$(Win.Major)+"."+Ltrim$(Str$(Win.Minor))
       Endif
    Endif
    Exit Sub
 Endif
 Select Case DOS.Major
 Case 10
    Strng="OS/2 v1.0"
 Case 20
    Strng="OS/2 v2.0"
    Select Case DOS.Minor
    Case 30
       Strng="OS/2 v3.0"
    Case 40
       Strng="OS/2 v4.0"
    End Select
 Case 30
    Strng="Mac OSX"
 Case Else
    Strng="DOS"+Str$(DOS.Major)+"."+Ltrim$(Str$(DOS.Minor))
 End Select
ErrResume11:
 Exit Sub
ErrTrap11:
 Resume ErrResume11
End Sub

' store default server name
Sub Get.Machine.Name(VarX$)
 On Local Error Goto ErrorTrap19z
 DIM Default.Net AS STRING * 16
 VarX$ = Nul
 Default.Net = Nul
 InregsX.AX = &H5E00
 InregsX.DS = VARSEG(Default.Net)
 InregsX.DX = VARPTR(Default.Net)
 CALL InterruptX(&H21, InregsX, OutregsX)
 ' check error flag.
 IF (OutregsX.Flags AND &H1) = &H0 THEN
    ' read CH
    VarS = (OutregsX.CX AND &HFF00) / 256
    IF VarS > 0 THEN ' valid name.
       VarX$ = Default.Net
       Imbedded = INSTR(VarX$, CHR$(0))
       IF Imbedded THEN
          VarX$ = LEFT$(VarX$, Imbedded - 1)
       END IF
       VarX$ = UCASE$(RTRIM$(VarX$))
       EXIT SUB
    END IF
 END IF
 ' check net path.
 If VarX$ = Nul Then
    Var$ = Environ$("COMPUTERNAME")
    If Len(Var$) Then
       VarX$ = Var$
    Endif
 Endif
ErrorResume19z:
 Exit Sub
ErrorTrap19z:
 Resume ErrorResume19z
End Sub

Sub Make.Format(Var#)
 On Local Error Goto ErrTrap13
 Var2#=Var#
 If Var2#<=0 Then
    Strng="0.00 B"
    Exit Sub
 Endif
 TempA=False
 Do
    If Var2#<1024# Then
       Exit Do
    Endif
    Var2#=Var2#/1024#
    TempA=TempA+1
    If TempA=8 Then
       Exit Do
    Endif
 Loop
 Strng=Nul
 If TempA>=1 And TempA<=8 Then
    Strng=Mid$("KMGTPEZY",TempA,1)
 Endif
 Strng=Format$(Var2#,"#,##0.00;;")+" "+Strng+"B"
ErrResume13:
 Exit Sub
ErrTrap13:
 Resume ErrResume13
End Sub

Sub Get.Free.Memory
 On Local Error Goto ErrTrap12
 Strng=Nul
 If OS2.Detected Then ' has no freespace
    Strng="256.00 KB"
 Else
    Temp#=Cdbl(TempX!)
    Call Make.Format(Temp#)
 Endif
ErrResume12:
 Exit Sub
ErrTrap12:
 Resume ErrResume12
End Sub
