Pascal,
The only way I can think of is to COMPILE the code and check for an .ERR file. This seems to work, but unfortunately requires the COMPILE command which was not available in the runtime before VFP6 SP5 (I think). Anyway, here's a simple syntax checker that returns the compiler's error message if there's a syntax error, otherwise a blank:
?SyntaxChecker("BROWSE")
?SyntaxChecker("BORWSE")
'Error in line 1: Unrecognized command verb.'
PROCEDURE SyntaxChecker
LPARAMETERS tcCode
lcTempPrg = AddBs(SYS(2023)) + "A" + RIGHT(SYS(3), 7) + ".TMP"
lcErrFile = FORCEEXT(lcTempPrg, "ERR")
STRTOFILE(tcCode, lcTempPrg)
COMPILE (lcTempPrg)
IF FILE(lcErrFile)
lcRetVal = FILETOSTR(lcErrFile)
ELSE
lcRetVal = ""
ENDIF
DELETE FILE (FORCEEXT(lcTempPrg, "*") )
RETURN lcRetVal
HTH
>How can I check if a command contained in a string has valid syntax, whithout executing it. Thought it was possible, but can't find how (VFP 5.0).
>
>I have a program that dynamically builds a query, so I want to know if the query has correct syntax before executing it.
Daniel