If you do a waitln command after a waitn command that times out
inputstr may contain several lines of text.
Following code example below shows the problem.
Run the code with a loop back plug on COM (pin 2 connected to pin 3)
and terminal transmit to CR + LF to visualize the problem better
1. time the loop runs, inputstr contain "secondline>"
2. time the loop runs, inputstr contain "firstline CRLF secondline>"
The problem does not occur when waitn command does not time out.
I have looked at the code, and I think I have found the problem.
If a waitn command find the number of bytes (result = 1) the
ClearWaitN() function is run (line 164 in ttmmain.cpp).
on the other hand if the function times out, ClearWaitN() if not run.
This again cause the Receive line buffer not to be cleared inside PutRecvLnBuff(BYTE b) function
when it should later in the waitln command (line 403 ttmdde.c is always false).
I have inserted a ClearWaitN(); in line 441 ttmmain.cpp when waitn exit because of timeout.
Compiled and tested that problem is gone.
(however i do not know the code well enough
to not guarantee that this modification don't have any unknown side effects)
timeout = 1
for tmpcnt 1 2
sprintf 'waitln %d.time inputstr [%s], result [%d]' tmpcnt inputstr result
messagebox inputstr 'Test'