6 Replies Latest reply: Jul 26, 2017 5:29 AM by Rajashekar Jaidi

# Set and Let

what is the difference b/w set and let?

What is the use of that? And when we are using please tel me.....

• ###### Re: Set and Let

Hi Rajashekar,

:SET :

The SET statement is used when you want a variable to hold the string or numeric value that is to the right of the Equal (=) sign.

When used, the variable is substituted by its value.

• Variables can be used in the script for macro expansion and in various control statements.
• This is very useful if the same string is repeated many times in the script, e.g. a path.

Set variable = string

Eg : Set Myvar=2*3 returns “ 2*3”

LET :

The let statement, in opposition to the set statement, evaluates the expression on the right side of the ' =' before it is assigned to the macro variable.

Let variable = Expression

Eg : Let MyVar =2*3 returns “6”

Hope it helps..

Thanks,

Arvind Patil

• ###### Re: Set and Let

Hi Jaidi,

i hope taht helps

Beck

• ###### Re: Set and Let

Thank you so much...............

• ###### Re: Set and Let

In simple words; let performs the calculation while set does not

Exp:

Set 3+2 => 3+2

Let 3+2 => 5

• ###### Re: Set and Let

Hi Rajashekar,

Let:-

The let statement is a complement to the set statement, used for defining script variables. The let statement, in opposition to the set statement, evaluates the expression on the right side of the ' =' before it is assigned to the variable.

Syntax:-Let variablename=expression

Set:-

The set statement is used for defining script variables. These can be used for substituting strings, paths, drives, and so on.

Syntax:- Set variablename=string

• ###### Re: Set and Let

Use SET if you want to assign a static value to a variable

e.g. SET Dept = 'Accounts';

Use LET if you want to assign a value resulting from expression (Dynamically)

e.g. LET Dept = Peek('DepartmentName',0,'MyDept');

Regards!

Rahul Pawar