PDA

View Full Version : Timing.scar Tutorial



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

Baked0420
08-14-2009, 11:32 AM
you know you can just do writeln(thetime) instead of declaring a variable as thetime and then writing the variable. I feel marktime should've gotten a little more explanation. You messed up in TimeFromMark in your coding, you never told the script which marker you wanted to check, you need to do if(TimeFromMark(i) > 2000) then, it doesn't just know which you're talking about :p. The date one is kind of alright I guess, could have it better. And MsToTime, you said the second paramater can be changed, well so can the first, it doesn't have to be TimeRunning, and I feel you should have explained it better, like how you have i there, and what i stands for. Maybe you can add what the result looks like when you do it right, in the debug box that is, what it all should come up with. All in all, I guess this is alright, just looks like you rushed and didn't put much time in, it looks like it could help some people with the few you have shown so far. Good luck with rest of the procedures/functions.

kyleisntwild
08-17-2009, 08:57 AM
Good post. Thanks

But you need to add what Baked suggested :)