Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programatically find Return within WITH / ENDWITH
Message
From
23/06/2008 23:40:51
 
 
To
23/06/2008 20:00:40
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01326207
Message ID:
01326253
Views:
16
Dragan --

Your approach made me wonder why I couldn't do the same thing using Code References -- but without the need to analyze all code in .PRG files and the like. (Fairly sure I could do it if needed, also fairly sure it would take me a while.)

Instead, I've been working on a solution that looks more or less like:

(1) Using Code References to find all lines containing WITH, ENDWITH and RETURN
(2) Export to a DBF
(3) Analyze the results with a single pass through the file (essentially mimicking your sample code).

This seems to work fairly well (so far).

I've noted that
(1) I only search for WITH, ENDW and RETU, since these abbrevations are allowed. I avoid them, but that's not true for all code I've gotten from other places.
(2) There's some possibility for "false negatives", as I have lines that begin with a difference usage of WITH:
 Replace all SomeField;
with SomeValue
Again, not the way I would write code now, but I must have done so in the past.

I've actually found 137 possible problems that I must investigate; most look like real problems that will need to be corrected.

Sigh. I thought I had gotten rid of these before.

Jim




>>Anybody have a programmatic way of finding RERURNs within WITH/ENDWITH constructions?
>>
>>I thought I had one, but have found it didn't do a very good job.
>
>Assuming you got all the code in .prg files (by either running SccText or class browser export), apply aProcInfo() so you can break the code into snippets - substrings of the whole .prg.
>
>Assuming now that you got one prg/method at a time in a string, chop that into lines using aLines(), then redimension the array you got to be two dimensional and append all into a cursor... like this:
>
>
lparameters tcText
>n=alines(aRows, tcText)
>for i=1 to n
>   aRows[i]=allt(chrtran(aRows[i], chr(9), " "))   && trim out any leading tabs
>endfor
>dimension aRows[n,1]  && make it 2-dim for Append
>create cursor crsRows (cRow c(200), nLevel i)
>append from array aRows
>lnLevel=0
>scan
>   do case
>      case lower(cRow)="with "
>         lnLevel=lnLevel+1
>      case lower(cRow)="endwith "
>         lnLevel=lnLevel-1
>   enddo
>   replace nlevel with lnLevel
>endscan
>browse for cRow="retu" and nLevel>0
>
>Of course, you can add row numbers and other stuff, make things easier to find in code references, etc. No guarantee, batteries not included, just an idea, code off headtop.
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform