SRL Archive - OSR Help

Randomrange Help


moneyman331

2013-05-31 00:12:57

Having problem getting random range to work. Doesn't like two named constants.

Script looks essentially like this:


constant1:=2
constant2:=3 (or 4 or 5)

blahblahblah

timestodotask:= randomrange(constant1,constant2)


perform action timestodotask

ALWAYS does constant1 times and when I print the timestodotask before running the action loop it's always returns constant1. No problems with it working elsewhere in the script when I use randomrange(0,100000) or whatever with numbers and not referenced constants. Any ideas?

moneyman331

2013-05-31 00:28:29


program testscript;

var
n:integer;
const
const1=2;
const2=3;

begin
repeat
n:=randomrange(const1,const2);
writeln(n);
wait(100);
until n=4
end

Should print numbers forever.

Mine looks like
2
2
2
2
2
2
2

tealc

2013-05-31 00:29:49

Seems to be working ok for me, remember with random range the second value is exclusive. ie: randomrange(0,100000) meaning this would return a number from 0 to 99999.

program new;
Const
a=1;
b=4;

begin
writeln(randomrange(a,b));
end.

if you want an output of 2 or 3 try randomrange(2,4);

moneyman331

2013-05-31 00:33:01

Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.

What I got with your script

Pasted the thing twice, not sure what's happening. Going to try rebooting simba and computer

Olly

2013-05-31 00:38:44

So this only gives you 2s..?

program new;

const
a = 1;
b = 4;

var
i: integer;

begin
while i <> 100 do
begin
writeln(randomRange(a, b));
inc(i);
end;
end.

Works for me.

tealc

2013-05-31 00:40:56

From: moneyman331
Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 31 ms.
2
Successfully executed.
Compiled successfully in 16 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.
Compiled successfully in 32 ms.
2
Successfully executed.

What I got with your script

Pasted the thing twice, not sure what's happening. Going to try rebooting simba and computer


Strange… Restart simba and try running this code

program new;
Const
a=69;
b=100;
begin
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
writeln(randomrange(a,b));
end.

moneyman331

2013-05-31 00:48:49

Restarted my computer and now it's working fine. No fucking clue. I've been trying to get it to work for like 2 hours and all I needed to do is restart :doh:. Thanks for the help. Really useful knowledge about the randomrange being exclusive at the end, I can't say I didn't learn anything.

Compiled successfully in 31 ms.
82
92
72
72
95
87
72
88
85
97
86
Successfully executed.