Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Why does this happen
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
Hello! Anything new?
by
JuhaManninen
[
Today
at 10:15:00 am]
Exiting HeapTrace dump
by
Thaddy
[
Today
at 10:11:53 am]
Debian releases a Gtk3 La...
by
dbannon
[
Today
at 10:05:16 am]
Getting results from sql ...
by
CraigC
[
Today
at 09:40:31 am]
mORMot again (HttpServer/...
by
DonAlfredo
[
Today
at 08:47:54 am]
CONCAT formula
by
Zvoni
[
Today
at 08:17:21 am]
Any way to "embed" Window...
by
egsuh
[
Today
at 05:38:10 am]
Is it me or is there some...
by
Martin_fr
[
Today
at 12:51:22 am]
[SOLVED] GTK3 : Icons hav...
by
Schmitty2005
[March 15, 2026, 08:43:28 pm]
emuloader: help to resurr...
by
arcadegamer
[March 15, 2026, 08:30:31 pm]
AutoSize TMemo.Height?
by
wp
[March 15, 2026, 05:55:05 pm]
Initialization & finaliza...
by
Martin_fr
[March 15, 2026, 05:24:36 pm]
could Ardour's YTK be use...
by
robert rozee
[March 15, 2026, 05:11:59 pm]
Possible Enhancement to t...
by
jamie
[March 15, 2026, 04:10:38 pm]
lazarus 4.99 and missing ...
by
wp
[March 15, 2026, 03:11:43 pm]
Questions about TFuncSeri...
by
hedgehog
[March 15, 2026, 06:58:29 am]
Problem with drawing orde...
by
wp
[March 15, 2026, 12:57:00 am]
CryptoLib4Pascal
by
Xor-el
[March 14, 2026, 06:17:32 pm]
Extended Module Player
by
Gigatron
[March 14, 2026, 05:32:06 pm]
[AGGPas] Difference betwe...
by
Roland57
[March 14, 2026, 04:36:02 pm]
declaring Array
by
Thaddy
[March 14, 2026, 01:24:11 pm]
TChart: Wrong default val...
by
wp
[March 14, 2026, 11:30:54 am]
Text Fill (Memo)
by
paweld
[March 14, 2026, 09:09:13 am]
Qt6/Wayland clipboard: pa...
by
AlexTP
[March 14, 2026, 08:56:58 am]
Pocketbase
by
PierceNg
[March 14, 2026, 06:29:04 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Why does this happen (Read 986 times)
Ten_Mile_Hike
Full Member
Posts: 136
Why does this happen
«
on:
May 19, 2025, 10:20:59 pm »
Why does the following code produce Tmemo lines
as short as 7 to as long as 26 characters when
wordwrap is on?
There are no #13 or #10 chars in the string- S
The font is monospaced
Attached is a picture of Tmemo
Code: Pascal
[Select]
[+]
[-]
var
S
:
String
=
''
;
begin
Repeat
S
:
=
S
+
Chr
(
Random
(
95
)
+
32
)
;
//32..126
until
Length
(
S
)
>
10000
;
Memo1
.
Text
:
=
S
;
end
;
Logged
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.
Robert A. Heinlein
Fibonacci
Hero Member
Posts: 793
R.I.P. Free Pascal
Re: Why does this happen
«
Reply #1 on:
May 19, 2025, 10:28:37 pm »
Because there has to be a line break somewhere, and the preferred place is a space character (32)
Logged
Bart
Hero Member
Posts: 5706
Re: Why does this happen
«
Reply #2 on:
May 19, 2025, 10:31:02 pm »
And if there are no suitable breaking characters, Windows will break the line where it sees fit.
Bart
Logged
Ten_Mile_Hike
Full Member
Posts: 136
Re: Why does this happen
«
Reply #3 on:
May 19, 2025, 11:00:48 pm »
A simple fix for uniform line lengths is
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
x
:
Integer
;
s1
,
s2
:
String
;
begin
s1
:
=
''
;
s2
:
=
''
;
Memo1
.
Clear
;
Repeat
S1
:
=
S1
+
Chr
(
Random
(
95
)
+
32
)
;
//32..126
until
Length
(
S1
)
>
=
10000
;
For
x
:
=
1
To
Length
(
S1
)
Do
Begin
s2
:
=
s2
+
s1
[
x
]
;
if
x
mod
20
=
0
then
s2
:
=
s2
+
#13
#10
;
end
;
Memo1
.
Text
:
=
S2
;
end
;
But I never knew that #32 could be used as a line break by windows
Logged
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.
Robert A. Heinlein
dbannon
Hero Member
Posts: 3744
Re: Why does this happen
«
Reply #4 on:
May 20, 2025, 01:47:37 am »
Quote from: Ten_Mile_Hike on May 19, 2025, 11:00:48 pm
...
But I never knew that #32 could be used as a line break by windows
No, its not being used as a line break, its just a suitable place to insert a line break.
Davo
Logged
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project -
https://github.com/tomboy-notes/tomboy-ng
and my github -
https://github.com/davidbannon
Ten_Mile_Hike
Full Member
Posts: 136
Re: Why does this happen
«
Reply #5 on:
May 20, 2025, 07:26:51 am »
To be clear; is this a Windows thing or a TMemo thing?
Logged
When any government, or any church for that matter, undertakes to say to its subjects, This you may not read, this you
must not see, this you are forbidden to know, the end result is tyranny and oppression no matter how holy the motives.
Robert A. Heinlein
Thaddy
Hero Member
Posts: 18795
Glad to be alive.
Re: Why does this happen
«
Reply #6 on:
May 20, 2025, 08:37:26 am »
The maximum
line
length in a Windows textbox, which is the underlying widget on windows is 32,767. But note it may be affected by scrollbar settings.
In effect, that means that within limits it should not be Windows but the TMemo implementation.
«
Last Edit: May 20, 2025, 08:38:57 am by Thaddy
»
Logged
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Why does this happen
TinyPortal
© 2005-2018