Scripting Guide > JSL Building Blocks > Rules for Name Resolution > Frequently Asked Questions about Name Resolution
Publication date: 04/12/2021

Frequently Asked Questions about Name Resolution

Should you always scope?

Yes. When in doubt, scope. Scoping is especially important in scripts that might be used by many people on a variety of data tables; you will not necessarily know whether a name is used in two contexts (such as for both a global variable and column name).

If you are writing such scripts, consider using explicit scoping and namespaces. See Advanced Scoping and Namespaces.

Prefix scope operators do not take run-time overhead after the first resolution. Infix scope operators, which follow data table references, always take run-time overhead.

What is the difference between a column reference and a column referred to by name? If I have a column reference in a global variable, how do I assign a value to a cell in the column?

With a column reference, you can send messages to change specific characteristics of the column or to access its values (for example, coloring cells or setting a formula).

When a column has been assigned to a global variable, assign a value to a cell in the column using a subscript. Suppose that the name of the column height has been assigned to the x variable:

x = Column( "height" );

Assign a value to the third row in the height column:

x[3] = 64 // sets the third row of height to 64

Note: The current row in a JSL script is not determined by selecting rows or positioning your cursor in the row. The current row is defined to be zero (no row) by default. You can set a current row with Row() (for example, Row() = 3). Please note that such a setting only lasts for the duration of that script. Then, Row() reverts to its default value, zero. This behavior means that submitting a script all at once can produce different results than submitting a script a few lines at a time.

Another way to establish a current row for a script is to enclose it in For Each Row(). This method executes the script once for each row of the current data table. For an example, see If. See Data Tables for more information about working with data tables.

Which Has Precedence When Scoping, ":" or "[ ]"?

Scoping occurs before subscripting. This means that these two lines of code are equal:

Want more information? Have questions? Get answers in the JMP User Community (