[Gambas-user] Keep variable value between subroutine calls?

Dave Merriman dkmerriman at ...626...
Sun Aug 23 23:59:46 CEST 2009


I'm having trouble getting my mind around how to do something in Gambas, 
and I'm hoping that someone can explain (or even better, show) how to do 
it.

As part of an application I'm trying to write, I need to be able to 
change a variable in a subroutine and still have the value available the 
next time the subroutine is called. I _used_ to think that this was 
called a "static" variable, but now I'm not so sure any more :-)

How can I keep the value of a variable intact between calls to the same 
subroutine?

sub Routine()
   V as integer

   select case V
       case 0
         V = 3
       case 1
         V = 2
       case 2
         V = 0
       case 3
         V = 1
       case else
         V = 0
   end select

end

Each time I call the subroutine, I want it to "remember" what "V" was. 
How?

DMerriman
-- 
Encrypted email encouraged and PREFERRED
Sunday, August 23, 2009 @ 1545
** A cat is always on the wrong side of a door. **
----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090823/05957a22/attachment.sig>


More information about the User mailing list