Understanding the RETURN Command

ID: Q119900

2.00 2.5x 2.60 2.60a | 2.5x 2.60 2.60a 3.00 | 2.5x      | 2.60
MS-DOS               | WINDOWS              | MACINTOSH | UNIX

The information in this article applies to:

SUMMARY

The RETURN command provides a great deal of flexibility over program control. RETURN terminates execution of a program, procedure, or function. Depending on how RETURN is used, control is returned to the calling program, the highest-level calling program, another program, or the Command window. The sample code below illustrates the power of the RETURN command.

MORE INFORMATION

Enter the following code in a program call RETTEST.PRG:

   PARAMETER x  && line 1

   ON ERROR DO myErr
   DO A
   WAIT WINDOW 'In master'   && line 5

   ON ERROR

   PROCEDURE A
   DO B
   WAIT WINDOW 'In A'   && line 11

   PROCEDURE B
   x=testing
   WAIT WINDOW 'In B'  && line 15

   PROCEDURE myErr
   DO CASE
     CASE x = 'master'
       RETURN TO MASTER
     CASE EMPTY(x)
       RETURN
     OTHERWISE
       RETURN TO &x
   ENDCASE

To demonstrate the capabilities of the RETURN command, try the following three invocations of the above program from the Command window. The program is so short that it may be helpful to use the Trace window and step through the code. For additional information about using the Trace window, see the "Debugging" chapter of the "Developer's Guide" and the "Program Menu" chapter of the "User's Guide."

REFERENCES

FoxPro "Language Reference"

Additional reference words: VFoxWin 3.00 FoxUnix FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.50c 2.60 2.60a KBCategory: KBSubcategory: FxtoolDebug

Keywords          : kbcode FxtoolDebug 
Version           : 2.00 2.5x 2.60 2.60a | 2.5x 2.60
Platform          : MACINTOSH MS-DOS UNIX WINDOWS

Last Reviewed: May 22, 1998