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
Classes vs Objects
by
TBMan
[
Today
at 02:43:06 am]
LAMW complaining about "A...
by
nullpointer
[
Today
at 12:52:28 am]
Firebird 5.02. - the root...
by
incendio
[
Today
at 12:27:38 am]
problem with the lps
by
wp
[
Today
at 12:26:24 am]
Exceptions en FPCUnit
by
janasoft
[June 20, 2025, 11:59:32 pm]
WinInet compiling errors.
by
marcov
[June 20, 2025, 11:57:17 pm]
How to export Pascal vari...
by
ecm
[June 20, 2025, 11:38:24 pm]
Layout problem by nested ...
by
Martin_fr
[June 20, 2025, 10:29:38 pm]
Lazarus 4 - I give up and...
by
Martin_fr
[June 20, 2025, 10:23:23 pm]
IBX installing - packages...
by
Nicole
[June 20, 2025, 10:16:20 pm]
Status and Maintenance of...
by
hdb
[June 20, 2025, 10:09:45 pm]
Documentation
by
LemonParty
[June 20, 2025, 10:03:21 pm]
Strict Aliasing Rule
by
nixbody
[June 20, 2025, 10:01:29 pm]
RecordCount not working -...
by
CharlyTango
[June 20, 2025, 09:43:24 pm]
IBX 2.7.2, What's wrong w...
by
rvk
[June 20, 2025, 09:33:54 pm]
InstallAware 2025 Sources...
by
msintle
[June 20, 2025, 08:29:41 pm]
Animation demo with multi...
by
TBMan
[June 20, 2025, 06:25:26 pm]
I created a Hello World p...
by
Weiss
[June 20, 2025, 05:25:28 pm]
[SOLVED] LAMW - UTF-8 cha...
by
Alcatiz
[June 20, 2025, 05:08:51 pm]
[Solved] HMACSHA1Digest g...
by
fedkad
[June 20, 2025, 04:41:07 pm]
TBitBtn no longer shows g...
by
Awesome Programmer
[June 20, 2025, 04:38:15 pm]
Hints for method name mis...
by
CM630
[June 20, 2025, 04:03:50 pm]
SnapModbus
by
Thaddy
[June 20, 2025, 03:18:55 pm]
mormot
by
Thaddy
[June 20, 2025, 03:01:26 pm]
Replace controls dynamica...
by
n7800
[June 20, 2025, 02:42:14 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Why does this happen (Read 677 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: 754
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: 5573
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: 3377
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: 17176
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