EasyLanguage Tutorial 196 | Scope in methods (plus convert a function to a method) | Part 2

8 months ago

Tutorial 196 gives an example of “scope” in the context of a method.

A common guideline in good programming practice suggests that a method should ideally only utilize variables that are provided through its parameter list or those that are locally declared within the method itself. However, there are situations where adhering strictly to this principle might be overly cumbersome or impractical. In such cases, it becomes possible to reference variables that have been declared at a the EasyLanguage study level.

Both “types” of methods are demonstrated in this tutorial.

When a variable is declared within the primary section of a study, it can be directly accessed and modified throughout that study. Nevertheless, when a method is invoked, it operates within its designated scope by design. This means that a variable declared within a method is confined to that method’s scope. Even if a variable with an identical name exists elsewhere, it is treated as a distinct and separate entity, maintaining its own distinct scope within the method.

To demonstrate converting the functions to methods two functions are used:

XAverage (a series function), and
Average( a simple function)

See https://markplex.com/free-tutorials/tutorial-196-scope-in-methods-plus-convert-a-function-to-a-method/

Loading comments...