home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases
- Path: sparky!uunet!munnari.oz.au!sgiblab!spool.mu.edu!agate!dog.ee.lbl.gov!news!humu!pegasus!tleylan
- From: tleylan@pegasus.com (Tom Leylan)
- Subject: Re: dBASE III+/Foxbase Question
- Message-ID: <1993Jan27.081213.22583@pegasus.com>
- Organization: Pegasus, Honolulu
- References: <1jsb6gINN5kj@golem.wcc.govt.nz>
- Date: Wed, 27 Jan 93 08:12:13 GMT
- Lines: 70
-
- cocks_d@kosmos.wcc.govt.nz writes:
-
- I don't know if anybody is interested in discussions on coding style
- since people seem to take so many things so very person but I'll try
- a few suggestions since the opportunity presented itself
-
- >STORE "" TO METHOD
- >@10,10 say "Output method (S)creen, (P)rinter or (F)ile"
-
- The empty string won't work. Consider "unpacking" code by adding
- spaces for readability. If you use an interpreter it might help to
- squeeze them out but use a software tool when the app is done.
-
- >DO WHILE .T. && Endless loop which will be broken by the EXIT command
- > @10,2 get METHOD
- > READ
-
- Avoid uncontrolled loops. Yes you can EXIT, no you should not. Set a
- variable or controlling expression and exit from the end of the loop.
- Consider not commenting "DO WHILE .T." it is like "Var = 5" if one
- can't figure it out no amount of commenting will help.
-
- > IF METHOD $ "SPFspf" && Does the letter S,P or F appear in variable METHOD?
- > EXIT
- > END IF
- >ENDDO
-
- You wouldn't have needed to (and shouldn't) test both upper and lowercase
- command characters if you had used the appropriate picture statement in
- the GET.
-
- >DO CASE
- > CASE METHOD $ "Ss"
- > && Don't do a thing cause will default to screen
- > CASE METHOD $ "Pp"
- > SET CONSOLE OFF && Turn off screen
- > SET PRINTER ON
- > CASE METHOD $ "Ff"
- > STORE "" to FILENAME
- > @12,10 say "Name of file" GET FileName
- > READ
- > SET CONSOLE OFF
- > SET ALTERNATIVE TO FileName
- >END CASE
-
- Consider not adding a CASE statement that doesn't do anything. If you
- need an empty "default" the OTHERWISE "case" is provided but even that
- isn't needed here.
-
- >... and tidy up housekeeping
- >SET PRINTER OFF
- >SET CONSOLE ON
- >CLOSE ALTERNATIVE
- >SET ALTERNATIVE TO
-
- As a general rule one should avoid "untidying" what wasn't tidied to
- begin with. It would take a little reorganization of the code but
- if the ALTERNATIVE hasn't be OPENED then one shouldn't CLOSE it and
- yes I realize that it doesn't break anything by doing so... in this
- example using this language. It is however a poor habit to get into.
-
- Hope this has been of some benefit to the parties involved, if you want
- to discuss it I'd be happy to but if you're going to tell me to go take
- a flying leap it wasn't my intention to degrade anybody just to offer
- assistance.
-
- Take it or leave it.
-
- tom "you can tell I've grown a bit leery of Usenet" leylan
-
-