>>select CAST(0 AS BIT) AS MYFIELD >>>>
>* GetSQLText.prg >Lparameters tcSQL,tcMode,tlDebug > >Local lcLeft,lcRight,lnOccurence >lcLeft = Iif(Upper(m.tcMode) = 'SQL', '<VFP>','<SQL>') >lcRight = Iif(Upper(m.tcMode) = 'SQL', '</VFP>','</SQL>') > >For lnOccurence = 1 To Occurs(m.lcLeft,Upper(m.tcSQL)) > If Atc(m.lcLeft,m.tcSQL) > 0 > tcSQL = Strtran(m.tcSQL,Strextract(m.tcSQL,m.lcLeft,m.lcRight,1,1+4)) > Endif >Endfor >For lnOccurence = 1 To Occurs(m.lcLeft,Upper(m.tcSQL)) && check against erronous closing tags > If Atc(m.lcLeft,m.tcSQL) > 0 > tcSQL = Strtran(m.tcSQL,Strextract(m.tcSQL,m.lcLeft,m.lcLeft,1,1+4)) > Endif >Endfor > > >** Remove tcMode tags >tcSQL = Strtran(Strtran(m.tcSQL,'<'+m.tcMode+'>','',1,-1,1),'</'+m.tcMode+'>','',1,-1,1) >** All CRLF to CR >tcSQL = Chrtran(Strtran(m.tcSQL,Chr(13)+Chr(10),Chr(13)),Chr(10),Chr(13)) >** Eliminate blanklines >Do While Occurs(Chr(13)+Chr(13),m.tcSQL) > 0 > tcSQL = Strtran(m.tcSQL,Chr(13)+Chr(13),Chr(13)) >Enddo >** All CR to CRLF + if mode is VFP: if tlDebug to ' ;'+CRLF else ' ' >tcSQL = Strtran(m.tcSQL,Chr(13),Chr(13)+Chr(10)) >If m.tlDebug > _Cliptext = Iif(Upper(m.tcMode) = 'VFP', ; > Strtran(m.tcSQL, Chr(13)+Chr(10),' ;'+Chr(13)+Chr(10)), ; > m.tcSQL) >Endif >If Upper(m.tcMode) = 'VFP' > tcSQL = Strtran(m.tcSQL, Chr(13)+Chr(10), ' ') >Endif >Return tcSQL >>
>Local lcSQL >Text to m.lcSQL textmerge noshow >Select > <VFP>Cast(0 as Logical)</VFP> > <SQL>Cast(0 as bit)</SQL> > as myField >from myTable >EndText > >MessageBox( GetSQLText(m.lcSQL,'VFP'), 0, 'VFP', 10000) >GetSQLText(m.lcSQL,'VFP', .T.) && copied to clipboard >MessageBox( _cliptext, 0, 'VFP-Debug mode', 10000) >MessageBox( GetSQLText(m.lcSQL,'SQL'), 0, 'SQL', 10000) >>