| || |
Problem with String Declaration that takes numeric value
We are using QC 8.2 with WinRunner and are developing Business Components. We are facing an unusual problem while declaring the fields as String and passing numeric values in QC Business Components section. For example, We need to validate a Code 02172 in our test case. So we declared the variable as a String and passed the value 02172. But When the value is read by Winrunner it is read as 2172 and the test case fails. We also tried '02172' but it takes the entire string'02172' and fails the test case again. Has anybody faced this problem and is there a feasible solution to overcome this problem. I am a newbie and I have searched through the forum and could not find an answer and am hence posting it.
Re: Problem with String Declaration that takes numeric value
You are experiencing what is called a Mix Mode operation. The string is the true representation you want, but when put into the "Integer" number equivalent it drops the leading zero (which is what it is supposed to do).
You need to see what data type is being read by Winrunner (I assume an Integer based on what you state). You need to convert the type between Integer and Character/String to do proper comparisons.
Look up the functions 'atoi' and 'itoa' in C language references for a clearer picture of what it is you need to do.