Raised This Month: $ Target: $400
 0% 

static variable - question


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-04-2012 , 13:34   Re: static variable - question
Reply With Quote #4

See http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
Code:
• Static local declarations 

A local variable is destroyed when the execution leaves the compound block 
in which  the variable was created.         Local  variables  in a  function  only  exist 
during the run time of that function.  Each new run of the function creates 
and  initializes new  local  variables.      When  a  local  variable is  declared  with 
the keyword static rather than new, the variable remains in existence after 
the  end  of  a  function.    This  means  that  static  local  variables  provide  pri- 
vate,  permanent  storage  that  is  accessible  only  from  a  single  function  (or 
compound  block).       Like  global  variables,  static local  variables  can  only  be 
initialized with constant expressions. 

• Static global declarations 

A static global variable behaves the same as a normal global variable, except 
that  its  scope  is  restricted  to  the  file  that  the  declaration  resides  in.      To 
declare a global variable as static, replace the keyword new by  static. 

[ ... ]

• Progressive initiallers for arrays 

The ellipsis operator continues the progression of the initialisation constants 
for an array, based on the last two initialized elements.  The ellipsis operator 
(three dots, or “ ...”)  initializes the array up to its declared size. 

Examples: 

Listing:  array  initializers 

      new a[10] = { 1, ... }                // sets all ten elements to 1 
      new b[10] = { 1, 2, ... }             // b = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 
      new c[8] = { 1, 2, 40, 50, ... }      // c = 1, 2, 40, 50, 60, 70, 80, 90 
      new d[10] = { 10, 9, ... }            // d = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-04-2012 at 13:48.
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode