qck.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DEF FN Scope Rules
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
 DEF FN Scope Rules
 
 ■ The DEF FN statement is an exception to Visual Basic scoping rules. Every
   variable in a DEF FN statement that isn't in the function's parameter list
   is part of the module-level code.
 
 ■ To make a variable local to a DEF FN statement, you must declare the
   variable in a STATIC statement. See: STATIC Statement
 
 ■ The STATIC statement in the following DEF FN statement makes the variable
   "I" local:
 
         CONST NO = 0, YES = NOT NO
         DEF FNIsThereAZ (A$)
         STATIC I
              FOR I = 1 TO LEN(A$)
                   IF UCASE$(MID$(A$, I, 1)) = "Z" THEN
                        FNIsThereAZ = YES
                        EXIT DEF
                   END IF
              NEXT I
         FNIsThereAZ = NO
         END DEF
 
 ■ As a rule, use a FUNCTION statement rather than DEF FN for better
   portability, increased modularity, and a more structured programming
   style. See: FUNCTION Statement
 
 See: DEF FN Statement  Scope Rules