remobjects / pascalscript

pascalscript
Other
447 stars 178 forks source link

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

Open aliule2020 opened 2 years ago

aliule2020 commented 2 years ago

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) );
}**
TetzkatLipHoka commented 1 year ago

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.