[Pas2js] sequencing function calls in pas2js
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat Jun 9 00:41:50 CEST 2018
On Fri, 8 Jun 2018 16:47:23 -0500 (CDT)
warleyalex via Pas2js <pas2js at lists.freepascal.org> wrote:
> I read through various threads and it really escapes me how to accomplish the
> following in pas2js:
> -------------------------------
> setTimeout(function() {
> console.log('hi after 10 secs')
> setTimeout(function() {
> console.log('hi after 5 more secs')
> setTimeout(function() {
> console.log('hi after 2 more secs')
> }, 2000)
> }, 5000)
> }, 10000)
> -------------------------------------------------------
> wait 10 sec then print the msg "hi, after 10 secs"
> wait more 5 sec then print the msg "hi after 5 more secs"
> wait more 2 sec then print the msg "hi after 2 more secs"
> -------------------------------------------------------
One solution:
procedure Test;
procedure Call3;
begin
writeln('hi after 2 secs');
end;
procedure Call2;
begin
writeln('hi after 5 secs');
window.setTimeout(@Call3,2000);
end;
procedure Call1;
begin
writeln('hi after 10 secs');
window.setTimeout(@Call2,5000);
end;
begin
window.setTimeout(@Call1,10000);
end;
Mattias
More information about the Pas2js
mailing list