Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
TextColor and StdOut
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Component to sdf file - M...
by
Thaddy
[
Today
at 05:56:40 pm]
Links in forum posts
by
440bx
[
Today
at 05:38:27 pm]
LCLProc MergeSort seems n...
by
Blaazen
[
Today
at 05:33:31 pm]
is there a "Lazarus.ini"?
by
Martin_fr
[
Today
at 04:53:20 pm]
Compiler directive - what...
by
wp
[
Today
at 04:52:14 pm]
Problem with Printing Uni...
by
Neville
[
Today
at 04:08:31 pm]
New version of MouseAndKe...
by
JuhaManninen
[
Today
at 04:08:06 pm]
Controls inside the form ...
by
wp
[
Today
at 03:13:19 pm]
[solved]Forum signature c...
by
KodeZwerg
[
Today
at 02:49:05 pm]
Disable theming for a TPa...
by
Bart
[
Today
at 02:42:14 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: TextColor and StdOut (Read 394 times)
Matze
Newbie
Posts: 1
TextColor and StdOut
«
on:
September 18, 2022, 01:48:20 pm »
Hello,
why does this dont work?
assign(FO, '');
rewrite(FO);
TextColor(Red);
write(FO,'some Text');
The TextColor is not set to red.
Can you help?
Thanks.
Logged
jamie
Hero Member
Posts: 5060
Re: TextColor and StdOut
«
Reply #1 on:
September 18, 2022, 03:03:34 pm »
That looks like you need to use the CRT unit to start with.
Also, remove the Assign and Rewrite.
If you are trying to do terminal output, then you need to use Ansi Escape codes or whatever the terminal understands.
Logged
The only true wisdom is knowing you know nothing
Jonas Maebe
Hero Member
Posts: 1029
Re: TextColor and StdOut
«
Reply #2 on:
September 18, 2022, 08:56:52 pm »
You have to use assigncrt instead of assign if you want to use the functionality of the crt unit with it.
Logged
Thaddy
Hero Member
Posts: 12575
Re: TextColor and StdOut
«
Reply #3 on:
September 19, 2022, 04:47:14 pm »
Something like so:
Code: Pascal
[Select]
[+]
[-]
uses
Crt
;
var
FO
:
Text
;
begin
AssignCrt
(
FO
)
;
Rewrite
(
FO
)
;
TextBackground
(
white
)
;
ClrEol
;
TextColor
(
Red
)
;
WriteLn
(
FO
,
'Some text'
)
;
Close
(
FO
)
;
end
.
Taken and adapted from the example in the manual for Assigncrt:
**s://www.freepascal.org/docs-html/rtl/crt/assigncrt.html
«
Last Edit: September 19, 2022, 04:56:11 pm by Thaddy
»
Logged
Writing code in an overly complex way is usually merely a complete misunderstanding of the goal you are trying to achieve.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
TextColor and StdOut
TinyPortal
© 2005-2018