How to include a double quote inside of the string in UFT GUI?
Question ID: 106563
0
0

I am always building strings from data tables in UFT GUI data table how do you add a double quote?

Marked as spam
Posted by (Questions: 45, Answers: 1)
Asked on December 31, 2015 5:02 pm
1309 views
Answers (2)
1
Private answer

Including a double quote inside of the string
To include a double quote within a string stored in a variable, use the Chr function to define the character in the string.
Chr(charcode)
charcode The ANSI number that identifies a character.

For a double quote character, the ANSI number is 34. Refer to the ANSI character chart for additional characters.
Example:

str = Chr(34) & ''hello world'' & Chr(34)
msgbox str
str = ''My '' & chr(34) & '' String''
MsgBox str

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 31, 2015 5:03 pm
0
Private answer

You can also use an escape character to allow the double quote as well.

UFT uses VBScript.

Strings in VBScript are represented by enclosing the string inside starting and ending double quotes as shown below

str = ''hello world''

But to represent ''hello world'' (including the quotes) the below code won't work due to a syntax error:

str = ''''hello world''''
MsgBox str
The issue with above code is that first pair of double quotes mark the end of the string and anything after that causes a syntax error. We need an escape character which will allow us to escape the double quote within the string. Unlike C, C++, JAVA etc... the escape character in VBScript is not but the double quote. So to represent ''hello world'' as string we will use:

str = ''''''hello world''''''
MsgBox str
The first and and last quotes mark the start and end of string. Every continuous pair of double quotes inside a string is treated a 1 double quote

Marked as spam
Posted by (Questions: 3, Answers: 168)
Answered on January 5, 2016 4:41 pm
0
Recommend not using the triple double quotes options. In the past HP has not recommend using triple double quotes due to issues with editors, vb scripting engines, and debugging monitors.
( at January 6, 2016 3:10 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top