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?
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
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.