SRL Archive - OSR Help

Failsafe global function?


Master BAW

2012-06-14 00:49:42

Hello,
I'm making my own script, and i'm new to simba/pascal, but i'm doing very well :)
I'm now stuck with a question. I need to know a good way to make a sort of global failsafe function
Here's what I was thinking about:


procedure failsafe(Funct: procedure(x), Amount:integer);
begin
//x=standaard 0 of een in deze functie meegegeven waarde;
if(x > Amount) then
begin
StopOurScript('Failsafe failed to make '+ Funct +' work after retrying '+ Amount +' times... Try second failsafe method: reset client and logout and restart script after 30 minutes',1+Times);
end Else
Funct(x+1,<OTHER VARIABLES THAT WERE GIVEN>);



end;

//make it work like this:


Procedure Progogo(x: integer);
Begin
//lets say theres a 10% change it will fail
//~~~~~~~~~~DOES THINGS~~~~~~
if random(10) = 0 then
begin
failsafe(Progogo(x, <othervariableshere>) , 10);
end;

End;

begin
Progogo(1,<othervars>);
end.
{so…. I thought about this but couldn't think of a way to make this to work..
is it even possible in Pascal/Simba?
It would be really usefull because: you of course could make this function "failsafe"
in every function you have, but that is just a lot of lines of text which you have double in your whole script
and that's bad! you shouldn't have things double in your script, then you should make a new function for it , isn't it? :)

so this has to be possible! ^^ What do you say? Or is there maybe a better/different way to handle failsafes more global

p.s. if I make a stupid thinking error It's because it's kinda late here and im tired;)

pps: sorry for my bad spelling and grammar, Im tired and i'm dutch;)

HT BaaFly

2012-06-23 13:43:01

Uh your code is confusing. Not sure if it's a snippet from your actual script or not. If you want my advice, use an integer as a failsafe. For example, everytime any of my scripts fail at something, an integer is increased. If it increases beyond a certain limit, my script automatically stops to prevent unhuman-like actions or repeated clicks. hope this helps