Search code examples
arraysbasicqbasicfreebasic

Array Not Dimensioned Before


I have the following QuickBasic 4.5 code:

IF LEN(Dir$("mtn.vga")) > 0 THEN
BLOAD "mtn.vga", VARPTR(mtn(1))

I'm trying to port it to FreeBasic but receive the error:

Array not dimensioned, before '('

IF LEN(Dir("mtn.vga")) > 0 THEN

       ^

Any ideas?


Solution

  • That specific line is perfectly valid FreeBASIC code (it works even if you keep the dollar sign after Dir()). I ran this test code just to make sure, and it works as one would expect:

    IF LEN(DIR("sa.bas")) > 0 THEN 'sa.bas is the name of this file
        PRINT "file exists"
    END IF
    

    Would you mind putting a larger chunk of code (maybe on pastebin and link me to it)? The cause of the problem may be somewhere just earlier in your code.