remobjects/pascalscript

why VGetInt( this->PSScript1->GetVariable("z") ) failed?

Opened this issue · 1 comments

script:

**program first;

var i,z:Integer;

begin
z:=0;
for i:=1 to 4 do
begin
z:=z+i;
end;
end.**

delphi:

**this->PSScript1->Script->LoadFromFile("script.txt");
ShowMessage("OK0");

if(this->PSScript1->Compile())
{

	ShowMessage("OK1");
	this->PSScript1->Execute();
	ShowMessage("OK2");

	a=   VGetInt( this->PSScript1->GetVariable("z") );

	ShowMessage( System::Sysutils::IntToStr(a) );
}**

You can't read a variable of a ended program.
In order to debug/read variables the script needs to be paused in execution after the variable was created.