Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
TextColor and StdOut
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
I found an actual use for...
by
jamie
[
Today
at 02:02:42 am]
Pre-Pre-Announce: High Pe...
by
jbthiel
[
Today
at 01:26:24 am]
TstringGrid read cell col...
by
Josh
[June 08, 2026, 11:05:23 pm]
Can /my/ AI help me with ...
by
schuler
[June 08, 2026, 10:41:39 pm]
Pascal for AI Agent CLI T...
by
schuler
[June 08, 2026, 10:35:41 pm]
Knigo
by
Roland57
[June 08, 2026, 09:17:39 pm]
is there a Base 26 / Radi...
by
Josh
[June 08, 2026, 08:54:36 pm]
FPC Unleashed (inline var...
by
Fibonacci
[June 08, 2026, 08:49:31 pm]
[New Component] ExtTabCtr...
by
wp
[June 08, 2026, 08:10:11 pm]
XLibre, finally and fortu...
by
Fred vS
[June 08, 2026, 05:59:14 pm]
AArch64. Fast method to c...
by
LemonParty
[June 08, 2026, 05:54:54 pm]
Notetask 1.1.4 - Free cro...
by
AlexanderT
[June 08, 2026, 04:55:38 pm]
Pixie: A lightweight HTML...
by
Tomxe
[June 08, 2026, 01:48:30 pm]
EasyLazFreeType Bug?
by
Tommi
[June 08, 2026, 10:57:47 am]
embed .jpg file into .pp ...
by
Thaddy
[June 08, 2026, 09:51:38 am]
Call SetLength from assem...
by
Thaddy
[June 08, 2026, 09:00:36 am]
Lazarus Main and Gnome/Wa...
by
robert rozee
[June 08, 2026, 08:57:55 am]
TPlaysound problem Ubuntu...
by
jamie
[June 08, 2026, 12:57:32 am]
Portable verion of FPC an...
by
Martin_fr
[June 08, 2026, 12:26:26 am]
Release ray4laz 6.0
by
lazarusprogrammer
[June 07, 2026, 08:02:14 pm]
Where is Lazarus config
by
n7800
[June 07, 2026, 07:49:03 pm]
Auto-vectorization hint/w...
by
Ten_Mile_Hike
[June 07, 2026, 07:31:42 pm]
Splitting Picture into Qu...
by
Dzandaa
[June 07, 2026, 06:16:22 pm]
Lazarus 4.99 - New featur...
by
Martin_fr
[June 07, 2026, 05:46:05 pm]
GDB 17 for Windows
by
Martin_fr
[June 07, 2026, 04:45:35 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: TextColor and StdOut (Read 1214 times)
Matze
Newbie
Posts: 5
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: 7762
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: 1071
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: 19249
Glad to be alive.
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:
https://www.freepascal.org/docs-html/rtl/crt/assigncrt.html
«
Last Edit: September 19, 2022, 04:56:11 pm by Thaddy
»
Logged
objects are fine constructs. You can even initialize them with constructors.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
General
(Moderators:
FPK
,
Tomas Hajny
) »
TextColor and StdOut
TinyPortal
© 2005-2018