Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Execute Functions
#1
Solved: 11 Years, 4 Months ago
Hi Ankur,

I am new to QTP, just started few days back,

I understood the concept of functions that you explained.

Now whatever the functions that I am creating if i want to see the ouput of that function, how I can see that.

exapmple: Function sum (val1,val2)
sum = val1 + val2
End Function.

now I know that if I call this function in my script i have to give value to my arguments val2 and val2. but

(1)how to check that whatever the function I created is giving me the correct value?

(2) Do i have to create new test and then just call this function, if this is the cade then how I call the function in the test and then what statement i use to execute that script?

please guide me with your best.

Thanks
Tapan Dalal
Reply
#2
Solved: 11 Years, 4 Months ago
Hi Tapan,

Put your function in a function library and associate this library to your script. Then in your script, lets assume you have two variables that you wish to be added together, variable1 and variable2. To do this just add the following line in your code -

Code:
call sum (variable1,variable2)


but if you wish to check the answer -
Code:
variable3 = sum(variable1,variable2)
msgbox variable3


Hope this helps,
Brian
Reply
#3
Solved: 11 Years, 4 Months ago
Hey guys,

Dont break your head for small things. Just go for basic programmings for w3schools or any other E-Books.

Here i am giving the example required for you:

Code:
a=10
b=5
sumOfNumbers=sum(a,b)   'Here i am calling the sum function
MsgBox(sumOfNumbers)

Function sum(var1,var2)
    Dim temp
    temp=var1+var2
    sum=temp 'Here i am returning the value to the called function
End function

Let me know if you need any clarification here.

Thanks & Regards,
Uday.
Reply
#4
Solved: 11 Years, 4 Months ago
Hi Thanks,

Actually i got that answer yesterday itself, I was doin exactly the same thing you mentioned, but did not put msgbox, then I found that from QTP help, you can also do bu putting Print statement.

onemore thing Brian, I read your thread on Siebel Application issue, I am doing the same thing, need to work on Siebel Emsedical, I want to do the same thing means everytime when you runt the scrip I need to provide new Data to Siebel App, did you find any better solution for this...

If you have the code just for one Example: Client Name that will be good for me.

Thanks in Advance

Thanks
Tapan Dalal
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Execute button of putton won't be clicke automaticly in UFT (VB) MarUFT 3 2,675 11-21-2016, 04:22 PM
Last Post: Ankur
  Not able to execute script shanthalaAR 0 2,078 06-27-2015, 03:53 AM
Last Post: shanthalaAR
  How to Execute a testset from QC using OTA framework AutomationTester2011 12 52,573 01-21-2015, 09:22 PM
Last Post: karthik_sanakran
  Is there a possible way to execute sql in QTP using 'WITH' clause shruthic 0 3,105 04-26-2014, 11:42 PM
Last Post: shruthic
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 3,225 08-22-2013, 11:43 AM
Last Post: smartkarthi

Forum Jump:


Users browsing this thread: 1 Guest(s)