FANDOM


Parse the answer off the end of the line of a question Edit

#DEFINE vfpTab CHR(9)
#DEFINE vfpCRLF CHR(13) + CHR(10)

LPARAMETER loFoxCode
LOCAL lnClipLen, lcRetVal

loFoxCode.ValueType = "V"

lcClipText = ALLTRIM(_CLIPTEXT)
lnClipLen = LEN(lcClipText)

lcRetVal = vfpTab ;
	+ [IF LEFT(lcLine, ] ;
	+ TRANSFORM(lnClipLen) ;
	+ [) = "] ;
	+ lcClipText ;
	+ ["] + vfpCRLF
lcRetVal = lcRetVal ;
	+ vfpTab + vfpTab ;
	+ [lc~ = ALLTRIM(SUBSTR(lcLine, ] ;
	+ TRANSFORM(lnClipLen + 1) ;
	+ [))] + vfpCRLF
lcRetVal = lcRetVal ;
	+ vfpTab ;
	+ [ENDIF] + vfpCRLF

RETURN lcRetVal

Remove the quotes from Quoted IdentifiersEdit

If you have a SELECT-SQL statement from Crystal Reports against an Oracle database, for example, you may find that all the table and field names have quotes around them. This offends my sense of style. :-)

This code uses Craig Boyd's RegExp.FLL -- download it first.

LPARAMETERS oFoxCode 
LOCAL llRegExpFLL ;
	, lcQuote, lcNonQuotes, lcPeriod, lcIdentifier ;
	, lcRegExp, lcCommand

oFoxCode.ValueType = "V"

*!* If we're not already using RegExp, add it, and be ready to 
*!* take it out at the end.
llRegExpFLL = .F.
IF "REGEXP"$UPPER(SET("Library"))
	llRegExpFLL = .T.
ENDIF
SET LIBRARY TO HOME(1) + "regexp.fll" ADDITIVE

*!* Build the expression in readable chunks
lcQuote = '\"'
lcNonQuotes = '([^' + lcQuote + ']+)'
lcPeriod = '\.'
lcIdentifier = lcQuote + lcNonQuotes + lcQuote

lcRegExp = lcIdentifier + lcPeriod + lcIdentifier

*!* Build the command 
lcCommand = [_cliptext = regexp(_cliptext, '] + lcRegExp + [', 1, '\1.\2')]

&lcCommand.

IF NOT llRegExpFLL
	RELEASE LIBRARY regexp.fll
ENDIF 

*!* Return the command as a comment in the Command Window
RETURN "*" + lcCommand

Select from the table you're inEdit

LPARAMETER oFoxCode

oFoxCode.ValueType = "V"

lcDBF = DBF()

lcRetVal = "SELECT ~ FROM " + JUSTSTEM(lcDBF)

RETURN lcRetVal

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.