An archive of community.esquilo.io as of Saturday January 26, 2019.

Learning Squirrel/ modified Sprinkler.NUT example

iaintravelgalloway

I'm using the Sprinkler.NUT as a reference example for a H bridge motor driver for a bleach pump.
I thought i was following along with Squirrel ok.. but don't understand why this error gets thrown.

Running nut 'sd:/LIB/DEMOS/BLEACH/BLEACH.NUT'.

%%Runtime error [the index 'IN2' does not exist]

CALLSTACK
*FUNCTION [constructor()] sd:/LIB/DEMOS/BLEACH/BLEACH.NUT line [53]
*FUNCTION [main()] sd:/LIB/DEMOS/BLEACH/BLEACH.NUT line [330]

LOCALS
[_IN2] INSTANCE
[_gpio] INSTANCE
[_name] "Backyard Swimming23"
[this] INSTANCE
[vargv] ARRAY
[this] TABLE

This is the constructor:

constructor(_name, _gpio, _IN2)
{
    name = _name;
    gpio = _gpio;
    IN2 = _IN2;    <--Line 53

And this is the modfied Zonelist

zoneList <- [
    Zone("Backyard Swimming23", GPIO(2), GPIO(3)),
    Zone("Backyard Swimming45", GPIO(4), GPIO(5)),
];

I feel like i must be missing something simple like interaction with other files?

iaintravelgalloway

AH....oops, i see now.
I didn't include IN2 in the class members!
Works when i add it at the bottom of the Class:

// Class members
onTimer = null;
offTimer = null;
name = "";
gpio = null;
IN2 = null;