home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / 9465 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.7 KB  |  81 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!munnari.oz.au!sgiblab!spool.mu.edu!agate!dog.ee.lbl.gov!news!humu!pegasus!tleylan
  3. From: tleylan@pegasus.com (Tom Leylan)
  4. Subject: Re: dBASE III+/Foxbase Question
  5. Message-ID: <1993Jan27.081213.22583@pegasus.com>
  6. Organization: Pegasus,  Honolulu
  7. References: <1jsb6gINN5kj@golem.wcc.govt.nz>
  8. Date: Wed, 27 Jan 93 08:12:13 GMT
  9. Lines: 70
  10.  
  11. cocks_d@kosmos.wcc.govt.nz writes:
  12.  
  13. I don't know if anybody is interested in discussions on coding style
  14. since people seem to take so many things so very person but I'll try
  15. a few suggestions since the opportunity presented itself
  16.  
  17. >STORE "" TO METHOD
  18. >@10,10 say "Output method (S)creen, (P)rinter or (F)ile"
  19.  
  20. The empty string won't work.  Consider "unpacking" code by adding
  21. spaces for readability.  If you use an interpreter it might help to
  22. squeeze them out but use a software tool when the app is done.
  23.  
  24. >DO WHILE .T. && Endless loop which will be broken by the EXIT command
  25. > @10,2 get METHOD
  26. > READ
  27.  
  28. Avoid uncontrolled loops.  Yes you can EXIT, no you should not.  Set a
  29. variable or controlling expression and exit from the end of the loop.
  30. Consider not commenting "DO WHILE .T." it is like "Var = 5" if one
  31. can't figure it out no amount of commenting will help.
  32.  
  33. > IF METHOD $ "SPFspf" && Does the letter S,P or F appear in variable METHOD?
  34. >  EXIT
  35. > END IF
  36. >ENDDO
  37.  
  38. You wouldn't have needed to (and shouldn't) test both upper and lowercase
  39. command characters if you had used the appropriate picture statement in
  40. the GET.
  41.  
  42. >DO CASE
  43. > CASE METHOD $ "Ss"
  44. >  && Don't do a thing cause will default to screen
  45. > CASE METHOD $ "Pp"
  46. >  SET CONSOLE OFF && Turn off screen
  47. >  SET PRINTER ON
  48. > CASE METHOD $ "Ff"
  49. >  STORE "" to FILENAME
  50. >  @12,10 say "Name of file" GET FileName
  51. >  READ
  52. >  SET CONSOLE OFF
  53. >  SET ALTERNATIVE TO FileName
  54. >END CASE
  55.  
  56. Consider not adding a CASE statement that doesn't do anything.  If you
  57. need an empty "default" the OTHERWISE "case" is provided but even that
  58. isn't needed here.
  59.  
  60. >... and tidy up housekeeping
  61. >SET PRINTER OFF
  62. >SET CONSOLE ON
  63. >CLOSE ALTERNATIVE
  64. >SET ALTERNATIVE TO
  65.  
  66. As a general rule one should avoid "untidying" what wasn't tidied to
  67. begin with.  It would take a little reorganization of the code but
  68. if the ALTERNATIVE hasn't be OPENED then one shouldn't CLOSE it and
  69. yes I realize that it doesn't break anything by doing so... in this
  70. example using this language.  It is however a poor habit to get into.
  71.  
  72. Hope this has been of some benefit to the parties involved, if you want
  73. to discuss it I'd be happy to but if you're going to tell me to go take
  74. a flying leap it wasn't my intention to degrade anybody just to offer
  75. assistance.
  76.  
  77. Take it or leave it.
  78.  
  79. tom "you can tell I've grown a bit leery of Usenet" leylan
  80.  
  81.