Re: VFP 9: Line Parsing

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Another gotcha, that fortunately is no real problem:
? "&&"

This does not work, but because of that you won't need to consider source code that has && within a string literal, no matter where within the string, VFP insist on && being the start of a line end comment and therefore ? " is incomplete, the
closing " is part of the comment.

The syntax highlighter of VFP does not color this correctly! Well, you can argue that VFP does not parse&compile this correctly, but it's one less problem to care for, if && is within a string or not, the first && in a line starts a comment.

U1 U2 Result
-- -- ------
; ; syntax error on this line only
; - valid: Code (not comment) continues on next physical line.
- ; valid: Comment continues on next physical line.
- - valid: The line stands alone.

Why the result when semicolons are in both positions?

Well, VFPs parser then can't determine, if the command or the comment would continue, so it does define this as syntax error.

Regarding how to easier find these U1,U2:

RTRIM() does trim away any whitespace, so the case of ;___ at the line end, any whitespace can be taken care of easily with RTRIM(), or if you do ALINES() on the sourcecode it's even a flag of ALINES to trim the lines. U2 then is the last char, or better said: If the last char is ";" U2 is ";" otherwise the line does not end with semicolon.

So all the heavy work is finding if there is a U1 semicolon before a && comment. As said initially, && always starts a comment and we don't need to parse if it is within a string or not. So we can search if U1 is ";" by backtracing
for the first non whitespace, or again use RTRIM in conjunction with GETWORDNUM:

If lcLine is a "physical" line parsed:

if '&'+'&' $ lcLine && here you see how to still create a string like '&&'
U1 = Right(Rtrim(GetWordnum(lcLine,1,'&'+'&')),1)
else
U1 = NULL && no line end comment
endif

Or if you treat U! and U2 as booleans:

U1 = (Right(RTrim(lcLine),1)=";")
U2 = ('&'+'&' $ lcLine AND Right(RTrim(GetWordnum(lcLine,1,'&'+'&')),1)=";")

If U1 AND U2
llContinuation = .F. && because of syntax error
Else
llContinuation = U1 OR U2
Endif

Bye, Olaf.

.



Relevant Pages

  • Re: Convert RTF to HTML
    ... I have a RTFstring and need to convert it to HTML using ... VFP. ... Is there any source code available to do this or any web references with ...
    (microsoft.public.fox.programmer.exchange)
  • Convert RTF to HTML
    ... I have a RTFstring and need to convert it to HTML using ... VFP. ... Is there any source code available to do this or any web references with ...
    (microsoft.public.fox.programmer.exchange)
  • Solution to File Tranfer Problem
    ... I read you post with interest as I will be embarking on a similar project with VFP and am curious whether you found a solution to the corrupted data problem you were experiencing. ... Interactive Computer Services Inc. ... problem is that example only transfers a string of data. ... "chunks" of data are not being properly sent. ...
    (microsoft.public.fox.programmer.exchange)
  • Including in VC6 project - compile errors
    ... C2059: syntax error: 'string' ... not a UDT or reference to a UDT. ... if applied using infix notation) ...
    (microsoft.public.vc.stl)
  • Re: STRTRAN() extrem langsam
    ... HTML gewisse Zeichen maskieren musst, stehst Du vor dem gleichen Problem. ... Hab schön öfters mal String Algorithmen in FLL's gepackt, ... Funktion nur zwei Speicher Allokationen macht und dabei vom "Worst Case" ... Wie macht VFP das? ...
    (microsoft.public.de.fox)