When calling for example fpsystem( 'cat /proc/partitions' );
the lines are not beginning at the 1st character of the next lineInstead of
Line1
Line2
Line3
like in the Linux shell
The output is:
Line1
Line2
Line3
and so on
What is the reason?

Mailing lists / fpc-pascal / 2013-01
12 messages · 5 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
When calling for example fpsystem( 'cat /proc/partitions' );
the lines are not beginning at the 1st character of the next lineInstead of
Line1
Line2
Line3
like in the Linux shell
The output is:
Line1
Line2
Line3
and so on
What is the reason?
Here the output looks OK when executing as-is.
But if you are using the crt unit, that may mess up the terminal. I added crt, and then the output was indeed indented.
Michael.
When calling for example fpsystem( 'cat /proc/partitions' ); the lines are not beginning…
You've not told us what OS etc. you're running. This is the sort of thing I'd expect to see if the program were running on a unix system that generated \n (LF) at the end of each line, but you had a misconfigured terminal emulator that was currently expecting CR LF. You could get this if the terminal emulator were on Windows, but a particular case on any platform is where for some reason the TE or console has been set to raw (or similar) mode; there's commands to sort this out but often the safest way is to restart the session.
Here the output looks OK when executing as-is. But if you are using the crt unit, that…
I also use crt.
Is it possible to change the bevahiour?
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
No.
in order to do it's magic, CRT must control the terminal.
Michael.
Are there alternative ways to write something on the screen and to clear the screen?
For example with unit system?
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
In the general case, that's going to be terminal-specific. If you only want stdout (and/or stderr) output you'd need to know what escape sequence to sent to the terminal (possibly with reference to termcap/terminfo- I don't know whether there are libraries to handle this) but if you wanted full control like you get with the FP IDE I think you'd be using the old TurboPower stuff.
In extremis, if you're already invoking an external program and want to clear output after it runs, and if you know that you're running on a unix, you could simply invoke the clear program.
Going back to your original question, I see no reason why you couldn't open and parse e.g. /proc/partitions as an ordinary text file.
Are there alternative ways to write something on the screen and to clear the screen? For…
Since you're already executing external commands:
Execute the /usr/bin/clear command ?
Michael.
In the general case, that's going to be terminal-specific. If you only want stdout…
This is one thing.
Another thing are the error messages from freepascal which behave the same then.
And other output messages (for example dhcp service programs).
Isn't it possible to make a function in crt that makes the behaviour wanted? Something like crt.turn_linefeed_on(); or similar.
No, it is not.
CRT is simply not meant to be mixed with raw output, and definitely not from other programs. There would be no end to the number of problems.
Michael.
This is one thing. Another thing are the error messages from freepascal which behave the…
Use TProcess to execute external programs and capture their output. You can then write it using the regular write/writeln routines, which work correctly with the crt unit. See http://wiki.freepascal.org/Executing_External_Programs#TProcess for help.
Jonas
Are there alternative ways to write something on the screen and to clear the screen? For…
Crt installs its own driver to control the screen buffer (and it has to be done, no way to escape). You can create your own by using Video unit: http://www.freepascal.org/docs-html/rtl/video/index.html