diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 443fe6a..7716820 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -1205,13 +1205,13 @@ class BuiltinFunction munch(str, " "); if(str.length > 2 && str[0..2] == "&H") { - int r; + uint r; str = str[2..$]; - if (tryParse!(int, wstring)(str, 16, r)) + if (tryParse!(uint, wstring)(str, 16, r)) { if (!str.empty) return 0; - return r; + return cast(int)r; } else { @@ -1220,13 +1220,13 @@ class BuiltinFunction } if(str.length > 2 && str[0..2] == "&B") { - int r; + uint r; str = str[2..$]; - if (tryParse!(int, wstring)(str, 2, r)) + if (tryParse!(uint, wstring)(str, 2, r)) { if (!str.empty) return 0; - return r; + return cast(int)r; } else { diff --git a/SMILEBASIC/project.d b/SMILEBASIC/project.d index 34a483b..e14d497 100644 --- a/SMILEBASIC/project.d +++ b/SMILEBASIC/project.d @@ -202,6 +202,13 @@ r"ファイルを書き込みます。 File f = File(path, "rb"); DataHeader[1] harray; f.rawRead(harray); + if (harray[0].magic != "PCBN0001") + { + f.seek(0); + harray[0].dimension = 1; + harray[0].dim[] = [cast(int)f.size, 0, 0, 0]; + harray[0].type = DataType.int_; + } if (harray[0].dimension != contents.dimCount) { throw new TypeMismatch("LOAD"); @@ -241,6 +248,10 @@ r"ファイルを書き込みます。 f.rawRead(array); result = array.map!(x => x.to!T).array; } + else + { + throw new TypeMismatch("LOAD(invalid file)"); + } //配列に書き込むというより配列を差し替えている contents.array = result; contents.dim[] = harray[0].dim[];