Highlighted
Frequent Contributor.
Frequent Contributor.
2233 views

Writing variables out to a file in TruClients

I am capturing values to write out to a file so i know the data i processed and if it brought back records.  I did this type of code:

var loginId = TC.getParam("p_User_ID");
var logMsg = TC.log('LastName: '+loginId);
IO.write(TC.scriptDir + "mylog.txt", +logMsg, false);

the logMsg gives me this in the log: LastName: burjuxx  (which is correct)

but the IO.write statement gives me junk.  is there a way to write out to a log a value captured in TruClient? I can get it to work if I put a string in place like

IO.write(TC.scriptDir + "mylog.txt", "string", false);

 

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi,

I'd suggest to try below code.

var loginId = TC.getParam("p_User_ID");

var logMsg = 'LastName: '+loginId;

TC.log(logMsg, "Standard");

IO.write(TC.scriptDir + "mylog.txt", logMsg, false);

 

Highlighted
Outstanding Contributor.
Outstanding Contributor.

If you're going to be doing a lot of this I'd recommend installing the free VTS and logging data in there. Lots of file I/O worries me inside a load test.

0 Likes
Highlighted
Contributor.
Contributor.

Hi there.  I have a script where I wish to do the same.  Im new to Truclient so could someone show me exactly How and Where to add this type of code?  

Any examples would be useful.  I am presuming somewhere in the 'develop script' area in, or immediately after the step that displays the text you wish to collect and write to a file.

Thanks in advance

 

0 Likes
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.