SRL Archive - Test corner

minutes; and hours; procedure


Thrice

2006-05-29 11:31:30

I was bored working on a procedure so a user could specify how long the script would run I finally got it to work but not as i would like the way i got it to work is that you will have to change the amount of hours and minutes in the procedure if anyone wants to change any of it be my guest…

procedure minutes;
var
m : integer;
begin
m:=0;
if ((m < 61)) then
begin
Wait(m*60000);
end else
Writeln('Invalid Minute Parameters.');
end;

procedure hours;
var
h : integer;
begin
h:=1;
if ((h < 25)) then
begin
Wait(h*600000);
end else
Writeln('Invalid Hour Parameters.');
end;

Thrice

2006-05-29 22:27:45

has anyone took a look at this yet…

Bebe

2006-05-29 22:30:38

Try looking in SRL and using timing.scar ;)

canadarules

2006-05-29 22:42:36

This is how I would do it. I put in comments to help you understand.

program CanadarulesTimer;  // YAY!

var
intStartTime,intEndTime:integer; // sets up variables

const // sets up how long to run (you edit these)
intDays2Run=0;
intHours2Run=0;
intMinutes2Run=0;
intSeconds2Run=1;

function Check4Time:boolean;
begin
if(GetSystemTime>=intEndTime)then // checks endtime with current time
begin
result := true; // it's done
end else result := false; // it's not done
end;

begin
intStartTime:=GetSystemTime; // tells when the script starts
intEndTime:=intStartTime+((((intDays2Run*24+intHours2Run)*60+intMinutes2Run)*60+intSeconds2Run)*1000); // converts total time into milliseconds and calculates end of script
repeat
WriteLn('s'); // realistically this would be the script
until(Check4Time); // checks if the time has met
WriteLn('done'); // shows when the script finishes
end.