Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
randomrange
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
TDateTimePicker - Make th...
by
AlexanderT
[
Today
at 07:46:48 pm]
Why is my program freezin...
by
paweld
[
Today
at 07:19:46 pm]
is there PDS reader/expor...
by
jamie
[
Today
at 07:01:12 pm]
Help needed on how to do ...
by
paweld
[
Today
at 06:47:28 pm]
UI app to work with SQLit...
by
LeP
[
Today
at 06:44:26 pm]
Fpcupdeluxe
by
cdbc
[
Today
at 06:40:29 pm]
weird error message
by
jamie
[
Today
at 06:37:01 pm]
Como compilar uma lib par...
by
marcelomaurinmartins@gmai
[
Today
at 06:24:51 pm]
Desenvolvimento visual pa...
by
marcelomaurinmartins@gmai
[
Today
at 06:19:16 pm]
OpenDocument('Filename') ...
by
J-G
[
Today
at 06:13:03 pm]
TTL Record Count, i.e. a ...
by
1HuntnMan
[
Today
at 06:05:29 pm]
Using callback
by
LemonParty
[
Today
at 05:43:15 pm]
equivalent to C/C++ "offs...
by
jamie
[
Today
at 12:58:11 pm]
Source Editor Collapsed P...
by
J-G
[
Today
at 11:17:14 am]
Habari STOMP Clients for ...
by
mjustin
[
Today
at 11:15:54 am]
Questions on slight diffe...
by
egsuh
[
Today
at 09:45:30 am]
Have anybody used Horse f...
by
egsuh
[
Today
at 08:31:21 am]
TCollection wiki entry
by
Thaddy
[
Today
at 07:06:53 am]
Printing on HP Smart Tank
by
jamie
[
Today
at 01:55:25 am]
Problems with creating a ...
by
jamie
[
Today
at 12:10:44 am]
val return code
by
Paolo
[July 10, 2026, 10:58:32 pm]
Gtk3 becomes default widg...
by
PascalDragon
[July 10, 2026, 09:59:25 pm]
Seeking performance feedb...
by
Xenno
[July 10, 2026, 04:31:34 pm]
Pls support Double Comman...
by
Alexx2000
[July 10, 2026, 04:02:56 pm]
Ignoring Exceptions - Hit...
by
Martin_fr
[July 10, 2026, 03:50:47 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: randomrange (Read 403 times)
BubikolRamios
Sr. Member
Posts: 397
randomrange
«
on:
December 06, 2025, 10:07:36 am »
Is that really useful for small ranges ?
I can tell there are 1000+ just 1 before and 1000+ just 2 after (see image)
randomize does no change anything at all.
Code: Pascal
[Select]
[+]
[-]
for
...
begin
randomize
(
)
;
random12
:
=
RandomRange
(
1
,
3
)
;
SynEdit1
.
Lines
.
Add
(
IntToStr
(
random12
)
)
;
end
;
Any suggestion ?
«
Last Edit: December 06, 2025, 10:20:01 am by BubikolRamios
»
Logged
lazarus 3.2-fpc-3.2.2-win32/win64
Thaddy
Hero Member
Posts: 19387
Glad to be alive.
Re: randomrange
«
Reply #1 on:
December 06, 2025, 10:21:24 am »
I don't see anything wrong.
A random in the range 1..3 is returned. 3 is not part of the range... see:
https://www.freepascal.org/docs-html/rtl/math/randomrange.html
So the function can only return 1 or 2 and it does.
Code: Pascal
[Select]
[+]
[-]
//tested with
{$ifdef fpc}{$mode objfpc}{$endif}
uses
math
;
type
range
=
0
..
999
;
var
i
:
integer
;
begin
randomize
;
for
i
in
range
do
writeln
(
i
:
5
,
randomrange
(
1
,
3
)
:
2
)
;
end
.
If 3 needs to be included, make the upper range 4.
«
Last Edit: December 06, 2025, 10:30:27 am by Thaddy
»
Logged
objects are fine constructs. You can even initialize them with constructors.
BubikolRamios
Sr. Member
Posts: 397
Re: randomrange
«
Reply #2 on:
December 06, 2025, 10:36:19 am »
Ahh, forget that, works fine. Had SynEdit1.Lines.Add(IntToStr(random12 )) inside wrong loop.
Thanks.
Logged
lazarus 3.2-fpc-3.2.2-win32/win64
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
randomrange
TinyPortal
© 2005-2018