home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLRANGE.PAK / PRINT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.8 KB  |  82 lines

  1. //.............................................................................
  2. //
  3. // print.cpp
  4. //
  5. //............................................................................
  6. // includes
  7.  
  8. #include <windows.h>
  9. #include <stdarg.h>
  10. #include <stdio.h>
  11.  
  12. #include "print.h"
  13.  
  14. //............................................................................
  15.  
  16. #ifdef __FLAT__
  17. #define filename "FISHER32.TXT"
  18. #else
  19. #define filename "FISHER16.TXT"
  20. #endif
  21.  
  22. //............................................................................
  23.  
  24. #define DBWinPrintf(lpstr) OutputDebugString(lpstr)
  25.  
  26. //............................................................................
  27.  
  28. #define MsgBoxPrintf(lpstr) MessageBox(GetFocus(), lpstr, "Diamond", MB_OK | MB_APPLMODAL)
  29.  
  30. //............................................................................
  31.  
  32. void FilePrintf(LPCSTR lpstr, int len)
  33. {
  34.     int hfile;
  35.  
  36.     hfile = _lopen(filename, OF_WRITE);
  37.     if (hfile == HFILE_ERROR)
  38.         hfile = _lcreat(filename, 0);
  39.     else
  40.         _llseek(hfile, 0L, 2);
  41.  
  42.     _lwrite(hfile, lpstr, len);
  43.     _lclose(hfile);
  44. }
  45.  
  46. //............................................................................
  47.  
  48. void EmptyFile( void )
  49. {
  50.     int hfile = _lcreat( filename, 0 );
  51.     _lclose( hfile );
  52. }
  53.  
  54. //............................................................................
  55.  
  56. void PrintMsg(WORD dest, LPCSTR format, ...)
  57. {
  58.     if (*format)
  59.     {
  60.         va_list argptr;
  61.         LPSTR lpstr;
  62.         int len;
  63.  
  64.         lpstr = new char[1024];
  65.  
  66.         va_start(argptr, format);
  67.         len = vsprintf(lpstr, format, argptr);
  68.         va_end(argptr);
  69.  
  70.         if (dest & TO_FILE)
  71.             FilePrintf(lpstr, len);
  72.         if (dest & TO_DBWIN)
  73.             DBWinPrintf(lpstr);
  74.         if (dest & TO_MSGBOX)
  75.             MsgBoxPrintf(lpstr);
  76.  
  77.         delete lpstr;
  78.     }
  79. }
  80.  
  81. //.............................................................................
  82.