The question about the delay function in squirrel by the O.P. in thread Help with Generator Function and Delay is obvious . I'm too looking for such a way that we execute some lines & then for the rest of the resources in that function , we need to produce a time lag .
Although , this could be done by creating a function first & then whatever need to be executed with some time lag have to put in another function . I actually have tried to test this fact on my own about 4-5 months ago :-
Code Select
function X_print()
{
print(" 1 ");
print(" 2 ");
print(" 3 ");
NewTimer("delay", 5000, 1);
print(" 8 ");
print(" 9 ");
print(" 10 ");
print(" 11 ");
}
function delay()
{
print(" 4 ");
print(" 5 ");
print(" 6 ");
print(" 7 ");
}
function onScriptLoad() X_print();
This will print 1,2,3,8,9,10,11,4,5,6,7 . Actually I was assuming here that the portion of function X_print which comes after Newtimer will execute after delay has finished its run-time . But, results shows that :-
No doubt that newtimer will create a time lag in trigerring the delay function but the X_print function would continue to execute its resources in that time duration . Now , to get the results in desired order, I changed the function as :-
Code Select
function X_print()
{
print(" 1 ");
print(" 2 ");
print(" 3 ");
NewTimer("delay", 5000, 1);
}
function delay()
{
print(" 4 ");
print(" 5 ");
print(" 6 ");
print(" 7 ");
print(" 8 ");
print(" 9 ");
print(" 10 ");
print(" 11 ");
}
Although it will print our desired result . But , I'm feeling that " Are we relying on a dummy function to create a delay ?? ". Could this be possible that something is executed to certain line & then we use delay() function to seize the activity period in squirrel just like in C++ ? This delay could be written into the core of the server as an inbuilt callback by the developers . Otherwise upto my scope , I aint sure about it to do something with this in squirrel . Who knows maybe I need some clarification .