Forum Discussion

twhitehouse's avatar
twhitehouse
Contributor
9 years ago
Solved

Double quotes added to variables

At times, double quotes seem to be added to string variables in Test Complete.  This may be a vbscript issue, I am not sure.  However, I have seen that a variable could end up having its value change...
  • twhitehouse's avatar
    twhitehouse
    9 years ago

    I figured out the problem.

     

    The variables were global in script #1.  I passed them into script #2 from script #1.

     

    In script #2, I had to make valid json for a "POST" command like so:

    postData = "{""username"": " & username & ", ""password"": " & password & "}"

     

    This is valid json.  I checked it using json lint: http://jsonlint.com/

     

    However, the strange thing here is that when I leave script #2, those double quotes follow the variable.  So, username first equals "user@domain.com" in script #1.  When execution focus of the project returns from script #2, back into script #1, username still equals ""user@domain.com""!!!

     

    I solved this by doing the following at the end of script #2, right before focus returns back to script #1:

     

    username = aqString.unquote(username)

     

    So, now, in script #1, I will not have extra double quotes anymore.

     

    But, the bigger question is why did the double quotes follow the variable from script #2 back into script #1.  I thought the scope of the variable would have died in script #2?  So, this is pass by reference the whole time then?