Hello community!
I got a bit stuck while using Classes, so I'm hoping someone could help me out.
A bit of context: I am working on a script which is divided into two: a main script and a functions script, where the latter is then included into the main script. I am trying to work with Classes and Namespaces, to make sure variables are only found when they are supposed to be found. My specific problem comes when trying to use the "On Change" function with a Col List Box.
I made a minimal working example that illustrates my problem. Consider the main code:
Names Default To Here(1);
Clear log(); Clear Globals(); Clear Symbols();
// Include the class script
If( !Namespace Exists( "mainNamespace" ), New Namespace( "mainNamespace" ) );
mainNamespace:dir = Get Default Directory();
Include(mainNamespace:dir || "classScript.jsl");
// Create an object of the class and try to use the function
testObject = New Object( exampleClass());
testObject:method1();
and then the class script:
Names Default To Here(1);
If( !Namespace Exists( "classNamespace" ), New Namespace( "classNamespace" ) );
Define Class("exampleClass",
_init_ = Method( {},
this:BC = Open( "$SAMPLE_DATA/Big Class.jmp", Show(1) );
this:window = Empty();
);
method1 = Method({},
this:window = New Window( "Test Window", clb = Col List Box( all, On Change( Show( clb << Get Items ) ) ) );
);
);
The idea is to have a window open where you can select some columns from a data table, and then get a list with the columns selected. This works fine when I don't use Classes, i.e., if I just write the classes part of the script as "normal" code. The code above manages to open up the Big Class data table, and the window with the Col List Box, but whenever I click on a column, I get an error:
Send Expects Scriptable Object in access or evaluation of 'Send', clb << /*###*/Get Items /*###*/
Is there something I'm doing wrong, or not understanding? Or is it something to do with how "On Change" is programmed? Any help is appreciated!