Class property cannot be referred in member function

I was trying to write a class in squirrel:
class Serial{ // constructor constructor(baud){ buffer = blob(4); hardware.uart57.configure(baud, 8, PARITY_NONE, 1, NO_CTSRTS, RxCallback); } // functions function RxCallback(){ local byte = hardware.uart57.read(); while(byte != -1){ buffer.writen(byte,'c'); byte = hardware.uart57.read(); } } // properties buffer = null; }
However, whenever the program goes into the RxCallback function, there is an error: “the index ‘buffer’ does not exist”. I thought the properties could be referred by member functions. Am I doing something incorrectly?

One more weird thing is that we can do similar thing on agent without any problem.

quick thought shouldn’t buffer declared local ?

Here is an example from Squirrel 3.0 reference manual:
`class Foo {
//constructor
constructor(a)
{
testy = [“stuff”,1,2,3,a];
}
//member function
function PrintTesty()
{
foreach(i,val in testy)
{
::print("idx = “+i+” = “+val+”
");
}
}
//property
testy = null;

}`

Here its property “testy” is not declared local

Think you need RxCallback.bindenv(this) in your callback not just RxCallback. As the callback is called from the global context, it needs the class reference.

My guess is that in your agent it wasn’t the system calling the reference, but local code.