As those of you who use R:Style know, it will warn you about RETURNS from
within WHILE loops or SWITCH statements.  Recent versions of R:Base seem to
handle RETURN from SWITCH statements without a problem. I have not had any
problems lately with this usage.  Doesn't mean it could
not cause problems now, just that I have not noticed any problems at clients
who use this construction.

R:BASE 2000 v6.5+ DOS (32-bit), U.S. Version, Build: 1.839xRT03


But, yesterday I spent a good deal of time tracking down a problem with a
client app.  The application would blow to the R> prompt, complaining about
too many commands in a while loop.
This behavior only occurred for specific type of orders.  It was difficult
to track down.
The problem was finally tracked down to a WHILE loop used to get user input.
If the operator pressed escape, the RETURN command was used to exit the
module.
R:Base would go belly up as soon as it encountered another WHILE.
Solution:  THIS IS NOT COMPLETE WORKING CODE, JUST A QUICK VIEW OF THE
PROBLEM
-- BAD CODE
WHILE #PI IS NOT NULL THEN
   FILLIN ......
   IF (LASTKEY(0)) = '[ESC]' THEN
      RETURN
   ENDIF
ENDW

-- BETTER CODE
WHILE #PI IS NOT NULL THEN
   FILLIN ......
   IF (LASTKEY(0)) = '[ESC]' THEN
      BREAK
   ENDIF
ENDW
IF (LASTKEY(0)) = '[ESC]' THEN
   RETURN
ENDIF

Upshot of this is to write you code to avoid any complains from R:Style.
It will save you a lot of grief.



-- Dennis McGrath
mailto:[EMAIL PROTECTED]

-- Productivity Tools for R:Base Programmers
http://www.enteract.com/~mcgrath/dennis

-- Full time consultant with:
SQL Resources Group
Steve Hartmann
Oak Park, IL
mailto:[EMAIL PROTECTED]


Reply via email to