开发者

Array Not Dimensioned Before

开发者 https://www.devze.com 2023-02-28 10:13 出处:网络
I have the following QuickBasic 4.5 code: IF LEN(Dir$("mtn.vga")) > 0 TH开发者_开发问答EN

I have the following QuickBasic 4.5 code:

IF LEN(Dir$("mtn.vga")) > 0 TH开发者_开发问答EN
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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号