Posts: 9
Threads: 5
Joined: Apr 2011
Reputation:
0
06-24-2011, 08:07 PM
Hi ,
What is the use of Dim , Option Explicit ?
While writing script if we didn't write Dim and Option Explicit the script will rum or not?
Thanks
Posts: 23
Threads: 1
Joined: May 2011
Reputation:
0
07-07-2011, 12:19 PM
Dim is for declaring a variable.and Option explicit makes it mandatory for the script writer to declare the variable.
If you have Option Explicit in your script, and you don't declare the variable using Dim ,the script throws an error.
Posts: 275
Threads: 4
Joined: Jul 2011
Reputation:
0
07-07-2011, 10:53 PM
While writing script if we didn't write Dim and Option Explicit the script will rum or not?
Yes it runs successfully
Posts: 3
Threads: 0
Joined: Aug 2011
Reputation:
0
08-09-2011, 08:21 PM
Hi,
There are two types of Variable Declaration Explicit and Implicit
Explicit way of Declaration
Dim str1
str1 = "Test"
Implicit way of Declaration
str1 = "Test"
When you use Option Explicit you should declare the variable by Explicit way. Otherwise you will get "Error 500" -"Variable is undefined"
Posts: 4
Threads: 0
Joined: Jul 2010
Reputation:
0
08-10-2011, 12:02 AM
if you use 'option explcit' in your script you should declare the variable in the script.otherwise u will get error.
Dim is used for declaring the variables.
Posts: 40
Threads: 1
Joined: Feb 2011
Reputation:
0
08-10-2011, 12:05 AM
That's exactly what I want. I want to declare the variable name I want to use. Then if I try to use a mis-typed the variable name, QTP throws an error so I know I screwed it up. That way I don't get weird results when the script goes into "production".
Posts: 41
Threads: 6
Joined: Jun 2011
Reputation:
0
11-24-2011, 12:42 PM
Hi,
When there are more number of variables it is better to use option Explicit. That will help us in debugging if go wrong with the variables any where in the script.
krr