| **Navigation:**  [[clarion.htm|Clarion.Net (Clarion#)]] > [[clarion net language reference.htm|Clarion# Language Extensions]] > Variable and Entity Attributes >====== Variable Declaration outside of the DATA section ====== | [[public set variable public to all class modules .htm|{{btn_prev_n.gif|Previous page}}]][[clarion net language reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[new modified and unsupported expression operators .htm|{{btn_next_n.gif|Next page}}]] | | || {{newcnet.jpg|NewCNet.jpg}} For declaring data elements outside of any data section, the **OF** clause can be used for any local variable declaration. **Syntax:** //Label//** OF **//DataType//** = **//InitialValue// **Scope of new variable:** The new variable has the same scope as if it were declared in the CODE section, however it is NOT available in the CODE section prior to it's declaration line. The only requirement is that the variable //must// be initialized at the point of declaration. **Examples:** **UsingOF PROCEDURE()** ** CODE** **  A1 ****OF**** LONG = 1                     !A1 is declared as a LONG** **  L1 ****OF**** List<;LONG> = NEW List<;LONG>  !reference to generic list** **SomeMethod PROCEDURE()** **  INLINE** **  CODE** **    Ndx ****OF**** Int32=0** **    Customers ****OF**** List<;Customer> = NEW List<;Customer>** **    Cust0 ****OF**** Customer = NEW Customer()** **    Cust1 ****OF**** Customer = NEW Customer(){ LastName="Z", FirstName="Bob"}** **    Cust2 ****OF**** Customer = NEW Customer{ LastName="Z", FirstName="Bob"}** **    Cust3 ****OF**** Customer = NULL** **    LOOP I ****OF**** Int32 = 1 TO 4** **       !do something** **    END** **    FOREACH( Cust ****OF**** Customer IN Customers)** **       !do something** **    END** **  END !SomeMethod** {{notebox.jpg|NoteBox.jpg}} Compiler Errors can occur based on the following scenarios: ·No Initial Value: **CODE** **Ndx2 OF Int32 !<;-- compile error:** **Compiler error:** Unexpected end of line (CLA00384) ·The variable is accessed prior to declaration **CODE** **Debug.WriteLine(L) !<;-- compile error:** **L OF LONG = 0** **Compiler error:** L is being used before being declared (CLA00248) ·The variable declared already exists **CODE** **LOOP I OF Int32 = 1 TO 4** **!do something** **END** **LOOP I OF Int32 = 1 TO 4 !<;-- compile error:** **!do something** **END** **J Int32** **CODE** **J OF Int32 = 42 !<;-- compile error:** **Compiler error:** Identifier is already defined: 'I' (Cla00185) ' (in both examples). **See also: [[generics.htm|Generics]]**