Search here for all the info you want in this Blog

Variable Scope


Variable Scope - The area of source code where a variable is accessible.
If you are not using procedures, variable scope is very simple. The scope of a variable is: from the statement where it is defined to the last statement of the code.
If you are using procedures, variable scope gets more complex. Here are some basic rules:
1. Global - If a variable is defined in the main code, its scope is from the statement where it is defined to the last statement of the entire code including all procedures.
2. Local - If a variable is defined in a procedure code, its scope is from the statement where it is defined to the last statement of the procedure.
3. Collision - If a variable is explicitly defined in a procedure code has the same name as a variable defined in the main code, the variable of the main code become in-accessible within this procedure.

No comments:

Post a Comment