我使用以下 7 行将文件
NameF
的字节放入 FreeBasic 0.4.6 FBide 中的向量 T()
中
有更好或更短的方法吗?
DIM L as ulong, NameF as string
Input "Enter Name of the File", NameF
Open NameF For Binary As #1
L= LOF(1)
Close #1
DIM T(1 to L) As Ubyte
Open NameF For Binary Access Read As #1
Get #1, , T()
Close #1
7条线工作正常。如果可行的话,我正在寻求改进。
减少2行是一个进步,谢谢大家
那么 3 行就更好了(不需要单独的 L 变量,以及冗余的
Close
和 Open
命令):
DIM NameF as string
Input "Enter Name of the File", NameF
Open NameF For Binary Access Read As #1
DIM T(1 to LOF(1)) As Ubyte
Get #1, , T()
Close #1