( Index )
Month

Brief Information about the February 2006 CSIG Meeting

C++ Viewer and HTML Converter

by Bruce Arnold

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Application Sample Output

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

OBJECT ...

To display a Cpp or C++ Text File in any browser by creating a temporary HTML file.

FEATURES ...

The file is displayed with keywords and comments highlighted in Blue and Green. Additionally, line numbers are added. The file may be printed directly from the browser with any desired scaling and pagination.

C++ Language Elements

Microsoft Visual C++ Version 6.0.
Windows API.
Dialog Based Applications.
File Input and Output.
String Searching.
Character handling in 'C'.
Launching a Browser.

At the meeting on Tuesday night we will be discussing these items and more.


SAMPLE CODE
===========
  258   /////////////////////////////////////////////////////////////////////////////
  259   //
  260   void CCDlg::DoProcess(CString InputFile)
  261       {
  262       CString drive, dir, fname, ext, folder, tempFile, tmpExt;
  263       _splitpath(InputFile.GetBuffer(100), drive.GetBuffer(100),
  264           dir.GetBuffer(100), fname.GetBuffer(100), ext.GetBuffer(100) );
  265   
  266       drive.ReleaseBuffer();  dir.ReleaseBuffer();
  267       fname.ReleaseBuffer();  ext.ReleaseBuffer();
  268       folder = drive + dir;
  269       tmpExt = ".htm";
  270       mResults.Empty();
  271   
  272       tempFile = TempName(&folder, &fname, &tmpExt);
  273   
  274       FILE *fs, *fsOut;
  275       if (NULL==(fs = fopen(InputFile.GetBuffer(100), "rt")))
  276           {
  277           MessageBox(InputFile.GetBuffer(100), "Input File Open Error 1");
  278           return;
  279           }
  280   
  281       if (NULL==(fsOut = fopen(tempFile.GetBuffer(100), "wt")))
  282           {
  283           MessageBox(tempFile.GetBuffer(100), "Output File Open Error 2");
  284           fclose(fs);
  285           return;
  286           }
  287   
  288       mResults = tempFile;
  289       
  290       fprintf(fsOut,"<HTML>\n");
  291       fprintf(fsOut,"<HEAD>\n");
  292       fprintf(fsOut,"<TITLE>%s</TITLE>\n", tempFile);
  293       fprintf(fsOut,"<!--\n");
  294       fprintf(fsOut,"*        This document has been created by CppView.exe\n");
  295       fprintf(fsOut,"* \n");
  296       fprintf(fsOut,"* C++ Program View Tool - Version 1.00 by B. Arnold 2/2006\n");
  297       fprintf(fsOut,"* \n");
  298       fprintf(fsOut,"-->\n");
  299       fprintf(fsOut,"<style type=\"text/css\"> .H_BLUE  { font-weight: bold;   color: #0000FF; } </style>\n");
  300       fprintf(fsOut,"<style type=\"text/css\"> .H_GREEN { font-weight: normal; color: #008000; } </style>\n");
  301       fprintf(fsOut,"</HEAD>\n");
  302       fprintf(fsOut,"<BODY>\n");
  303   
  304   
  305       fprintf(fsOut,"<H1>%s</H1>\n", tempFile);
  306       fprintf(fsOut,"<H3>Source = %s</H3>\n", InputFile.GetBuffer(100));
  307       fprintf(fsOut,"<HR>\n");
  308       fprintf(fsOut,"<pre>\n");
  309    
  310       DoParseData(fs, fsOut);             //  PARSE THE DATA FILE 

  311   
  312       fprintf(fsOut,"</pre>\n");
  313       fprintf(fsOut,"<HR>\n");
  314       fprintf(fsOut,"</BODY>\n");
  315       fprintf(fsOut,"</HTML>\n");
  316   
  317       fclose(fs);
  318       fclose(fsOut);
  319       }

"Random Access" questions start at 7:30 Tuesday night. See you there.
February 2006  C/C++ Meeting Random Access Notes
=================================================

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page