🎯 User arguments definition – the true power of Scalar Calculator

Defining user arguments and constants is what makes Scalar unique in the panorama of available calculators. Take a moment to familiarize yourself with this short tutorial. It is definitely a dose of very useful knowledge. Stay tuned 🙂

⭐ Simple user arguments definition

In Scalar you can simply write x = 2, y = 2 * x, etc. Try it yourself. Pay particular attention to the fact that when defining the argument y, which depends on the argument x, the change in the value of x affects the value of y. In other words, Scalar remembers the expressions that define the arguments and uses these expressions at the time of requesting the value.

Scalar code result:

scalar > x = 2
scalar > x
e1 = 2
scalar > 2*x + 4
e2 = 8
scalar > y = 2*x + 4
scalar > y
e3 = 8
scalar > x = 3
scalar > y
e4 = 10

Scalar script:

x = 2
x
2*x + 4
y = 2*x + 4
y
x = 3
y

⭐ Arguments multi-dependencies

In terms of dependencies between arguments Scalar does not define any restrictions. You can create wide and deep dependency trees. This is well illustrated by the example below.

Scalar code result:

scalar > a = 3
scalar > b = 3*a + 2
scalar > c = a*b
scalar > d = a + b + c
scalar > d
e1 = 47
scalar > a = 4
scalar > d
e2 = 74
scalar > a = 5
scalar > d
e3 = 107

Scalar script:

a = 3
b = 3*a + 2
c = a*b
d = a + b + c
d
a = 4
d
a = 5
d

In certain situations, it is convenient to check how user elements are defined. Use the list command to do this.

list

Please note that Scalar assigns the results of the calculations to the constant, while the arguments are marked separately.

Scalar code result:

scalar > list
Type       Name/Value
----       ----------
Constant:  e1 = 47.0 -----    d
Constant:  e2 = 74.0 -----    d
Constant:  e3 = 107.0 -----    d
Argument:  a = 5.0 -----    a = 5
Argument:  b = 17.0 -----    b = 3*a + 2
Argument:  c = 85.0 -----    c = a*b
Argument:  d = 107.0 -----    d = a + b + c

Scalar script:

list

You can also use context help to verify the elements definition. Long click on the “example /?” button, then in the dialog select the user items.

⭐ User arguments vs user constants

The difference between the user constant and the user argument is fundamental. The constant only remembers the value, the argument remembers the expression, thanks to which the value can be calculated. You can define your own constant by adding the const command at the beginning.

const def

Scalar code result:

scalar > x = 3
scalar > const y = x^2
scalar > y
e1 = 9
scalar > x = 10
scalar > y
e2 = 9
scalar > list
Type       Name/Value
----       ----------
Constant:  y = 9.0 -----    y = x^2
Constant:  e1 = 9.0 -----    y
Constant:  e2 = 9.0 -----    y
Argument:  x = 10.0 -----    x = 10

Scalar script:

x = 3
const y = x^2
y
x = 10
y
list

It’s all for today. Thank you 🙂

🥇 Scalar Lite (Free) 🥇 Scalar Pro 