Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing code in colour 1

Status
Not open for further replies.

pmscraiova

Programmer
Joined
Dec 8, 2001
Messages
86
Location
RO
I want, if it is possible, to print my code, in different colour (such it appear in vfp editor). For example keywords = blue, variables = black)
 
Go to the UT ( Click on Down loads, pick Visual FoxPro, then enter 'mhHTMLCode' in the Title box (without the quotes). You should get back:
"mhHTMLCode January 25, 2002 06:57
This utiltity takes Visual FoxPro code and converts it to HTML, preserving syntax coloring. It can convert it to HTML colors directly or use CSS. It has been changed a bit, mostly to speed it up, and it cooks pretty well."

You can then print this output from your browser.

Rick
 
Thank you Rick,
I pick up the "mhHTMLCode" from UniversalThread, but I can't understand how can I use it. Please help me...
Best regards,
Eugen Fintina
 
Eugen,
While Mike writes good code, his example does leave a little to be desired <g>. (For example - this will only compile in VFP 7.0 and it assumes you have IE installed! The original worked in VFP 5/6, but I don't see that it's still available. <s>) I've added some parameters, and some comments, and the following should give you a better starting point - assuming you have FP 7.0. Sample use:
=ShowColor('mhhtmlcode.prg')
Code:
*ShowColor.PRG
LPARAMETERS p_cPRGFileName, p_cOutputFile
LOCAL lcText, lcHTML, ;
  loHTML AS htmlcode OF mhhtmlcode.prg && VFP 7.0

IF PCOUNT() < 2 OR VARTYPE(p_cOutputFile) <> &quot;C&quot;
   p_cOutputFile = 'sample.htm'
ENDIF
lcText = FILETOSTR(p_cPRGFileName)
loHTML = NEWOBJECT('htmlcode', 'mhhtmlcode.prg')
lcHTML = loHtml.PrgToHtml(lcText)

*?loHTML.nLines, ' lines in ', loHTML.nSeconds, ' seconds'

RELEASE loHTML

* Display the page in IE
llSafety = SET(&quot;Safety&quot;) = 'ON'
SET SAFETY OFF 
STRTOFILE(lcHTML, p_cOutputFile)
IF llSafety
   SET SAFETY ON 
ENDIF 
oIE = CREATEOBJECT(&quot;internetexplorer.application&quot;)
oIE.Navigate(FULLPATH(p_cOutputFile))
oIE.Visible = .t.

Rick
 
Thank you very much Rick but, unfortunate, I don’t have VFP 7.0 (only VFP 6.0). I understand that this piece of code works only in VFP 7.0. Do you think that I can get the version for VFP 6.0 from somewhere?

Eugen
 
Eugen,
I found I have a very &quot;old&quot; version of the program that would work in VFP 5 / 6. It's non-oop, and only supports reserved works in blue and comments in green. It also expects you to convert the file to a string and the returned string to a file. If you understand what he's doing in the 7.0 version, you could probably expand this old version to do the same functions. If you are interested, provide an email address and I'll zip up what I have and sent it to you. (Note: Feel free to &quot;mask&quot; you're email address so it isn't for the page reader programs to grab it for SPAM lists - mine for example is rgbean AT NOSPAMmelange-inc DOT com.)

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top