cancel
Showing results for 
Search instead for 
Did you mean: 

How can I check a function return type in another function in vb script.

SOLVED
kaiiii
Regular Contributor

How can I check a function return type in another function in vb script.

How can I check a function return type in another function in vb script.

like there are 2 function.Kindly check below

 

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

    Else

        log.message("not ok")

    End IF

End Function

 

 

Function B()

     .....In this function i want to check status of function A... It's true or False----

so I can return value in boolean and check the same

End Function

2 ACCEPTED SOLUTIONS

Accepted Solutions
tristaanogre
Community Hero

Re: How can I check a function return type in another function in vb script.

Um... OK, so that's some basic VBScripting there.  Simply...

 

Function A()

     Set obj = ----------something here-----
     A = Obj.Exists

End Function

And then, in function B

 

Function B()

     If A then
          Log.Message("Object exists")
     else
          Log.Message("Object does not exists")
     End If
End Function

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

rajulapati
Contributor

Re: How can I check a function return type in another function in vb script.

You can try below scenario and check if it works for you

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

         strResult=TRUE

    Else

        log.message("not ok")

       strResult=FALSE

    End IF

   A=strResult

End Function

 

Function B()

  strResult=A()

   If strRESUlt=TRUE Then

      log.Message"True"

Else

     log.Message"False"

End Function

View solution in original post

5 REPLIES 5
tristaanogre
Community Hero

Re: How can I check a function return type in another function in vb script.

Um... OK, so that's some basic VBScripting there.  Simply...

 

Function A()

     Set obj = ----------something here-----
     A = Obj.Exists

End Function

And then, in function B

 

Function B()

     If A then
          Log.Message("Object exists")
     else
          Log.Message("Object does not exists")
     End If
End Function

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

rajulapati
Contributor

Re: How can I check a function return type in another function in vb script.

You can try below scenario and check if it works for you

Function A()

     Set obj = ----------something here-----

    If(Obj.Exists) then

         Log.message("ok")

         strResult=TRUE

    Else

        log.message("not ok")

       strResult=FALSE

    End IF

   A=strResult

End Function

 

Function B()

  strResult=A()

   If strRESUlt=TRUE Then

      log.Message"True"

Else

     log.Message"False"

End Function

View solution in original post

AlexKaras
Community Hero

Re: How can I check a function return type in another function in vb script.

Hi,

 

> How can I check a function return type [...]

so I can return value in boolean and check the same

 

I am pretty sure that @tristaanogre and @rajulapati provided you with the answer you was looking for.

But been a naughty old-school guy I can't but clarify:

Considering your example and function A():

-- Return type of function A() is of boolean type. To be perfectly correct, the return type of A() is OleVariant of boolean subtype. VarType() is the function that returns the subtype of the tested object/variable. All functions and variables in scripting languages (in VBScript) are of OleVariant type.

-- As function A() is expected to return the boolean *type*, the returned *value* can be either True or False.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tristaanogre
Community Hero

Re: How can I check a function return type in another function in vb script.

I am pretty sure that @tristaanogre and @rajulapati provided you with the answer you was looking for. But been an old-school naughty guy I can't but clarify:
The snark is strong with this one.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
sonya_m
Community Manager

Re: How can I check a function return type in another function in vb script.

Thank you everyone. A lot of great suggesions to choose from hereSmiley Happy

 

Hi @kaiiii, which one works for you best? 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors