Forum Discussion

jimsmith_1's avatar
jimsmith_1
Contributor
12 years ago

User defined functions in Keyword Test Log command.

I have found that if I include standard vbscript functions in the code in the Value  in a keyword test Log Message command, then they work just fine. My own known-to-be-working, user defined, vbscript functions do not seem to work. The Log Message just returns a blank.



Are user defined functions supposed to work in the keyword test Log command?



Thanks, Jim

  • Hi Jim,


     


    Only LastResult can get the results of the function to be executed. So, it's impossible to use another approach at the moment.


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jim,


     


    In this case, the best way is to use the Run Script Routine operation to call the function and get the result of its execution via Last Operation Result. Here is the keyword test sample:




    Run Script Routine Unit1 - TrimInner "Hello     People" Runs a script routine.


    Log Message LastResult, "", pmNormal, Empty, Empty, ... Posts an information message to the test log.



  • Sorry, that didn't paste very well...try this...



    Function TrimInner(Str)

        Dim WordArray, i

        WordArray = Split(Str)

        Str = ""

        For i = 0 To UBound(WordArray)

            If WordArray(i) <> "" Then Str = Str & WordArray(i) & " "

        Next

        TrimInner = Trim(Str)

    End Function

  • Hi Tanya,



    Yes...I use Last Result as you describe. I was just wondering whether calling the function directly was supposed to work or not.



  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jim,


     


    Only LastResult can get the results of the function to be executed. So, it's impossible to use another approach at the moment.