Qbasicnews.com
Why does using STATIC give me an error? - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Why does using STATIC give me an error? (/thread-5921.html)



Why does using STATIC give me an error? - BiLLaMoNsTeR - 02-04-2005

This works in QBASIC, but not in FreeBASIC for some reason.
It says duplicated definition for "dim array(47) as integer".

Code:
sub subname ()
static array() as integer, notfirst

if notFirst = 0 then
   notFirst = 1
   dim array(47) as integer
end if

end sub

Am I doing something wrong?

EDIT: Whoops, I just figured out that doing "STATIC array(47)" to dimension the variable works.


Why does using STATIC give me an error? - relsoft - 02-04-2005

redim?


Why does using STATIC give me an error? - barok - 02-04-2005

maybe array's a keyword or something? I dunno... I recall something about how you have to have '$dynamic (or just DYNAMIC now) or something'll happen to variables.

I got nothing. :lol:


Why does using STATIC give me an error? - v3cz0r - 02-06-2005

STATIC syntax is FB is the same as with DIM or REDIM, not like in QB where you have to declare the array twice, simple do:

static somearray(lowerbound to upperbound, ...) as sometype

lowerbound and upperbound can't be variables, only constant expressions.