Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can you do functions by calling filename or any other better ways?
#1
Not Solved
I have functions that I use all the time in my automation.

1. Can I save the function to another filename?
2. If I save to another filename how do I evoke it?
3. Is there any other better way?

==============

Below is example of my function:

Code:
Dim OutDate,ReturnDate,RndValue

' Initialize random-number generator
Randomize
' Generate random value between 200 and 300
RndValue = Int(  (300-200 +1)* Rnd + 200)
'msgBox(RndValue)

OutDate = DateAdd("d", RndValue, Date)
'msgBox(OutDate)

ReturnDate = DateAdd("d", RndValue+10, Date)
'msgBox(ReturnDate)
================

My code that calls it:

Code:
Browser("Delta Air Lines - Airline").Page("Delta Air Lines - Airline").WebEdit("departureDate_0").Set OutDate
Reply
#2
Not Solved
you should look into function library, it is an external file, can contain functions and objects/variables.
Reply
#3
Not Solved
I got it working the first time. It was not that hard. I just google it. I just didnt know its called 'function library'

You need to go to Resources Tab and do "Associated Function Librarys".

I dont know if this is good programming or not.

I am still learning.

=============
' I save this to a file

Code:
Dim  RndValue
Randomize
RndValue = Int(  (300-200 +1)* Rnd + 200)

Public Function OutDate()
     OD = DateAdd("d", RndValue, Date)
     OutDate = OD
End Function

Public Function ReturnDate()
    RD= DateAdd("d", RndValue+10, Date)
    ReturnDate = RD
End Function

======================
'Put this in expert view:

Code:
Browser("Delta Air Lines - Airline_2").Page("Delta - Book a flight").WebEdit("departureDate[0]").Set OutDate
Browser("Delta Air Lines - Airline_2").Page("Delta - Book a flight_14").WebEdit("departureDate[1]").Set ReturnDate
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 2,934 08-22-2013, 11:43 AM
Last Post: smartkarthi
  exit parent functions as well Shridevi.Salagare 3 3,596 07-31-2013, 12:15 AM
Last Post: Ankur
  Datatable in functions shwetasharma 2 3,285 03-26-2013, 08:00 AM
Last Post: sams001
  Problem with using two functions in the same action mhanaan 2 2,848 09-14-2012, 10:09 PM
Last Post: mhanaan
  Calling a HP Service Test Skript Gandalf2005 0 2,018 09-05-2012, 07:53 PM
Last Post: Gandalf2005

Forum Jump:


Users browsing this thread: 1 Guest(s)