You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with file operations, specifically when there is an exception while writing to a file (when the file does not exist in this instance). When I call Reset(F); on a non existing file, the program just crashes with no message. This only happens after I execute some JavaScript code.
I noticed that in BESENShell, you are calling the Reset function like this {$i-}reset(f,1);{$i+};. Why is it necessary to supress thrown exceptions like this? Are there any other situations, where I can run into this error?
Here is some code that results in a crash. Thanks for your help.
program BESENTest;
{$APPTYPE CONSOLE}
uses
SysUtils, BESEN, BESENValue, BESENTypes, BESENASTNodes, BESENNativeObject, BESENNumberUtils;
var
lResult : TBESENValue;
lResultStr: String;
lBesen : TBESEN;
F: file of char;
function BesenValToStr(aBesenVal : TBESENValue):string;
begin
case aBesenVal.ValueType of
bvtUNDEFINED: Result := '';
bvtNULL: Result := '<null>';
bvtBOOLEAN: Result := BoolToStr(aBesenVal.Bool);
bvtNUMBER: Result := FloatToStr(aBesenVal.Num);
bvtSTRING: Result := aBesenVal.Str;
bvtOBJECT: Result := '<object>';
bvtREFERENCE: Result := '<reference>';
bvtLOCAL: Result := '<local>';
bvtNONE: Result := '<none>';
end;
end;
begin
try
lBesen := TBESEN.Create();
try
lResult := lBesen.Execute('1+1');
lResultStr := BesenValToStr(lResult);
Writeln(lResultStr);
finally
lBesen.Free;
end;
AssignFile(F,'doesnotexist.log');
try
try
Reset(F);
//{$i-}Reset(f);{$i+};
finally
CloseFile(F);
end;
except
on Ex: Exception do
Writeln(Ex.Classname, ': ', Ex.Message);
end;
ReadLn;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
end.
The text was updated successfully, but these errors were encountered:
I have a problem with file operations, specifically when there is an exception while writing to a file (when the file does not exist in this instance). When I call
Reset(F);
on a non existing file, the program just crashes with no message. This only happens after I execute some JavaScript code.I noticed that in BESENShell, you are calling the Reset function like this
{$i-}reset(f,1);{$i+};
. Why is it necessary to supress thrown exceptions like this? Are there any other situations, where I can run into this error?Here is some code that results in a crash. Thanks for your help.
The text was updated successfully, but these errors were encountered: