Basic script the word "result" is not flagged at compile time...

Hello,

Installed the current version today. Delphi 10.2

This code:

DIM inBuffer as integer 
inBuffer=VarArrayCreate([0,1023],0x11)    '0x11 = byte

function IDGood as boolean
 result=((inBuffer[0] = 0) and (inBuffer[1] = 1))
end function

Compiles without error.
When used
if IDGood then <runtime error

This code:

function IDGood as boolean
 return ((inBuffer[0] = 0) and (inBuffer[1] = 1))
end function

Works.

Why is "result" not flagged as an error at compile time?

Cheers,

Mark

This script doesn't even compile. Are you sure this is the exact script you are using? What code are you using to compile it?

If I use this script:

DIM inBuffer as integer 

function IDGood as boolean
 result=((inBuffer[0] = 0) and (inBuffer[1] = 1))
end function

inBuffer=VarArrayCreate([0,1023],0x11)    '0x11 = byte

And I run it using this code:

procedure TForm4.Button1Click(Sender: TObject);
begin
  IDEScripter1.DefaultLanguage := slBasic;
  IDEScripter1.Scripts.Clear;
  IDEScripter1.CurrentScript := IDEScripter1.Scripts.Add;

  IDEScripter1.SourceCode := IDEMemo1.Lines;
  IDEScripter1.Execute;
end;

I get this error:

Please always provide exact steps to reproduce the issue, or a minimal sample project reproducing the issue.

This script doesn't even compile.

What error is produced?

Yes it complies here without error.

It is part of a much larger script so I did not include the complete script.

Here is the smallest that complies and runs without error.

DIM inBuffer as integer

function IDGood as boolean
 result=((inBuffer[0] = 0) and (inBuffer[1] = 1))
end function

inBuffer=VarArrayCreate([0,1023],0x11)    '0x11 = byte

if (IDGood = false) then
 beep
end if

The IDE I am using only does Basic so the default language is set at design time to Basic and this is the code to compile the script.

 atScripter1.SourceCode.Assign(scrMemo1.Lines);           //load the source to the compiler
 atScripter1.Compile;                                     //call compile

Then to run it:

atScripter1.Running:=True

In our main program we do exactly what you have shown:

  RunningScripter.DefaultLanguage := slBasic;
  RunningScripter.Scripts.Clear;
  RunningScripter.CurrentScript := IDEScripter1.Scripts.Add;

  RunningScripter.SourceCode := <load from a file>;
  RunningScripter.Compile;

Then if no errors we save it to a stream via "SaveCodeToStream" and then on demand load the stream and run it.

Can you please send a sample project reproducing the issue?