Micro Focus QTP (UFT) Forums
How to minimze the script - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to minimze the script (/Thread-How-to-minimze-the-script)



How to minimze the script - venkatbatchu - 10-20-2009

I have a 500 lines of script among this 300 lines of code start with
Browser("xxxxx").Page("xxxx").Frame("xxxxx") this sentense

i would like to minimze this code instead of writing entire thing in 300 lines , i just want to assign this entire sentense in to a variable and wherever it is required i want to pass this variable and with some extensions (according to my requirement like webedit, weblist, webelement,.....)

Please let me know how to minimze the script

Thanks in advance,
Venkat.Batchu


RE: How to minimze the script - basanth27 - 10-20-2009

Code:
Set oRobj = Browser("xxxxx").Page("xxxx").Frame("xxxxx") 'write this as the first line
' -- Do a Find and Replace , would look like below.
oRobj.Weblist("xx").Select "xxx"

Set oRobj = Nothing ' -- Write this at the 500th line



RE: How to minimze the script - sreekanth chilam - 10-20-2009

Hi Venkat,

You can use "With" statements for ensuring precise & more readable code.

In QTP , Go to Edit Menu --> Apply "With" Statements --> Click OK

Let me know if it helps you Smile


RE: How to minimze the script - venkatbatchu - 10-20-2009

Thanks alot Basanth,
Now i am clear about these things....