Hi Cathy,
>
> TEXT TO m.lcSQL TEXTMERGE NOSHOW
> SELECT * ;
> FROM table ;
> WHERE <<m.lcWhere>> ;
> ENDTEXT
> lcSQL = ALLTRIM(CHRTRANC( m.lcSQL, CHR(13) + CHR(10) + CHR(9) + ";", " "
))
> &lcSQL
does not allow me to use inline commentary in Text..EndText.
Therefore I use the code at the bottom.
Perhaps you want to add vfp-style inline commentary.
regards
thomas
function CleanSQLTest()
local lcSQL
text TO lcSQL TEXTMERGE NOSHOW
select ;
"Hallo" as fullname ; && Line in pure Text
from TestSnippet ; && Table we have open
into cursor c_Test readwrite
ENDTEXT
? lcSQL
lcSQL = CleanSqlLine(m.lcSQL)
? lcSQL
assert .f. message lcSQL
&lcSQL
return
function CleanSqlLine(tcSQL, tlSimple)
*-- needs to take care of more special cases like
*-- chr(9) used inside strings,
*-- multiple spaces in "code part
if m.tlSimple
return Alltrim(chrtranc(m.tcSQL,";"+chr(13)+chr(10)+chr(9),space(1)))
else
local laLines[1] ;
, lcLine, lcSQL ;
, lnRun, lnRAT
lcSQL = ""
for lnRun = 1 to alines(laLines, m.tcSQL)
*-- possible break: ";" not used as continuation sign but in text
*-- would have been broken in orig. implementation as well
*-- use Asc(59) or just make sure you have a ";"
*-- at the end of the code line
*-- if one ";" is in the text!
*-- snips off inline commentary as well
lnRAT = rat(";",laLines[m.lnRun]) - 1
lcLine = iif(m.lnRAT>0, left(laLines[m.lnRun] ;
, m.lnRAT), laLines[m.lnRun])
*-- work in progress, unelegant and potentially slow
*-- check again if offsetcounters are better
do while empty(left(m.lcLine, 1))
lcLine = substr(m.lcLine, 2)
enddo
do while empty(right(m.lcLine, 1))
lcLine = left(m.lcLine, len(m.lcLine)-1)
enddo
lcSQL = m.lcSQL + " " + m.lcLine
next
*-- we avoided checking lcSQL in the loop, cut off first space
return substr(m.lcSQL, 2)
endif


|