******************************************************************** * Description.......: mhHTMLCode - program to format VFP programs to HTML * Calling Samples...: on key label f9 _cliptext=mhHTMLcode(_cliptext) * Parameter List....: lcCode, lcPath * Created by........: Mike Heland * Modified by.......: Nadya Nosonovsky 04/05/2000 10:54:03 AM ******************************************************************** lparameters lcCode, lcPath *Open up our table of words lnWA = select() select 0 use (iif(empty(lcPath), '', lcPath) + 'words') *Do some basic HTML intializing lcCode = strtran(lcCode, chr(9), space(5)) lcCode = strtran(lcCode, '<', '<') && In line comments lcCode = strtran(lcCode, '>', '>') *Create an array ouf of our strings. local laLines[1], lcReturn alines(laLines, lcCode) lcReturn = '<pre>' *Proccess each line for lnI = 1 to alen(laLines) lcLine = laLines[lnI] *Don't even bother the blank ones if empty(alltrim(lcLine)) loop endif *Full Line Comments, first if upper(alltrim(lcLine)) = '*' or; upper(alltrim(lcLine)) = 'NOTE' lcLine = '<font color=green>' + ; lcLine + '</font>' *Print line here lcReturn = lcReturn + chr(13) + chr(10) + lcLine loop endif *Now end of the line comments local lcDoubleAmp, lnStartComment lcDoubleAmp = chr(38) + chr(38) lnStartComment = at(lcDoubleAmp, lcLine) if lnStartComment > 0 lcLine = stuff(lcLine, lnStartComment, 0, '<font color=green>') + ; '</font>' endif *Define vars ahead of time *So they do not always need to be *Calculated in the loops local lcFormat, lnFormatLength, lcFL, ; lcRW, lnRWLength, lnStartRW, lnOccurance lcFormat = '<font color=blue>' lnFormatLength = len(lcFormat) lcFL = ' '+ upper(trim(chrtran(lcLine, ':;./\<>+=-}]()#', space(15)))) + ' ' *Look at every RW scan wait window nowait 'Line ' + alltrim(str(lnI)) + ; ' RW ' + alltrim(str(recno())) lcRW = ' ' + alltrim(REVWORD) + ' ' lnRWLength = len(lcRW) - 2 *For each occurance of an RW ... lnOccurance = 1 lnStartRW = at(lcRW, lcFL, 1) do while lnStartRW > 0 *Put in the format tags lcLine = stuff(lcLine, lnStartRW, 0, lcFormat) lcLine = stuff(lcLine, lnStartRW + lnFormatLength + lnRWLength, 0, '</font>') lcFL = ' '+ upper(trim(chrtran(lcLine, ':;./\<>+=-}]()', space(14)))) + ' ' lnOccurance = lnOccurance + 1 lnStartRW = at(lcRW, lcFL, lnOccurance) enddo endscan *Submit the process line lcReturn = lcReturn + chr(13) + chr(10) + lcLine endfor lcReturn = strtran(lcReturn, '&', '&') lcReturn = lcReturn + '</pre>' use select (lnWA) return lcReturn