| USING MODULES |
Here’s how it
works:
Whenever you’re editing a FORM, you
can click the FORM properties, and you’ll find 5 properties called
Module1,Module2,Module3,Module4,Module5.
Each module can contain up to 32,000 characters of code. These 5 modules are not specific to the
form you’re editing. They are
available to EVERY form in your database.
Let’s look at a very ‘useless’
example. Perhaps your application
will need to test the value of a variable called VALUE and notify you of whether
it is equal to 1,2,3, or else give you an error message. Let’s also assume that you’ll need to
perform this test MANY times throughout your code!
Well, rather than duplicating the
following lines of code EVERY time you need to run this test, you can instead
place this code in one of the modules, and ‘call’ it using the following RUNSUB
statement from anywhere else in your application:
RUNSUB(TEST_VALUE)
Notice that for this to work, you
need to preface the block of code with the name of the subroutine. Subroutine names are prefixed with a
colon.
Whenever you want the subroutine to
‘return’ control to the calling code, you can use the RETURN()
statement.
:TEST_VALUE
TEST(<!value!>//=//1)
MESSAGE(“one”//”one”)
RETURN()
ENDTEST()
TEST(<!value!>//=//2)
MESSAGE(“two”//”two”)
RETURN()
ENDTEST()
TEST(<!value!>//=//3)
MESSAGE(“three”//”three”)
RETURN()
ENDTEST()
MESSAGE(“You
did not enter a valid value!”//”ERROR”)
RETURN()
NEXT >>>