REALbasic Cross-Platform Application Development

When declaring variables within a method, they are treated by default like local variables that come in scope when the method starts and go out of scope when the method has completed executing. There are two variants of local variables that are also available.

Const

If you declare a variable within a method using Const instead of Dim, you are declaring a constant. The difference between this kind of constant and the other kind that I have written about is that these are local constants and so are active only for the duration of the method:

Const a = 100

This constant is local to the method, but it can be declared anywhere within the method.

Static

Static variables are new to REALbasic 2005. As such I haven't used them extensively in real-life, but they are an interesting addition. A static variable is like a local variable that's declared in a method except for one thing: It retains its value between invocations of that method.

Static a as Integer

Категории