home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DIAG100.ZIP / DIAG.PRG < prev    next >
Text File  |  1993-04-27  |  14KB  |  442 lines

  1. *:*****************************************************************************
  2. *:
  3. *: Procedure file: C:\SOURCE\DIAG\DIAG.PRG
  4. *:
  5. *:         System: System Diagnostics Tool
  6. *:         Author: Bil Simser
  7. *:      Copyright (c) 1993, Bil Simser
  8. *:  Last modified: 04/27/93     13:48
  9. *:
  10. *:  Procs & Fncts: DIAG()
  11. *:
  12. *:  Generic diagnostics routine that prints out a full report
  13. *:  for dealing with problems. This may take up a lot of paper so
  14. *:  some sort of parameter passing would be needed to filter out
  15. *:  unwanted reports.
  16. *:  For use as a generic diagnostics tool in all Clipper and C programs
  17. *:  since we use funcky we'll just add a _; to the function calls to make
  18. *:  them C callable
  19. *:
  20. *:      Documented 04/27/93 at 13:55                SNAP!  version 5.02
  21. *:*****************************************************************************
  22. #include "funcky.ch"
  23.  
  24. *!*****************************************************************************
  25. *!
  26. *!       Function: DIAG()
  27. *!
  28. *!    Other Files: REPORT.TXT
  29. *!               : AUTOEXEC.BAT
  30. *!               : CONFIG.BAT
  31. *!
  32. *!*****************************************************************************
  33. FUNCTION Diag( cName )
  34.  
  35. LOCAL nHandle := FCREATE( "report.txt" ), nTempHandle
  36. LOCAL nRetVal1, nRetVal2, nRetVal3, nCount
  37. LOCAL cString := "", aInfo[12]
  38.  
  39. // Array for reporting mice type
  40. LOCAL aMice := { "None","Bus","Serial", ;
  41.    "InPort","PS/2", "Hewlett Packard" }
  42.  
  43. // Array for reporting hard drive info
  44. LOCAL aStatus := { "bytes per sector                  ",;
  45.    "sectors per cluster               ",;
  46.    "reserved sectors                  ",;
  47.    "FATs (File Allocation Tables)     ",;
  48.    "possible root directory entries   ",;
  49.    "sectors on disk             ",;
  50.    "is the Disk media descriptor byte                  ",;
  51.    "sectors per FAT                   ",;
  52.    "sectors per track                 ",;
  53.    "heads                             ",;
  54.    "hidden sectors                    ",;
  55.    "Serial number                               "}
  56.  
  57. CLS
  58. ? "Clipper Diagnostics"
  59. ? "Version 1.00"
  60. ? "Copyright (c) 1993 Bil Simser"
  61. ? "All Rights Reserved"
  62. ?
  63. ? "Building System Statistics..."
  64.  
  65. Fwriteline( nHandle, PADC( " System Summary Information ", 78, "-" ) )
  66. Fwriteline( nHandle, "" )
  67.  
  68. nRetVal1 := Cputype()
  69.  
  70. DO CASE
  71.    
  72. CASE nRetVal1 ==  -1
  73.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "Unknown" )
  74. CASE nRetVal1 ==  8086
  75.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "8088 or 8086 microprocessor" )
  76. CASE nRetVal1 ==  80186
  77.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "80186 CPU" )
  78. CASE nRetVal1 ==  80286
  79.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "80286 CPU" )
  80. CASE nRetVal1 ==  80386
  81.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "80386 CPU" )
  82. CASE nRetVal1 ==  80486
  83.    Fwriteline( nHandle, PADL(   "Computer : ", 40 ) + "80486 CPU" )
  84.    
  85. ENDCASE
  86.  
  87. nRetVal1 := Dosmem()
  88. nRetVal2 := Extmem()
  89. nRetVal3 := Expmem()
  90.  
  91. cString := ALLTRIM( STR( nRetval1 ) ) + ;
  92.    "K DOS, " + ;
  93.    ALLTRIM( STR( nRetval2 ) ) + ;
  94.    "K Ext, " + ;
  95.    ALLTRIM( STR( nRetval3 ) ) + ;
  96.    "K EMS"
  97.  
  98. Fwriteline( nHandle, PADL( "Memory : ", 40 ) + cString )
  99.  
  100. nRetVal1 := montype()
  101.  
  102. DO CASE
  103.    
  104. CASE( nRetVal1 EQ -1 )
  105.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "Display combination unknown." )
  106.    
  107. CASE( nRetVal1 EQ 0 )
  108.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "No video available." )
  109.    
  110. CASE( nRetVal1 EQ 1 )
  111.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "MDA with monochrome monitor in use." )
  112.    
  113. CASE( nRetVal1 EQ 2 )
  114.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "CGA with color monitor in use." )
  115.    
  116. CASE( nRetVal1 EQ 4 )
  117.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "EGA with color monitor in use." )
  118.    
  119. CASE( nRetVal1 EQ 5 )
  120.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "EGA with monochrome monitor in use." )
  121.    
  122. CASE( nRetVal1 EQ 6 )
  123.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "PGA adapter in use." )
  124.    
  125. CASE( nRetVal1 EQ 7 )
  126.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "VGA with monochrome monitor in use." )
  127.    
  128. CASE( nRetVal1 EQ 8 )
  129.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "VGA with color monitor in use." )
  130.    
  131. CASE( nRetVal1 EQ 10 )
  132.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "MCGA with digital color display." )
  133.    
  134. CASE( nRetVal1 EQ 11 )
  135.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "MCGA with analog monochrome display." )
  136.    
  137. CASE( nRetVal1 EQ 12 )
  138.    Fwriteline( nHandle, PADL(   "Video : ", 40 ) + "MCGA with analog color display." )
  139.    
  140. ENDCASE
  141.  
  142. nRetVal1 := Dosvers()
  143.  
  144. Fwriteline( nHandle, PADL(   "OS Version : ", 40 ) + "MS-DOS Version " + ;
  145.    ALLTRIM( STR( nRetVal1 ) ) )
  146.  
  147. nRetVal1 := m_version()
  148. nRetVal2 := m_type()
  149.  
  150. Fwriteline( nHandle, PADL(   "Mouse : ", 40 ) + aMice[ nRetVal2 + 1 ] + ;
  151.    IIF( nRetVal2 <> 0, ;
  152.    " Mouse Version " + ;
  153.    ALLTRIM( STR( nRetVal1 * .01 ) ), "" ) )
  154.  
  155. Fwriteline( nHandle, PADL(   "Disk Drives : ", 40 ) + alldrives() )
  156.  
  157. nRetVal1 := lptcount()
  158.  
  159. Fwriteline( nHandle, PADL(   "LPT Ports : ", 40 ) + ;
  160.    ALLTRIM( STR( nRetVal1 ) ) )
  161.  
  162. nRetVal1 := comcount()
  163.  
  164. Fwriteline( nHandle, PADL(   "COM Ports : ", 40 ) + ;
  165.    ALLTRIM( STR( nRetVal1 ) ) )
  166. Fwriteline( nHandle, "" )
  167.  
  168. Fwriteline( nHandle, PADC( " Computer ", 78, "-" ) )
  169. Fwriteline( nHandle, "" )
  170.  
  171. nRetVal1 := Romdate()
  172.  
  173. Fwriteline( nHandle, PADL(   "BIOS Date : ", 40 ) + nRetVal1 )
  174.  
  175. nRetVal1 := Ndptype()
  176.  
  177. DO CASE
  178.    
  179. CASE nRetVal1 == -1
  180.    Fwriteline( nHandle, PADL(   "Math Coprocessor : ", 40 ) + "Unknown" )
  181.    
  182. CASE nRetVal1 == 0
  183.    Fwriteline( nHandle, PADL(   "Math Coprocessor : ", 40 ) + "No math coprocessor installed" )
  184.    
  185. CASE nRetVal1 == 8087
  186.    Fwriteline( nHandle, PADL(   "Math Coprocessor : ", 40 ) + "8087 NDP" )
  187.    
  188. CASE nRetVal1 == 80287
  189.    Fwriteline( nHandle, PADL(   "Math Coprocessor : ", 40 ) + "80287 NDP" )
  190.    
  191. CASE nRetVal1 == 80387
  192.    Fwriteline( nHandle, PADL(   "Math Coprocessor : ", 40 ) + "80387 NDP" )
  193.    
  194. ENDCASE
  195.  
  196. Fwriteline( nHandle, PADL(   "Keyboard : ", 40 ) + IIF( Isextended(), ;
  197.    "Enhanced", "Standard") )
  198. Fwriteline( nHandle, "" )
  199.  
  200. Fwriteline( nHandle, PADC( " Video ", 78, "-" ) )
  201. Fwriteline( nHandle, "" )
  202.  
  203. nRetVal1 := Vidtype()
  204.  
  205. DO CASE
  206.    
  207. CASE( nRetVal1 EQ -1 )
  208.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "Adapter type unknown." )
  209.    
  210. CASE( nRetVal1 EQ 0 )
  211.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "Monochrome adapter in use." )
  212.    
  213. CASE( nRetVal1 EQ 1 )
  214.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "CGA adapter in use." )
  215.    
  216. CASE( nRetVal1 EQ 2 )
  217.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "EGA adapter in use." )
  218.    
  219. CASE( nRetVal1 EQ 3 )
  220.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "VGA adapter in use." )
  221.    
  222. CASE( nRetVal1 EQ 4 )
  223.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "MCGA adapter in use." )
  224.    
  225. CASE( nRetVal1 EQ 5 )
  226.    Fwriteline( nHandle, PADL(   "Video Adapter Type : ", 40 ) + "PGA adapter in use." )
  227.    
  228. ENDCASE
  229.  
  230. nRetVal1 := Getmode()
  231.  
  232. Fwriteline( nHandle, PADL(   "Video Mode : ", 40 ) + ;
  233.    ALLTRIM( STR( nRetVal1 ) ) )
  234. Fwriteline( nHandle, PADL(   "Number of Columns : ", 40 ) + ;
  235.    ALLTRIM( STR( lastcol() ) ) )
  236. Fwriteline( nHandle, PADL(   "Number of Rows : ", 40 ) + ;
  237.    ALLTRIM( STR( lastrow() ) ) )
  238. Fwriteline( nHandle, "" )
  239.  
  240. Fwriteline( nHandle, PADC( " OS Version ", 78, "-" ) )
  241. Fwriteline( nHandle, "" )
  242. Fwriteline( nHandle, PADL(   "Operating System : ", 40 ) + ;
  243.    "MS-DOS " + ;
  244.    ALLTRIM( STR( Dosvers() ) ) )
  245. Fwriteline( nHandle, PADL(   "Boot Drive : ", 40 ) + ;
  246.    CHR( bootdrive() + 65 ) + ":" )
  247. Fwriteline( nHandle, "" )
  248.  
  249. Fwriteline( nHandle, PADC( " Memory Status ", 78, "-" ) )
  250.  
  251. // Conventional Memory
  252. Fwriteline( nHandle, "" )
  253. Fwriteline( nHandle, PADL(   "Conventional Memory", 40 ) )
  254. Fwriteline( nHandle, PADL( "Total : ", 40 ) + ;
  255.    ALLTRIM( STR( Dosmem() ) ) + " K" )
  256. Fwriteline( nHandle, PADL( "Available : ", 40 ) + ;
  257.    ALLTRIM( STR( MEMORY(0) ) ) + " K" )
  258.  
  259. Fwriteline( nHandle, "" )
  260. Fwriteline( nHandle, PADL( "Extended Memory (XMS)", 40 ) )
  261. Fwriteline( nHandle, PADL( "Available : ", 40 ) + ;
  262.    ALLTRIM( STR( Extmem() ) ) + " K" )
  263.  
  264. Fwriteline( nHandle, "" )
  265. Fwriteline( nHandle, PADL( "Expanded Memory (EMS)", 40 ) )
  266. Fwriteline( nHandle, PADL( "EMS Memory Manager Installed : ", 40 ) + ;
  267.    IIF( Isems(), "Yes", "No" ) )
  268. Fwriteline( nHandle, PADL( "Active Expanded Memory handles : ", 40 ) + ;
  269.    ALLTRIM( STR( ems_count() ) ) )
  270. Fwriteline( nHandle, PADL( "Total number of pages available : ", 40 ) + ;
  271.    ALLTRIM( STR( ems_pages( 1 ) ) ) )
  272. Fwriteline( nHandle, PADL( "Number of remaining pages available : ", 40 ) + ;
  273.    ALLTRIM( STR( ems_pages( 0 ) ) ) )
  274. Fwriteline( nHandle, "" )
  275.  
  276. Fwriteline( nHandle, PADC( " Environment Strings ", 78, "-" ) )
  277. Fwriteline( nHandle, "" )
  278.  
  279. FOR nRetVal1 := 1 TO envc()
  280.    
  281.    Fwriteline( nHandle, env( nRetVal1 ) )
  282.    
  283. NEXT
  284.  
  285. Fwriteline( nHandle, "" )
  286.  
  287. Fwriteline( nHandle, PADC( " Disk Drives ", 78, "-" ) )
  288. Fwriteline( nHandle, "" )
  289. Fwriteline( nHandle, SPACE( 2 ) + "Drive" + SPACE( 2 ) + "Type" + ;
  290.    SPACE( 34 ) + "Free Space" + SPACE( 10 ) + "Total Size" )
  291. Fwriteline( nHandle, SPACE( 2 ) + "-----" + SPACE( 2 ) + "----" + ;
  292.    SPACE( 34 ) + "----------" + SPACE( 10 ) + "----------" )
  293. Fwriteline( nHandle, "" )
  294.  
  295. FOR nRetVal1 := 1 TO LEN( Drivestr() )
  296.    
  297.    cString := ""
  298.    
  299.    // Build our information for each drive
  300.    IF UPPER(SUBSTR( Drivestr(), nRetVal1, 1 )) == "A" .OR. ;
  301.          UPPER(SUBSTR( Drivestr(), nRetVal1, 1 )) == "B"
  302.       
  303.       cString += "Floppy Drive, "
  304.       nRetVal2 := drivetype( SUBSTR( Drivestr(), nRetVal1, 1 ) )
  305.       DO CASE
  306.          
  307.       CASE( nRetVal2 EQ 360 )
  308.          cString += " 360k 5 1/4 in."
  309.       CASE( nRetVal2 EQ 720 )
  310.          cString += " 720k 3 1/2 in."
  311.       CASE( nRetVal2 EQ 120 )
  312.          cString += " 1.2m 5 1/4 in."
  313.       CASE( nRetVal2 EQ 144 )
  314.          cString += " 1.44m 3 1/2 in."
  315.       CASE( nRetVal2 EQ 280 )
  316.          cString += " 2.8m 3 1/2 in."
  317.          
  318.       ENDCASE
  319.       
  320.       Fwriteline( nHandle, SPACE( 2 ) + SUBSTR( Drivestr(), nRetVal1, 1 ) + ;
  321.          ":" + SPACE( 5 ) + PADR( cString, 31 ) )
  322.    ELSE
  323.       
  324.       cString += IIF( Getvolume( SUBSTR( Drivestr(), nRetVal1, 1 ) ) == "MS-RAMDRIVE", ;
  325.          "RAM Drive", "Fixed " + ;
  326.          IIF( isremote( SUBSTR( Drivestr(), nRetVal1, 1 ) ), ;
  327.          "remote drive", ;
  328.          "local drive" ) )
  329.       
  330.       Fwriteline( nHandle, SPACE( 2 ) + SUBSTR( Drivestr(), nRetVal1, 1 ) + ":" + ;
  331.          SPACE( 5 ) + PADR( cString, 31 ) + ;
  332.          PADL( ;
  333.          TRANSFORM( DISKSPACE( SUBSTR( Drivestr(), nRetVal1, 1 ) ), ;
  334.          "@Z 999,999,999" ) + " K", 20 ) + ;
  335.          PADL( ;
  336.          TRANSFORM( Disksize( SUBSTR( Drivestr(), nRetVal1, 1 ) ), ;
  337.          "@Z 999,999,999" ) + " K", 20 ) )
  338.       Fwriteline( nHandle, SPACE( 9 ) + ;
  339.          "Volume : " + ;
  340.          IIF( EMPTY( Getvolume( SUBSTR( Drivestr(), nRetVal1, 1 ) ) ), ;
  341.          "No Volume Label", ;
  342.          Getvolume( SUBSTR( Drivestr(), nRetVal1, 1 ) ) ) )
  343.       
  344.       diskinfo( SUBSTR( Drivestr(), nRetVal1, 1 ), @aInfo )
  345.       
  346.       FOR nCount := 1 TO LEN( aInfo ) - 1
  347.          
  348.          Fwriteline( nHandle, SPACE( 9 ) + ;
  349.             ALLTRIM( STR( aInfo[ nCount ] ) ) + ;
  350.             " " + ALLTRIM( aStatus[ nCount ] ) )
  351.          
  352.       NEXT
  353.       
  354.    ENDIF
  355.    
  356. NEXT
  357.  
  358. Fwriteline( nHandle, "" )
  359. Fwriteline( nHandle, "LASTDRIVE=" + Lastdrive() )
  360. IIF( phantom() == 1, Fwriteline( nHandle, "Drive A: is acting as drive B:" ), )
  361. Fwriteline( nHandle, "" )
  362.  
  363. Fwriteline( nHandle, PADC( " LPT Ports ", 78, "-" ) )
  364. Fwriteline( nHandle, "" )
  365. Fwriteline( nHandle, SPACE( 2 ) + "Port" + SPACE( 4 ) + "Status" )
  366. Fwriteline( nHandle, REPLICATE( "-", 60 ) )
  367.  
  368. FOR nRetVal1 := 1 TO lptcount()
  369.    
  370.    cString := ""
  371.    
  372.    IF Islpt( nRetVal1 )
  373.       
  374.       nRetVal2 := Prnstatus()
  375.       
  376.       DO CASE
  377.          
  378.       CASE nRetVal2 == 0
  379.          cString += "Not busy and on line"
  380.          
  381.       CASE nRetVal2 == 1
  382.          cString += "Off line or not turned on"
  383.          
  384.       CASE nRetVal2 == 2
  385.          cString += "Off or not connected"
  386.          
  387.       CASE nRetVal2 == 3
  388.          cString += "No paper"
  389.          
  390.       CASE nRetVal2 == 4
  391.          cString += "Not connected"
  392.          
  393.       CASE nRetVal2 == -1
  394.          cString += "Cannot determine status"
  395.          
  396.       ENDCASE
  397.       
  398.       Fwriteline( nHandle, SPACE( 2 ) + "LPT" + STR( nRetVal1, 1 ) + ;
  399.          SPACE( 4 ) + cString )
  400.       
  401.    ENDIF
  402.    
  403. NEXT
  404.  
  405. Fwriteline( nHandle, "" )
  406.  
  407. Fwriteline( nHandle, PADC( " AUTOEXEC.BAT ", 78, "-" ) )
  408. Fwriteline( nHandle, "" )
  409.  
  410. nTempHandle := FOPEN( CHR( bootdrive() + 65 ) + ":\AUTOEXEC.BAT" )
  411.  
  412. FOR nRetVal1 := 1 TO Flinecount( nTempHandle )
  413.    
  414.    Fwriteline( nHandle, Freadline( nTempHandle ) )
  415.    
  416. NEXT
  417.  
  418. FCLOSE( nTempHandle )
  419.  
  420. Fwriteline( nHandle, "" )
  421. Fwriteline( nHandle, PADC( " CONFIG.SYS ", 78, "-" ) )
  422. Fwriteline( nHandle, "" )
  423.  
  424. nTempHandle := FOPEN( CHR( bootdrive() + 65 ) + ":\CONFIG.BAT" )
  425.  
  426. FOR nRetVal1 := 1 TO Flinecount( nTempHandle )
  427.    
  428.    Fwriteline( nHandle, Freadline( nTempHandle ) )
  429.    
  430. NEXT
  431.  
  432. FCLOSE( nTempHandle )
  433. FCLOSE( nHandle )
  434.  
  435. ?
  436. ? "All done!"
  437. ?
  438.  
  439. RETURN(NIL)
  440.  
  441. *: EOF: DIAG.PRG
  442.