How do I set a static variable value?
Author Message How do I set a static variable value?

Folks.

If I declare a static variable like this:

Static Dim X As Integer

then X is initialised to 0. How do I set the initial value to say 241?
In C terms, I want the equivalent of:

static long int X = 241;

Any ideas?

Peter

Tue, 25 Sep 2001 03:00:00 GMT  How do I set a static variable value?
Set a flag (also static) the first time through and use it as a test to see
if the Static needs to be initialized. Then initialize it manually:

static X as Integer
static flag as integer

if flag = 0 then
X = 241
flag = 1
end if

Brian-

Quote:

>Folks.

>If I declare a static variable like this:

>Static Dim X As Integer

>then X is initialised to 0. How do I set the initial value to say 241?
>In C terms, I want the equivalent of:

>static long int X = 241;

>Any ideas?

>Peter

Tue, 25 Sep 2001 03:00:00 GMT  How do I set a static variable value?
Maybe you need two static variables to do this?

Static blnInitialized as Boolean
Static X as Integer
If Not  blnInitialized Then
X=241
blnInitialized =True
End If
........
Neila

Quote:

>Folks.

>If I declare a static variable like this:

>Static Dim X As Integer

>then X is initialised to 0. How do I set the initial value to say 241?
>In C terms, I want the equivalent of:

>static long int X = 241;

>Any ideas?

>Peter

Tue, 25 Sep 2001 03:00:00 GMT  How do I set a static variable value?
you miay not like this BUT
private function muFunction()
static valye as integer
static first as integer ' set to 0

if(first = 0) then
value = 234
fidst = 1
end if

etc.

you might also check the "initial" " default" value of a Bool (first as
bool)

Quote:

> Folks.

> If I declare a static variable like this:

> Static Dim X As Integer

> then X is initialised to 0. How do I set the initial value to say 241?
> In C terms, I want the equivalent of:

> static long int X = 241;

> Any ideas?

> Peter

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Most of what I have learned has been taught to me by others.
I guess that means I have to teach others what I have learned
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lately It Occurs To Me
What A Long Strange Trip Its Been
(R. Hunter)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Tue, 25 Sep 2001 03:00:00 GMT  How do I set a static variable value?
seems like booleans are default to false:,
same logic though.

Quote:

> Folks.

> If I declare a static variable like this:

> Static Dim X As Integer

> then X is initialised to 0. How do I set the initial value to say 241?
> In C terms, I want the equivalent of:

> static long int X = 241;

> Any ideas?

> Peter

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Most of what I have learned has been taught to me by others.
I guess that means I have to teach others what I have learned
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lately It Occurs To Me
What A Long Strange Trip Its Been
(R. Hunter)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Tue, 25 Sep 2001 03:00:00 GMT  How do I set a static variable value?
Folks,

tks for the replies. All consistent with each other so it seems it's the only
way. I just thought it could be initialised at design time, much like the
syntax of a Const...

Quote:

> Maybe you need two static variables to do this?

> Static blnInitialized as Boolean
> Static X as Integer
> If Not  blnInitialized Then
> X=241
> blnInitialized =True
> End If
> ........
> Neila

> >Folks.

> >If I declare a static variable like this:

> >Static Dim X As Integer

> >then X is initialised to 0. How do I set the initial value to say 241?
> >In C terms, I want the equivalent of:

> >static long int X = 241;

> >Any ideas?

> >Peter

Wed, 26 Sep 2001 03:00:00 GMT

 Page 1 of 1 [ 6 post ]

Relevant Pages