Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP with FUNCTIONS
#1
Solved: 11 Years, 4 Months ago
Hello,

I need some help with function. Have not really got any help from the QTP guides. I am confident someone can explain it to me in better terms.


We have multiple scenarios in out application the same steps are being performed. I would like to write function to limit the amount of code and maintenance.

For example - We have an option to create fields and choices, layouts, etc.

How can i call a function every time, if i need to create a field, instead or reusing a redundant script.

Any help will be appreciated. Thanks!
Reply
#2
Solved: 11 Years, 4 Months ago
more explanation for the scenario will help. if possible paste your lines of code of you functions that you have created.

Reply
#3
Solved: 11 Years, 4 Months ago
I think i made some progress on the answer to my intial question. but i do have a follow up. How can i set optional variables in a function.

for example.

public function create addressbook (byref name, byref address, byref city, by ref zip)

Code:
browser("main").page("flight").weblist("objecttype:dropdown").Select name
browser("main").page("flight").weblist("objecttype:dropdown").Select address
browser("main").page("flight").weblist("objecttype:dropdown").Select city
'etc

how can i implement optional variables as well? for instance if i wanted suitenumber to to applicable to some and not all.
is specifying all possible variables the only way?
Reply
#4
Solved: 11 Years, 4 Months ago
Optional parameters are not allowed in VBscript, neither is overloading. Unfortunantly, you must specify each one. you could always test the varible for a null or empty and just not use it.
Reply
#5
Solved: 11 Years, 4 Months ago
Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 3,222 08-22-2013, 11:43 AM
Last Post: smartkarthi
  exit parent functions as well Shridevi.Salagare 3 3,869 07-31-2013, 12:15 AM
Last Post: Ankur
  Datatable in functions shwetasharma 2 3,521 03-26-2013, 08:00 AM
Last Post: sams001
  Problem with using two functions in the same action mhanaan 2 3,043 09-14-2012, 10:09 PM
Last Post: mhanaan
  Can you do functions by calling filename or any other better ways? chong67 2 3,206 05-29-2012, 11:41 PM
Last Post: chong67

Forum Jump:


Users browsing this thread: 2 Guest(s)