0 THEN BLOAD "mtn.vga", VARPTR(mtn(1)) I'm trying to port it to FreeBasic but rece" /> 0 THEN BLOAD "mtn.vga", VARPTR(mtn(1)) I'm trying to port it to FreeBasic but rece" /> 0 THEN BLOAD "mtn.vga", VARPTR(mtn(1)) I'm trying to port it to FreeBasic but rece"/>

Array Not Dimensioned Before

841 Views Asked by At

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?

2

There are 2 best solutions below

0
Alex V On BEST ANSWER

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.

0
ExagonX On

In FreeBASIC the $ after String Variable is deprecated is usefull only if you want use for a compatible program with older BASIC

Follow the example program for understand what do the DIR()

'This example show you how work if want verify the exist file.

Print DIR("lendir.bas") ' Dir("namefile.ext") show the name of file if exist

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

'or you can use this too

IF DIR("lendir.bas") = "" THEN 'If file not exist
    PRINT "file not exists"
   Else 
    PRINT "file exist"
END IF

BLOAD Loads arbitrary data from a file created with BSave, or a compatible BMP image file.

But you Have to be sure if the original code is QB or QuickBASIC because have different way to take the same things

Example fbc myprog.bas -lang qb doesnt work with this example try fblite instead qb