Program Random;

{ *** Random - show a random number ***
      v1.1 © JIPsoft 14th Nov 1996
 Usage: Random <max>, where max is the maximum
 value for the random number

 This program is freely distributable         }

{$I "Include:Utils/Random.i"}
{$I "Include:Utils/Parameters.i"}
{$I "Include:Utils/Stringlib.i"}

var cline: string;
    seed: integer;

Function StringConvert(source: string): integer;
var c: char;
    result,index: integer;
begin
    result:=0;
    index:=0;
    c:=source[index];
    while (c>='0') and (c<='9') do begin
        result:=(10*result)+(ord(c)-ord('0'));
        index:=index+1;
        c:=source[index]
   end;
   StringConvert:=result
end;

begin
    if 1=2 then
        writeln('$VER: Random v1.1 by JIPsoft');
    cline:=AllocString(255);
    GetParam(1,cline);
    seed:=StringConvert(cline);
    SelfSeed;
    writeln(RangeRandom(seed))
end.
