home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / robinson / debug.bas < prev    next >
Encoding:
BASIC Source File  |  1994-05-31  |  1.4 KB  |  56 lines

  1. 'DEBUG: Routines used in debugging an app
  2. Option Explicit
  3. Option Compare Text
  4.  
  5. '----------------------------------------------------
  6. ' These are variables used as constants
  7. Dim CRLF As String
  8. '
  9. Global Const DEBUG_FLAG = "/D"
  10.  
  11. '----------------------------------------------------
  12. Declare Sub OutputDebugString Lib "Kernel" (ByVal lpOutputString As String)
  13. Global fDebug As Integer
  14. Dim nDebug As Integer
  15. Dim szDspChr As String
  16.  
  17. 'Display an appropriate error message, and then stop the
  18. ' program.  These errors should NOT be possible in the
  19. ' shipping product.
  20. Sub Assert (ByVal bFlag As Integer, Msg As String, ByVal bDie As Integer)
  21.   
  22.   If bFlag Then Exit Sub
  23.   
  24.   MsgBox Msg$, 48
  25.   If bDie Then fCancel = True
  26.  
  27. End Sub
  28.  
  29. Sub EndODS ()
  30.   If nDebug Then
  31.     Close nDebug
  32.   End If
  33. End Sub
  34.  
  35. 'InitODS: Initialize variables needed for ODS routine
  36. ' CmdLine = Command line to test for debug flag: /D
  37. Sub InitODS (sDisplayChar As String, CmdLine As String, LogFileName As String)
  38.   
  39.   CRLF = Chr$(13) + Chr$(10)
  40.   szDspChr = sDisplayChar
  41.   fDebug = InStr(CmdLine, DEBUG_FLAG) > 0
  42.   If Len(LogFileName) Then
  43.     nDebug% = FreeFile
  44.     Open LogFileName For Output As nDebug%
  45.   Else
  46.     nDebug% = 0
  47.   End If
  48.  
  49. End Sub
  50.  
  51. Sub ODS (DspStr As String)
  52.   If fDebug Then OutputDebugString szDspChr + DspStr + CRLF
  53.   If nDebug Then Print #nDebug, DspStr
  54. End Sub
  55.  
  56.