我有以下QuickBasic 4.5代码:
IF LEN(Dir$("mtn.vga")) > 0 THEN
BLOAD "mtn.vga", VARPTR(mtn(1))我试图将其移植到FreeBasic,但接收错误:
阵列没有尺寸,在“(”)之前
如果LEN(Dir("mtn.vga")) >0
^
有什么想法吗?
发布于 2011-05-02 23:00:45
这一行代码是完全有效的FreeBASIC代码(即使在Dir()之后保留美元符号也有效)。我运行这个测试代码只是为了确保,它的工作就像人们所期望的那样:
IF LEN(DIR("sa.bas")) > 0 THEN 'sa.bas is the name of this file
PRINT "file exists"
END IF您介意把更大的代码块(也许在pastebin上并将我链接到它)吗?问题的原因可能就在代码的早期位置。
发布于 2020-04-06 14:20:00
在FreeBASIC中,$ after字符串变量是不推荐的,只有当您希望使用与旧BASIC兼容的程序时才有用。
按照示例程序来理解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 IFBLOAD从用BSave创建的文件或兼容的BMP图像文件中加载任意数据。
但是您必须确定原始代码是QB还是QuickBASIC,因为有不同的方式来处理相同的事情。
示例fbc myprog.bas -lang qb无法使用此示例尝试fblite代替qb
https://stackoverflow.com/questions/5762005
复制相似问题