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
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
gpio_set_irq_enabled_with...
by
Germo
[
Today
at 11:25:02 am]
X11Libre, finally and for...
by
dbannon
[
Today
at 10:59:42 am]
What is the current versi...
by
wp
[
Today
at 10:34:45 am]
[SOLVED] TStringGrid.Visi...
by
EganSolo
[
Today
at 10:30:20 am]
32-Bit MS-DOS Application...
by
paule32
[
Today
at 10:05:46 am]
Build failure
by
dbannon
[
Today
at 09:49:30 am]
How to run an external pr...
by
vsajip
[
Today
at 08:39:26 am]
FPReport designer, am I u...
by
mobilevil
[
Today
at 06:30:34 am]
Lazarus 4 - I give up and...
by
anthonyirwin82
[
Today
at 04:55:15 am]
Will pay for a solution
by
n7800
[
Today
at 04:51:00 am]
Fast Canvas Library V1.0
by
440bx
[
Today
at 04:00:56 am]
Which Linux version
by
dbannon
[
Today
at 03:51:54 am]
Nothing but chaotic attem...
by
dbannon
[
Today
at 03:19:47 am]
Free Pascal Database Serv...
by
nullpointer
[
Today
at 02:51:55 am]
Firebird 5.02. - the root...
by
egsuh
[
Today
at 02:25:38 am]
functional IF
by
Warfley
[
Today
at 12:06:22 am]
64 bits and PascalScript
by
LV
[June 14, 2025, 11:44:07 pm]
StringGrid - How to force...
by
CM630
[June 14, 2025, 11:03:21 pm]
TCustomGrid.OnPaint is us...
by
jamie
[June 14, 2025, 11:02:21 pm]
Linux - partly off topic...
by
Warfley
[June 14, 2025, 10:51:48 pm]
Linux: How to set a Folde...
by
QEnnay
[June 14, 2025, 08:55:58 pm]
A Challenge for Lazarus G...
by
440bx
[June 14, 2025, 08:27:10 pm]
TimageList - Lazarus 4 wi...
by
wp
[June 14, 2025, 07:38:42 pm]
how to break out early of...
by
440bx
[June 14, 2025, 07:02:57 pm]
show the content of an ar...
by
aja_ttara
[June 14, 2025, 06:57:50 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Why does this happen (Read 674 times)
Ten_Mile_Hike
Full Member
Posts: 104
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: 753
Internal Error Hunter
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: 5571
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: 104
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: 3367
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: 104
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: 17129
Ceterum censeo Trump esse delendam
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
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Why does this happen
TinyPortal
© 2005-2018