Can anyone explain why i get output like this in a small test program:
Inside Thread
Main Loop
Inside Thread
Main Loop
Inside Thread
Main Loop
That's because the line terminator!
#10#13 or #13#10 acts differently
So, check in the source code which one is used, because the first one is
not suitable in Windows!
As you supposedly know, the end line terminator is different on Mac, Unix
and Windows.
Mac only uses #13
Unix only uses #10
Windows uses #13#10 (CRLF)
This comes from the fact that telex machines needed to complete two
different actions in order to start writing in a new line (just like what
you have to do on a normal typewriter): first to step on the next row,
then to put the head at the beginning of the row.
So, basically #10 means Line-Feed (LF) (step to the next row)
While #13 means Carriage Return (CR) which means "move the carriage -the
printing head- to the beginning of the row) - or what you are doing on a
typewriter by hand, using that lever from the right upper part of the
machine.
so, when OS-es split up, the kept what they wanted, although MS had had to
preserve the standard as long as they was part of IBM those times, and IBM
telex machines needed the time of two caracter printing to complete a CRLF
operation.
But I I've seen, sometimes in FP source codes the CRLF is using as LFCR
which does nothing wrong on Unix, as long as CR is invisible, but on
So just look out for this in the source-code.
Or just use
write('Main Loop',#13#10);
:^)
On Windows the output are lined up just as I would expect:
Inside Thread
Main Loop
Inside Thread
Main Loop
Here's a snip of the code:
// Main Prog
Thr := threadtest.Create;
Repeat
k := PollKeyEvent;
WriteLn('Mein Loop');
Sleep(100);
Until k <> 0;
And the ThreadTest.Execute i just:
Procedure ThreadTest.Execute;
Begin
Repeat
WriteLn('Inside Thread');
Sleep(100);
Until Terminated
End;
And if this is a "wrong way" of doing this thing, could someone tell me how
it should be..
Oh and BTW. Using FPC 2.1.1 snapshot from 14.06.06 (from Lazarus site), on
OpenSuSe 10.1..
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal