02-20-2014 02:16 AM
Hi
Yes, I'm using a serial cable for connecting two computers.
I did set a loop count in my code. While reading the data from another computer, sometimes I recieve an incorrect buffer of data and this cause writing to the file to start form the beginning. and when I check the loop count, at that instance it resets the while loop (i=0).
For solving this if I remove the part of my code where I empty the string for the first time it'll work fine, since when the while loop resets my string doesn't. But in this case is there any other way for empty-ing string?
Thanks for your time
02-20-2014 05:59 PM
Hello Neo_Ev,
This is a little hard to understand without seeing the code you are working with. What string are you talking about? Do you initilize an empty string that you were then filling with the loop count? Or are you just feeding the loop iteration in as the information to send?
Also are you still having issues or is it working now; as in, do you need to empty the string?
02-21-2014 01:17 AM
I save all the data I need into a string, then write the string to a text file. At every instance I append the string of instance (i) to the string of instance of (i-1). When I initialize the code I want to have an empty string. So I use the loop count of while loop to do this. (if loop count is zero then I empty the string).
But if while I'm reading the data, I get an incorrect data buffer, the while loop will reset and the loop count will go to zero. So it will empty my string and all the data I had saved (appended to the string) will be lost.
I want to empty the string only when I initialize the code and not when the while loop resets. How should I do it?
Thanks
02-21-2014 08:20 PM
Hello Neo_Ev,
If you want to initalize the string just once then move it outside the while loop and feed it in. It will feed an empty string into the while loop that can then be appended to on each iteration of the loop.