Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to type cast INTEGER to STRING data type for use in SetText() method

How to type cast INTEGER to STRING data type for use in SetText() method

The following article will demonstrate how to use type casting to convert an INTEGER data type to a STRING for use with the SetText() method. 

The SetText() method only accepts a STRING data type to be used for the text value in its parameters. If you need to use an INTEGER type, you can use type casting to convert to a STRING and then pass this into the SetText.

The below code shows how this can be done by converting an integer to a string in the Integer2String function and then calling this in the Convert() testcase. 

[-] String Integer2String (integer y)
[ ]
[ ]        STRING text
[ ]        text = ([STRING]y)
[ ]        print (text)
[ ]
[ ]        TextField.SetText(text)
[ ]
[ ]        return text
[ ]

[-] testcase Convert() appstate none
[ ]        Integer2String(12345)

For further reading on type casting and the available operators, please see the Silk Test help topic 'Type Cast Operator'.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-08 09:26
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.