Using bindenv() with objects


#1

I’m guessing this is a “noob” question here but I can’t seem to wrap my head around using bindenv() for this particular example. Just making sure I’m not completely crazy.

Basically, as I understand it, is that what you pass into bindenv(passed) is the environment that would be bound to what you’re “binding.” This question stems from me having 2 classes, one that is used to collect data from a sensor, the other for calibrating the data for the specific use. My first class will be logging data every few seconds and doing statistical analysis to it but I also want it to pass that data after the statistics are done into the 2nd class to calibrate it for the use of the user. Soooooo, if that wasn’t confusing enough, is it correct that you can pass an object into a classes function and then use bindenv(theObjectPasses) to allow the first class to have access to the second classes “addData” function.

Example:

class dataCollect {

secondClass <- null;

 function bindToSecondClass(anObject) {
       secondClass = anObject;
 }

function logData() {                                                /////////// Will this function work? when called, will it take
         addData(someData).bindenv(aFutureObject);           data from sensor and log it to
 }                                                                                          aWaterWell.addData()

}

class compileClass {

 function addData() {
      ......
 }

}

sensor <- dataCollect();
aWaterWell <- compileClass();

sensor.bindToSecondClass(aWaterWell);

This is more of me trying to understand here. There is a real example off of this but I hope this comes across as sensible? So sorry for the… non understanding


#2

Well… there’s no delete button. But there probably is considering how much I didn’t think this through…

forget bindenv… you can just pass the object of one into another and call from that… sooo I over complicated things way to much.

:smiley: