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
TA Chart Axes visibility ...
by
wp
[
Today
at 08:22:28 pm]
FPC Unleashed (inline var...
by
flowCRANE
[
Today
at 08:18:34 pm]
Qt does not position form...
by
Fred vS
[
Today
at 08:07:57 pm]
USB-C PD logger KM003C
by
DonAlfredo
[
Today
at 07:42:44 pm]
IDE: Property editor does...
by
Raskaton
[
Today
at 07:35:18 pm]
How can I suppress except...
by
msch
[
Today
at 07:27:59 pm]
Transparent form
by
Nicole
[
Today
at 07:24:20 pm]
TR-DOS Audio Suite
by
Gigatron
[
Today
at 06:26:53 pm]
Stack overflow detection
by
Warfley
[
Today
at 06:06:34 pm]
show me the parameters ce...
by
Nicole
[
Today
at 05:42:40 pm]
How to view the TODO list...
by
n7800
[
Today
at 05:08:49 pm]
Scripts to generate ofici...
by
robert rozee
[
Today
at 03:39:49 pm]
How to compare floating p...
by
Warfley
[
Today
at 03:16:41 pm]
TToolbutton: Dropdown men...
by
apeoperaio
[
Today
at 03:11:30 pm]
FPGMAP accepts duplicates...
by
Zvoni
[
Today
at 02:04:09 pm]
How to read the values ca...
by
dodgex
[
Today
at 11:17:00 am]
Hint tools gives wrong hi...
by
Nicole
[
Today
at 10:43:50 am]
Connecting to AzureSQL
by
paweld
[
Today
at 09:31:30 am]
Nothing but chaotic attem...
by
dbannon
[
Today
at 09:25:17 am]
How do 'with' statements ...
by
Thaddy
[
Today
at 09:14:38 am]
Pascal port of Unishox2
by
Okoba
[
Today
at 08:48:45 am]
Can I get the position an...
by
CM630
[
Today
at 08:38:48 am]
Windows API Hooking/DLL I...
by
tooknox
[
Today
at 06:49:16 am]
Can't access class in for...
by
egsuh
[
Today
at 06:44:12 am]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 12:43:49 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Why does this happen (Read 1050 times)
Ten_Mile_Hike
Full Member
Posts: 140
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: 936
Behold, I bring salvation - FPC Unleashed
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
FPC Unleashed
- inline vars, tuples, statement expressions, array equality, compound assignments, indexed/lazy labels, no-RTTI & more. ⭐
Star it on GitHub!
Bart
Hero Member
Posts: 5715
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: 140
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: 3801
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: 140
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: 19129
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
objects are fine constructs. You can even initialize them with constructors.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Why does this happen
TinyPortal
© 2005-2018