Qbasicnews.com

Qbasic "like" compilers/interpreters => FB Discussion & Programming Help => Topic started by: BiLLaMoNsTeR on February 04, 2005, 12:44:01 AM



Title: Why does using STATIC give me an error?
Post by: BiLLaMoNsTeR on February 04, 2005, 12:44:01 AM
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.


Title: Why does using STATIC give me an error?
Post by: relsoft on February 04, 2005, 02:47:05 AM
redim?


Title: Why does using STATIC give me an error?
Post by: barok on February 04, 2005, 02:51:56 AM
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:


Title: Why does using STATIC give me an error?
Post by: v3cz0r on February 05, 2005, 06:42:03 PM
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.