This is an open group. Sign in and click the "Join Group" button to become a group member and start posting.
Community Trekker

Further documentation on the '<<Select Where' message in JSL?

Hi guys,

I'm just wondering if there is further documentation on the allowed syntax and operation of the << select where( insert condition here ) message (or << Get Rows Where()) that you can send to a datatable in JSL.

For me, this represents one of the more powerful features of the JSL scripting language and allows the user to accomplish a wide range of tasks with a single line of code.

However, I feel there is a need to further explain its operation (i.e. is the condition specified in the brackets run for each row, etc.)  and allowable syntax. It just seems that a user has to build up knowledge of what works for a specific task rather than intuitively knowing what is possible for a lot of cases.

I'd give MATLAB's logical indexing functionality as an example where there are clear rules as allowable syntax, and where you can intuitively input conditions to get the matches you are looking for.

Just wanted to start a discussion on this. Feel free to add.

Thanks everyone!

Re: Further documentation on the '<<Select Where' message in JSL?

I agree that these messages are powerful and make scripting much easier than it would be without them.

Their syntax and usage is straightforward.  These messages take Boolean arguments. Any expression that evaluates to true or false is valid. Also, any numerical result will work, where 0 is interpreted as false and any other value is interpreted as true. The expression is evaluated row-wise, substituting the column reference in the expression with the value for that column in the current row.

Using Big Class as an example, you select all female observations with Current Data Table() << Select Where( :sex == "F" ). In this case, the column reference is literal. If you are using a column reference stored in a variable instead, then you must append "[]" after the column name. So my example would become col = Column( "sex" ); Current Data Table() << Select Where( :col[] == "F" ).

Of course the Boolean expression could select on multiple criteria by using other logical functions, as in Current Data Table() << Select Where( :sex == "F" & :age == 12 ).

That is really about all there is to it.

Learn it once, use it forever!