SRL Archive - FAQ

Time from starting SMART function?


djborec

2012-09-17 14:23:37

Is there any function which will return time from starting smart? (not from strating script)

Or?

Or other way would be to save starting time somewhere in file ,but how do I determinate starting time.

I mean ,because sometimes you restart script ,but you do not restart smart.

litoris

2012-09-17 14:30:59

Right after setupsrl, do a Marktime. ie:

SetupSrl;
Marktime(l);
"l" would have to be declared as an integer/longint at the very top.
TimeFromMark(l) would return the time since SMART began.

(This all assumes that setupsrl ends after SMART spawns. Would get screwed up if it tries to log you in or something afterwards. )

djborec

2012-09-17 14:33:43

Well ,I did not explained my problem very well ,because I mean this:

Sometimes my bot got stuck, so I have to restart it and I do not wanna close SMART ,so I just stop it manually and start it again manually and this restart of script would load new time into mark, so it wont be exact time from starting SMART.

litoris

2012-09-17 14:46:24

No way to get the time if you stop the script :) You could write the system time to a file, and read from there though.
Just checked, function TheTime returns the time your PC shows, but it's hh:mm:ss format.

djborec

2012-09-17 14:59:57

Getting current time would not be problem ,

The problem is determining whatever I start script first or I restarted script ,but I think that I can use number of SMARTs loaded before setupsrl ,if 0 then its frist time ,so it will save time to file ,, tht should be working . I will try

djborec

2012-09-17 16:16:02

I did something like this:

function createTimeFile:boolean;
var
IDs:TIntegerArray;
Count:Integer;
begin
Ids := SmartGetClientIDs;
Count := Length(IDs);
If (Count = 0) then
begin
If not(FileExists(ScriptPath+'sys.txt')) then begin
CreateFile(ScriptPath+'sys.txt');
SMARTtime1:=RewriteFile(ScriptPath+'sys.txt',false);
end else begin
SMARTtime1:=RewriteFile(ScriptPath+'sys.txt',false);
end;
if not(SMARTtime1=-1) then Result:=true;
end;
end;


function saveSmartTime:boolean;
begin
if createTimeFile then
begin
if WriteFileString(SMARTtime1,ToStr(GetSystemTime)) then
begin
CloseFile(SMARTtime1);
Result:=true;
end;
end else
begin
try
CloseFile(SMARTtime1);
except
end;
end;
end;

function timeFromSMARTstart:Integer;
var
number:String;
startingTime:Integer;
begin
If FileExists(ScriptPath+'sys.txt') then
begin
SMARTtime1:=OpenFile(ScriptPath+'sys.txt',true);
if not(SMARTtime1=-1) then
begin
If ReadFileString(SMARTtime1,number,FileSize(SMARTtime1)) then
startingTime:=StrToInt(number);
if (startingTime>0) then begin
Result:=getsystemtime-startingTime;

end;
end;
CloseFile(SMARTtime1);
end;
end;

// Nevermind managed to find it out what GetSystemTime is returning its time from swtching on computer,so my functions are working :)