|
|
|
|
What is the use of DIM ?
|
|
06-24-2011, 08:07 PM
Post: #1
|
|||
|
|||
|
What is the use of DIM ?
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 |
|||
|
07-07-2011, 12:19 PM
Post: #2
|
|||
|
|||
|
RE: What is the use of DIM ?
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. (06-24-2011 08:07 PM)shyam.emmadi Wrote: Hi , |
|||
|
07-07-2011, 10:53 PM
Post: #3
|
|||
|
|||
|
RE: What is the use of DIM ?
While writing script if we didn't write Dim and Option Explicit the script will rum or not?
Yes it runs successfully |
|||
|
08-09-2011, 08:21 PM
Post: #4
|
|||
|
|||
|
RE: What is the use of DIM ?
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" |
|||
|
08-09-2011, 08:39 PM
Post: #5
|
|||
|
|||
|
RE: What is the use of DIM ?
I personally am starting like Option Explicit more and more. It keeps me from making dumb mistakes like this:
dim recurring recurrring=browser(<whatever>).page(<whatever>).WebLink(<whatever>).GetROProperty("innertext") if recurring="clickme" then ... I have done this too many times - declared a variable and then used a mis-typed version of the variable later on. Infuriating! |
|||
|
08-10-2011, 12:02 AM
Post: #6
|
|||
|
|||
|
RE: What is the use of DIM ?
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. |
|||
|
08-10-2011, 12:05 AM
Post: #7
|
|||
|
|||
RE: What is the use of DIM ?
(08-10-2011 12:02 AM)Kasanagottu Wrote: if you use 'option explcit' in your script you should declare the variable in the script.otherwise u will get error. 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". |
|||
|
11-24-2011, 12:42 PM
Post: #8
|
|||
|
|||
|
RE: What is the use of DIM ?
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 |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
|
|

Search
Member List
Calendar
Help



