Subject Re: To call Function / Procedure
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Wed, 19 Jul 2023 10:39:10 -0700
Newsgroups dbase.getting-started

On 7/19/2023 10:20 AM, Milind Nighojkar wrote:
> Scenerio : To execute a common validation repitative code for an object in a form ?
>
> Can function / procedure  be created in a form ? How to call that function ?

Add the code below the constructor:

class form ...
    form constructor (details of the form, size, etc.)
    all the objects on the form

    usually a statement like:
    form.rowset = ...


    // add all your own code here:
    function MyValidation
       bReturn = true
       // whatever you need to do
       // set return to false if invalid
    return bReturn

endclass

Then in the code in the form if you want to perform the validation
routine you can do it in things like an onLostFocus event handler, and
call:   class::MyValidation() like:

    if not class::MyValidation()
       alert( "Something is not valid" )
       this.focus()
    endif

There are MANY ways to do things like this. If you haven't, you may want
to look at my books, and/or the dBASE Tutorial (see my signature block
below).

Ken



--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm