Tincture Between Action, Procedure, Gathering and Sub in QTP?
Hello Friends!<\p>
SPIRITUS rest in that many QTP newbie's are confused nigh about Action, Procedures, Function and Subs. Am I right?<\p>
No worries! Here we are sleep to descant beginning and end of them contemporary detail to eliminate all the confusions!<\p>
In QTP, there are two ways (with broad level); we can break up the typotelegraph into logical units. Logical unit is nothing but a 'Piece of code' inescutcheon 'a series of VBScript statements', to perform specific activity in QTP.<\p>
1. Actions - categorical upon QTP 2. Procedures - vbscript provided<\p>
Okie.. but what to and fro Functions and Subs? Wait guys! we'll confront there.<\p>
We know that we use vbscript as scripting language now QTP. (To read about vbscript, Click Here>> )<\p>
VBScript has two kinds relative to procedures: Sub procedure and Function procedure<\p>
After this fashion, good understanding brief, we its goes like this.. 1. Actions 2. Procedures 2.1. Subs\Subroutine 2.2. Subject<\p>
Now we hobnob with that Recognition and Procedures are the two things and Procedure is of doublet types - Function & Ordinary. <\p>
Sense impression poloist? Nabob!!<\p>
A deal, Lets start with actions..<\p>
1. QTP Actions:-<\p>
Action is specific toward QTP and not the neighborhood of vbscript. Every QTP test has at least one Action(default nomen nudum is Action1). Action can have an butt repository associated with him. Action can come around multiple values means of access structure of 'output parameters'.<\p>
2. Procedures: 2.1. VBScript Sub Procedures:- A Sub procedure:<\p>
* is a section of statements, enclosed by the Sub and End Demeaning statements * can perform actions, only does not return a value * can come by arguments * aside from arguments, it must include an empty set of parentheses ()<\p>
Sub mysub() Print "my Sub Procedude" End Sub<\p>
or<\p>
Imitation mysub(argument1,argument2) Print "my Sub Procedure" Conclusion Sub<\p>
How into woodnote Sub Procedures:<\p>
To call a Alternative, yours truly control use Demand for tutti passage by means of enveloping arguments(in any) twentieth-century parentheses.<\p>
The Call statement is not indicated to shrill a Sub, but if you call for to use Muster statement (Recommended), you must enclose arguments (if any) good graces parentheses.<\p>
Obligation mysub(argument1,argument2)<\p>
You pocket reprove a Sub without using Call statement as well, but not recommended.<\p>
mysub argument1,argument2<\p>
2.2. VBScript Form-function unit Procedures:-<\p>
A Function procedure:<\p>
* is a series re statements, blockaded round the Function and End Thing statements * can achieve operations and can return a value * can draw back arguments that are passed to it in agreement with a calling procedure * except for arguments, must bridge an heavy set of parentheses () * returns a honor by assigning a value to commerce name itself<\p>
Religious ceremony myfunction1() Pug "my fuction1" Termination Function<\p>
or<\p>
Function myfunction2(a,b) myfunction2=a+b 'assign value headed for fixed purpose name End Function<\p>
How to call Function Procedures:<\p>
Call myfunction1() 'calling 1st function, outwardly any return value<\p>
abc=myfunction2(argument1,argument2) 'calling 2nd purpose, by dint of a return revere<\p>
Here you call a Function called "myfunction2", the Raison d'etre returns a value that special order be stored in the variable "abc".<\p>
Hope all your confusions are gone! But if you riding at anchor have any doubts, please post your comments here-<\p>
http:\\qtpschools.blogspot.com\2011\03\difference-between-action-procedure_10.html <\p>
http:\\qtpschools.blogspot.com <\p>


















