Reference.Scope History

Hide minor edits - Show changes to markup

July 02, 2013, at 10:57 AM by Roberto Guido - minor typo correction. Thanks to Ignacio Hoyos Rodríguez for alert
Changed lines 7-8 from:

Cuando los programas crecen en tamaño y complejidad, las variables globales son una forma útil de asegurar que sólo una función tiene acceso a sus propias variables. Esto previene errores de programación al evitar que una función modifique, involuntariamente, variables de otras funciones.

to:

Cuando los programas crecen en tamaño y complejidad, las variables locales son una forma útil de asegurar que sólo una función tiene acceso a sus propias variables. Esto previene errores de programación al evitar que una función modifique, involuntariamente, variables de otras funciones.

June 01, 2010, at 09:32 AM by Equipo Traduccion -
Changed lines 1-13 from:

Variable Scope

Variables in the C programming language, which Arduino uses, have a property called scope. This is in contrast to languages such as BASIC where every variable is a global variable.

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop(), etc. ), is a global variable.

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its own variables. This prevents programming errors when one function inadvertently modifies variables used by another function.

It is also sometimes handy to declare and initialize a variable inside a for loop. This creates a variable that can only be accessed from inside the for-loop brackets.

Example:

[@int gPWMval; // any function will see this variable

to:

Ámbito de las variables

Las variables en el lenguaje de programación C, usado por Arduino, tienen una propiedad llamada ámbito. Al contrario de lo que pasa en lenguajes como BASIC en los que todas las variables son globales.

Una variable global puede verse por todas las funciones de un programa. Las variables locales son sólo visibles desde la función en las que están declaradas. En el entorno Arduino, cualquier variable declarada fuera de la función (por ejemplo setup(), loop(), etc.), es una variable global.

Cuando los programas crecen en tamaño y complejidad, las variables globales son una forma útil de asegurar que sólo una función tiene acceso a sus propias variables. Esto previene errores de programación al evitar que una función modifique, involuntariamente, variables de otras funciones.

A veces es útil declarar e inicializar una variable dentro de un bucle for. Esto crea una variable que sólo se puede acceder desde dentro del bucle.

Ejemplo

[@int gPWMval; // cualquier función va a tener acceso a esta variable

Changed lines 21-22 from:
  int i;    // "i" is only "visible" inside of "loop"
  float f;  // "f" is only "visible" inside of "loop"
to:
  int i;    // "i" es sólo accesible dentro de "loop"
  float f;  // "f" es sólo accesible dentro de "loop"
Changed line 26 from:
  // variable j can only be accessed inside the for-loop brackets
to:
  // la variable j sólo es accesible desde el bucle for
January 06, 2009, at 10:32 PM by Paul Badger -
Changed lines 7-8 from:

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its variables. This prevents programming errors when one function inadvertently modifies variables used by another function.

to:

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its own variables. This prevents programming errors when one function inadvertently modifies variables used by another function.

December 29, 2008, at 12:35 AM by Paul Badger -
Changed lines 9-10 from:

It is also sometimes handy to declare and initialize variables inside for loops. This creates variables that can only be accessed from inside the for-loop brackets.

to:

It is also sometimes handy to declare and initialize a variable inside a for loop. This creates a variable that can only be accessed from inside the for-loop brackets.

December 29, 2008, at 12:34 AM by Paul Badger -
Changed lines 9-10 from:

It is also sometimes handy to declare and initialize variables inside for loops. This creates variables that can only be accessed from inside the for loop brackets.

to:

It is also sometimes handy to declare and initialize variables inside for loops. This creates variables that can only be accessed from inside the for-loop brackets.

Changed line 26 from:
  // variable j can only be accessed inside the for loop brackets
to:
  // variable j can only be accessed inside the for-loop brackets
December 29, 2008, at 12:33 AM by Paul Badger -
Changed lines 25-30 from:

for (int j = 0; j <100; j++){ // variable j can only be accessed inside the for loop brackets }

to:
  for (int j = 0; j <100; j++){
  // variable j can only be accessed inside the for loop brackets
  }
December 29, 2008, at 12:32 AM by Paul Badger -
Changed lines 5-6 from:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

to:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop(), etc. ), is a global variable.

Added lines 9-10:

It is also sometimes handy to declare and initialize variables inside for loops. This creates variables that can only be accessed from inside the for loop brackets.

Added lines 24-30:

for (int j = 0; j <100; j++){ // variable j can only be accessed inside the for loop brackets }

September 06, 2008, at 09:06 PM by Paul Badger -
September 06, 2008, at 09:04 PM by Paul Badger -
Changed lines 3-4 from:

Variables in the C programming language, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a global variable.

to:

Variables in the C programming language, which Arduino uses, have a property called scope. This is in contrast to languages such as BASIC where every variable is a global variable.

September 06, 2008, at 08:54 PM by Paul Badger -
September 06, 2008, at 08:53 PM by Paul Badger -
Changed lines 5-6 from:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

to:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

July 17, 2007, at 08:10 PM by David A. Mellis - formatting example code
Changed lines 12-13 from:

void setup(){ // ...

to:

void setup() {

  // ...
Changed lines 17-20 from:

void loop(){ int i; // "i" is only "visible" inside of "loop" float f; // "f" is only "visible" inside of "loop" // ...

to:

void loop() {

  int i;    // "i" is only "visible" inside of "loop"
  float f;  // "f" is only "visible" inside of "loop"
  // ...
July 17, 2007, at 08:10 PM by David A. Mellis - IDE -> environment
Changed lines 5-6 from:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino IDE, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

to:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

July 17, 2007, at 06:51 AM by Paul Badger -
Changed lines 5-6 from:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared.

to:

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino IDE, any variable declared outside of a function (e.g. setup(), loop() ), is a global variable.

May 15, 2007, at 05:07 AM by Paul Badger -
Changed lines 7-8 from:

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its variables. This prevents inadvertent programming bugs when one function modifies variables used by another function.

to:

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its variables. This prevents programming errors when one function inadvertently modifies variables used by another function.

May 15, 2007, at 05:05 AM by Paul Badger -
Added lines 7-8:

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its variables. This prevents inadvertent programming bugs when one function modifies variables used by another function.

May 04, 2007, at 01:15 PM by Paul Badger -
Changed lines 15-16 from:

int i; // only "visible" inside of "loop" float f;

to:

int i; // "i" is only "visible" inside of "loop" float f; // "f" is only "visible" inside of "loop"

May 04, 2007, at 01:14 PM by Paul Badger -
Changed lines 8-10 from:

int gPWMval; // any function will see this variable

to:

[@int gPWMval; // any function will see this variable

Changed line 18 from:

}

to:

}@]

May 04, 2007, at 01:13 PM by Paul Badger -
Changed lines 3-19 from:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a gloabal variable.

to:

Variables in the C programming language, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a global variable.

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared.

Example:

int gPWMval; // any function will see this variable

void setup(){ // ... }

void loop(){ int i; // only "visible" inside of "loop" float f; // ... }

May 04, 2007, at 01:07 PM by Paul Badger -
Changed line 3 from:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a //gloabal// variable.

to:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a gloabal variable.

May 04, 2007, at 01:05 PM by Paul Badger -
Changed line 3 from:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a !!!gloabal!!! variable.

to:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a //gloabal// variable.

May 04, 2007, at 01:04 PM by Paul Badger -
May 04, 2007, at 01:04 PM by Paul Badger -
Changed line 3 from:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a !!gloabal!! variable.

to:

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a !!!gloabal!!! variable.

May 04, 2007, at 01:04 PM by Paul Badger -
Added lines 1-3:

Variable Scope

Variables in the C programming languange, which Arduino uses, have a property called "scope". This is in contrast to languages such as BASIC where every variable is a !!gloabal!! variable.

Share