Navigation:  Reference > Commands >


Print this Topic Previous pageReturn to chapter overviewNext page


You would use this command to end a subroutine called with the GOSUB command, a UDF/UDC or an event called from an object on a form.


RET f/c/eIf this is a return from a UDF, or certain form object events, you may specify a value to be returned.


       A value can only be returned in the case of a UDF.  In the case of a UDC or a return from a subroutine called through the GOSUB command the RET should not be followed by a value.  In any case it will have no effect.


PROGRAM EDITOR        prg Control  -> Goto/gosub  -> Ret









         X = USER_FUNC()





        //This is a simple function, it just returns the number 1        

        RET 1


       The value of X will be set to 1 in the example above.


       Another example would be in the OnClose event in a form.  This example assumes you have set the label name to CheckClose:



        //Make sure the user has entered a value into XYZ

         Ret XYZ<>''


In this example the program will evaluate whether XYZ is blank first and will return .TRUE. if it has something in it, or .FALSE. if not.  You could've also just returned the appropriate value, e.g:



        //I don't want to close now.

        RET .FALSE.


Obviously, you would want to change the label for the OnClose event at some time or the user would never be able to exit out of the program (short of Alt-Ctrl-Del), but that is beyond this section and is covered more fully in the Form Objects section.







Page url: