Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>public</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
PUBLIC


Syntax:     PUBLIC <memvar list/array list>

Purpose:    To declare memory variables and/or arrays as available to
            all procedures within a program.

Argument:   <memvar list> is the list of memory variables and/or
            arrays to declare PUBLIC.  If an array is specified, it is
            created according to the dimension specified.

Usage:      Declaring a memory variable PUBLIC when the variable does
            not exist creates a new logical memory variable with an
            initial value of false (.F.).  Once assigned a value, its
            scope is global and the variable becomes available to all
            procedures within the program.  Note that you cannot declare
            an existing private variable PUBLIC.  If you do this,
            Clipper simply ignores the declaration and the memory
            variable retains its private status and scope.  Public
            variables, however, can be temporarily hidden from other
            procedures by declaring them PRIVATE.

            Arrays: In addition to declaring PUBLIC memory
            variables, you can declare PUBLIC arrays.  Declaring an
            array PUBLIC creates an array with the specified number of
            elements whose scope is all procedures in the current
            program.  Note, however, that PUBLIC array elements are
            undefined until assigned a value.

            For more information on arrays, see DECLARE.

            PUBLIC Clipper: To include Clipper extensions in a
            program and still allow the program to run under dBASE III
            PLUS the special memory variable, "clipper," is initialized
            to true (.T.) when declared PUBLIC.  Using "clipper" as the
            argument of an IF...ENDIF construct blocks Clipper-specific
            code so these lines of code are not executed when run under
            dBASE III PLUS.

            Note that compilation errors occur when the syntax of the
            dBASE III PLUS commands is not supported.  In this instance,
            comment out statements you do not want compiled.

Library:    CLIPPER.LIB


----------------------------------- Examples -------------------------------

   This example declares a series of memory variables and arrays PUBLIC:

   PUBLIC var1, var2, array1[10], array2[10]

   The following example demonstrates the different scoping behaviors of
   private and PUBLIC memory variables:

   ? TYPE("var1")       && Results: U
   ? TYPE("var2")       && Results: U

   DO Proc1

   ? TYPE("var1")       && Results: C
   ? TYPE("var2")       && Results: U
   RETURN

   PROCEDURE Proc1
   PUBLIC var1
   var1 = "string1"
   var2 = "string2"
   RETURN


   The following is an example of code using the PUBLIC memory variable
   "clipper" to allow Clipper enhancements in a program that runs under
   dBASE III PLUS without error:

   PUBLIC clipper

   @ 25, 10 SAY "Press any key to continue..."

   IF clipper
      key = INKEY(0)
   ELSE
      key = INKEY()
      DO WHILE key = 0
         key = INKEY()
      ENDDO
   ENDIF


See Also: DECLARE PARAMETERS PRIVATE

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson