Micro Focus QTP (UFT) Forums
optional parameters - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: optional parameters (/Thread-optional-parameters)



optional parameters - Ishul - 04-03-2012

Hi,

Hi all, i want to know can we define optional parameters in vbscript


RE: optional parameters - sshukla12 - 04-03-2012

Hi,

Could u please eloborate???

Regards,
Sankalp


RE: optional parameters - Ishul - 04-03-2012

if i have function say

login(UN,PWD,a)

when i call login function i make use of parameters UN and PWD,
but i dont use 'a' , i may use or not use. its just optional
so i pass all the values but i dont use it the value a inside the function, does the login function work?




RE: optional parameters - vIns - 04-03-2012

Having Optional parameters in a function is not possible in VBscript.
You can use dictionary objects / arrays and pass the values to a function if
you want to have flexible no of arguments.


RE: optional parameters - supputuri - 04-03-2012

Hi Ishul,

This feature is not part of vb scripting so we have to pass all the parameters while calling any action. However, you can make it option by incorporating the code if the input is empty ("") then igone that value and pass the value as empty ("") while calling the function for the one which you don't want to pass the value.

Let me know if you need any info.


RE: optional parameters - supputuri - 04-03-2012

Hi Ishul,

This feature is not part of vb scripting so we have to pass all the parameters while calling any action. However, you can make it option by incorporating the code if the input is empty ("") then igone that value and pass the value as empty ("") while calling the function for the one which you don't want to pass the value.

Let me know if you need any info.