Using many conditionals to check 20columns in a table DAT to run different text DAT's

Hey there, i think this might be simple, but i’m travelling and dont got My pc with me, so i just wanna be sure. I’m having a table DAT, with 20 columns, that receive like 10 different messages. I need that every message trigger something different, and the code needs to check if the message was delivered in every column. How can i do it?

It’s something like

if op('table1')[1,(1-20)] == 'open:palm'
   op(text1').run()

And Also, i have only used the ‘if’ ‘elif’ and ‘else’. But now i must have 10 differents conditionals, so should i repeat the ‘elif’ statement??

Thanks!!!

It needs to run only when ALL of the cells in that row have the exact same value? You could do something like:

if op('table1').row(1) == (['open:palm'] * 20) :

or something… AKA whatever is the proper way to make a list of repeated items in python…

and yeah you can just repeat elif statements, and even end with an else if you want to catch any exceptions - but make sure your indenting matches because python sure gets grumpy if you don’t…

1 Like

Also also, SPM is now available in the new stable release!

You could also check the findCells function and just check how long it is as a listComparison can get pretty slow.
DAT Class - Derivative _> findCells

2 Likes

If your possible combinations are already known, then I’d consider constructing a hashmap so you only need a single .get() call to a dictionary rather than a lot of conditionals.

The idea would be that something like “open:palm” is the key that points to your resulting call rather than searching through all of your columns for the right match.

1 Like