« Best practices with Visual FoxPro | Main | USE IN SELECT() to close a work area »

August 06, 2008

Copy- (or Cut)-and-paste as much as possible; avoid re-typing code!

For example:

LOCAL  lnTotalInvoice && Type only one (1) of the instances of 'lnTotalInvoice'
            lnTotalInvoice = … && and then copy-and-paste it for all other instances

This helps prevent inadvertent typos (are there any other kind?!) from creeping into your code.

It is also helpful when you communicate with other developers (e.g., via e-mail when posting to an on-line news group or message board) so that you don’t accidentally modify the code in question (again introducing that inadvertent typo <g>).

Doug Carpenter reminded me of a trick when working with memory variables that have been declared LOCAL and PUBLIC (but not PRIVATE):
typing ZLOC followed by the <Spacebar> in a .Prg file/method causes VFP to display an IntelliSense list of available LOCAL and PUBLIC memvars and parameters.

Here is an example of the list that displays after you press the <Spacebar>:
    lcString
    llCustom
    llError
    llSuccess
    loException

Posted by abergquist on August 6, 2008 | Permalink

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341fba8753ef00e553d2955c8833

Listed below are links to weblogs that reference Copy- (or Cut)-and-paste as much as possible; avoid re-typing code! :

Comments

Good for people to know.

Posted by: Melanie | Oct 28, 2008 9:45:21 PM

Post a comment