Camaro'
08-14-2009, 06:06 AM
This is a tutorial on how to use srl's useful timing.scar functions.
// * function MsToTime(MS, StrType: Integer): string; // * by ZephyrsFury, Nava2, and Rasta Magician
// * function TimeRunning: String; // * by Rasta Magician
// * procedure MarkTime(var TimeMarker: Integer); // * by Stupid3ooo
// * function TimeFromMark(TimeMarker: Integer): Integer; // * by Stupid3ooo
// * function TheTime : string; // * by RsN
// * function TheDate(DateFormat : Integer) : String; // * by Ron & Nava2
// * function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // By Marpis, N1ke! & Rasta Magician
// * function WaitOption(S: String; Time: Integer): Boolean; // By N1ke!
// * function WaitUptextMulti(S: TStringArray; Time: integer): Boolean; // By Marpis & N1ke!
// * function WaitUptext(S: String; Time: Integer): Boolean; // By N1ke!
// * function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean; // By Rasta Magician, fixed by TRiLeZ
// * function WaitFindColor(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician, fixed by TRiLeZ
// * function WaitFindColorSpiral(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician
// * function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean; // By Rasta Magician
// * function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean; // By Rasta Magician, edit by EvilChicken!
lets Begin.
MSToTime
{************************************************* ******************************
function MsToTime(MS, StrType: Integer): string;
By: ZephyrsFury, Nava2, and Rasta Magician
Description: Takes MS in milliseconds and outputs a string with hours, mins and
seconds. Different styles can be created with different StrType values:
Str Type
0: 2 Hours, 47 Minutes and 28 Seconds
1: 02h, 47m, 28s
2: 2 hr, 47 min, 28 sec
3: 02:47:28
4: 12.04.40
************************************************** *****************************}
Well this is a function that converts milliseconds to readable time with hours, minutes and seconds.
How to use
program new;
{.include srl/srl.scar}
var i:integer;
s:String;
procedure doblah;
begin
i := GetTimeRunning;//gets the time running in ms
s := MsToTime(i,1);// the second parameter can be changed
writeln(s);
end;
begin
setupsrl;
doblah;
end.
TimeRunning
-Pretty obvious, it gets the time running in the format with msToTime.
Mark Time, and TimeFromMark
{************************************************* ******************************
procedure MarkTime(var TimeMarker: Integer);
By: Stupid3ooo
Description: Sets TimeMarker to current system time
************************************************** *****************************}
procedure MarkTime(var TimeMarker: Integer);
begin
TimeMarker := GetSystemTime;
end;
{************************************************* ******************************
function TimeFromMark(TimeMarker: Integer): Integer;
By: Stupid3ooo
Description: returns Milliseconds since MarkTime was set
************************************************** *****************************}
function TimeFromMark(TimeMarker: Integer): Integer;
begin
Result := GetSystemTime - TimeMarker;
end;
Mark Time
Basically a timer that uses MS.
TimeFromMark
Finds out if the timer from mark time has reached x MS.
Usage of both
program new;
{.include srl/srl.scar}
var i:integer;
begin
setupsrl;
MarkTime(i);//setting timer
wait(2001);//waiting
if (TimeFromMark > 2000) then
writeln('yay, the timer was above 2000 ms');
end.
TheTime And The Date
The time
returns the time :p
10:32 PM
used as
var s:string;
begin
s := thetime;
writeln(s);
end.
TheDate
Tells the date with a certain format
{************************************************* ******************************
function TheDate(DateFormat : Integer) : String;
By: Ron & Nava2
Description: TheDate will return the current date. DateFormats can be...
1 = April 2nd, 2007 Month Day, Year
2 = 04/02/07 Month/Day/Year
3 = 02-04-07 Day-Month-Year
************************************************** *****************************}
used as
begin
writeln(theDate(1));
end.
will add the rest of the functions tommorow ... :o
// * function MsToTime(MS, StrType: Integer): string; // * by ZephyrsFury, Nava2, and Rasta Magician
// * function TimeRunning: String; // * by Rasta Magician
// * procedure MarkTime(var TimeMarker: Integer); // * by Stupid3ooo
// * function TimeFromMark(TimeMarker: Integer): Integer; // * by Stupid3ooo
// * function TheTime : string; // * by RsN
// * function TheDate(DateFormat : Integer) : String; // * by Ron & Nava2
// * function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // By Marpis, N1ke! & Rasta Magician
// * function WaitOption(S: String; Time: Integer): Boolean; // By N1ke!
// * function WaitUptextMulti(S: TStringArray; Time: integer): Boolean; // By Marpis & N1ke!
// * function WaitUptext(S: String; Time: Integer): Boolean; // By N1ke!
// * function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean; // By Rasta Magician, fixed by TRiLeZ
// * function WaitFindColor(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician, fixed by TRiLeZ
// * function WaitFindColorSpiral(var x, y: integer; x1, y1, x2, y2, Color, Tol, MaxTime: integer): boolean; // By Rasta Magician
// * function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean; // By Rasta Magician
// * function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean; // By Rasta Magician, edit by EvilChicken!
lets Begin.
MSToTime
{************************************************* ******************************
function MsToTime(MS, StrType: Integer): string;
By: ZephyrsFury, Nava2, and Rasta Magician
Description: Takes MS in milliseconds and outputs a string with hours, mins and
seconds. Different styles can be created with different StrType values:
Str Type
0: 2 Hours, 47 Minutes and 28 Seconds
1: 02h, 47m, 28s
2: 2 hr, 47 min, 28 sec
3: 02:47:28
4: 12.04.40
************************************************** *****************************}
Well this is a function that converts milliseconds to readable time with hours, minutes and seconds.
How to use
program new;
{.include srl/srl.scar}
var i:integer;
s:String;
procedure doblah;
begin
i := GetTimeRunning;//gets the time running in ms
s := MsToTime(i,1);// the second parameter can be changed
writeln(s);
end;
begin
setupsrl;
doblah;
end.
TimeRunning
-Pretty obvious, it gets the time running in the format with msToTime.
Mark Time, and TimeFromMark
{************************************************* ******************************
procedure MarkTime(var TimeMarker: Integer);
By: Stupid3ooo
Description: Sets TimeMarker to current system time
************************************************** *****************************}
procedure MarkTime(var TimeMarker: Integer);
begin
TimeMarker := GetSystemTime;
end;
{************************************************* ******************************
function TimeFromMark(TimeMarker: Integer): Integer;
By: Stupid3ooo
Description: returns Milliseconds since MarkTime was set
************************************************** *****************************}
function TimeFromMark(TimeMarker: Integer): Integer;
begin
Result := GetSystemTime - TimeMarker;
end;
Mark Time
Basically a timer that uses MS.
TimeFromMark
Finds out if the timer from mark time has reached x MS.
Usage of both
program new;
{.include srl/srl.scar}
var i:integer;
begin
setupsrl;
MarkTime(i);//setting timer
wait(2001);//waiting
if (TimeFromMark > 2000) then
writeln('yay, the timer was above 2000 ms');
end.
TheTime And The Date
The time
returns the time :p
10:32 PM
used as
var s:string;
begin
s := thetime;
writeln(s);
end.
TheDate
Tells the date with a certain format
{************************************************* ******************************
function TheDate(DateFormat : Integer) : String;
By: Ron & Nava2
Description: TheDate will return the current date. DateFormats can be...
1 = April 2nd, 2007 Month Day, Year
2 = 04/02/07 Month/Day/Year
3 = 02-04-07 Day-Month-Year
************************************************** *****************************}
used as
begin
writeln(theDate(1));
end.
will add the rest of the functions tommorow ... :o