Our website would like to use cookies to store information on your computer. You may delete and block all cookies from this site, but parts of the site will not work as a result. Find out more about how we use cookies.

Login or Register

Powered by
Powered by Novacaster
 
Re: Javascript: don't move!
by Simon at 17:02 22/03/05 (Forum::Technical Advice::General)
In Perl, (courtesy of Hugo explaining what you mean by static variable :-)) you could have:


{
my $bumCount = 0;
   sub bum {
      $bumCount++;
      warn "Bum has run $bumCount times\n";
   }
}

... ie you create a 'bare block' {} around the subroutine to constrain the scope of $bumCount and ensure that it only gets initialised to 0 the first time the program is run, not for every invocation of the subroutine.
--
simon

<< View comments Iiyama monitors, quickasyoulik... >>
View Comments (Flat Mode) Printer Version
Javascript: don't move! Bruce Ure - 22/03
    Re: Javascript: don't move! Simon - 22/03
       Re: Javascript: don't move! Bruce Ure - 22/03
          Re: Javascript: don't move! Simon - 22/03
             Re: Javascript: don't move! Simon - 22/03