Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find matching parenthesis, brackets or codeblock with the VFP buildin Editor

Status
Not open for further replies.

pixhub

Technical User
May 28, 2010
2
DE
Hi,

after 10 years not using VFP I have to look into old code, because the App still running.

When I rember right there was a shortcut to find matching brackets i.e., but sorry I do not remember this.

Somebody can help ?

Thanks in advance!
 
The moment you enter the closing bracket the block until the matching opening bracket becomes selected.

So if you want to find out for an existing bracket, delete it and enter it again. I don't think there's something working like that for the opening bracket.

For better formatting use Beautify and you may not need this except for very long codeblocks. Also I don'T think there is or ever was something for the kind of brackets of codeblocks that have words like endif, endfor, enddo, endcase, endscan, etc.

Chriss
 
Another thing you can do is set bookmarks and toggle between them with F2 and SHIFT+F2.

The best feature for navigate a PRG is by the document view.

Chriss
 
Some program editors have a feature whereby when you click on a parenthesis, it automatically highlights that parenthesis and the matching one. Unfortunately, the native VFP code editor doesn't have that feature. The best you can do is to delete the parenthesis and then type it again, at which point the editor highlights the entire block of code enclosed by the matching parentheses.

(This also works with square brackets, by the way.)

I wonder if anyone has written a third-party utility to check the parentheses in VFP code?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I see Thor has a tool for finding matching code blocks (that is, blocks of code within control structures like IF / ELSE / ENDIF, SCAN / ENDSCAN, FOR / ENDFOR, TRY / CATCH / ENDTRY). When you run it once, it highlights the inner-most structure; then each time you run it it (from the same position), it highlights the next outer structure.

You can download Thor here:
As far as I can see, it does not deal with matching parentheses but it should be possible to extend it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I once also saw a code viewer that used a treeview with expand/collaps function based on indentation which is working after beautify is done on the code. Beautify alone makes it readable already, but that could help with very long codeblocks. It only was a code viewer, no editor. I can imagine things like copy&paste become less easy once each code line becomes a treeview node.

Chriss
 
WOw, I'm having flashbacks of Scheme... after writing in that language for a couple of years, I became a savant in spotting parenthetic pairs. Never thought about the editor being able to do that... ><


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCAP, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
Many thanks,

"... delete the parenthesis and then type it again!"

this was it, simple , but I forgot it.

Best Regards
Steffen
 
Ah, and I thought there was another way also for the other block delimiters.

A detail not unknown, but also not very well known is that after an END... keyword the editor and compiler don't care, you can write what you like without using && to separate it from the code as a comment. So there you could also write a closing bracket.

But where to put the opening bracket. A comment before the IF would work, but I wouldn't like that. This needs a lot of changes to make that feature work for any block, could perhaps be automated, but then I'd prefer sensitivity for all the keywords that start and end a block, using normal brackets for that has the same disadvantage as JS, C, PHP and the like have letting every block be delimited by curly brackets. You can easily have a one off in two places that balance each other but are actually two mistakes that don't even out each other.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top