[SOVED] My first ever DAT Scrip bases on Matthew Ragan tuorial (works in text mode but not in DAT Execute)

Hello Everyone

Today, I’ve finally took the courage to have a deeper look into DAT’s.
After watching the series of Matthew Ragan (about python) I’ve tried to recreate one of his “variables examples” reading a table.

The Script works fine in text mode but as many probably know it’s annoying to always use CMD + R to run it.

I can’t figure out why the same code doesn’t work in the DAT Execute node.
I’ve tried using a button to active the Node and also a lfo (ramp) Chop.
Also i tried using the value-change mode in the DAT Execute node with no success either.

So my Question:
How or what do I have to change so the code works with a DAT Execute node?

Thanks in advance fo any hints!

Code Issue:

def onOffToOn(channel, sampleIndex, val, prev):

#define variable
lines = op (‘lines’)
presets = op(‘number_lines_presets’)
row_ref = int( op(‘presets_change’)[‘chan1’] )

#change some paramters
lines.par.value0 = presets [row_ref , ‘number_lines’]


DAT_Execute_isue.tox (1.5 KB)

Python is sensitive to spacing and indentations. you don’t have you lines of code indented properly. your code needs to be indented by one tab underneath the “def onOffToOn” function

def onOffToOn(channel, sampleIndex, val, prev):

	#define variable
	lines = op ('lines')
	presets = op('number_lines_presets')
	row_ref = int( op('presets_change')['chan1'] )
	#change some paramters
	lines.par.value0 = presets [row_ref , 'number_lines']

also, if you click on the red circle with the “X” in it when you get an error you can often see exactly what the problem is problem is, or at least get pointed to the offending line of code. The error message will also show up in the textport.

Hy Tomsepe

Thank you very much for your fast reply! It worked as you said, i wasn’t aware that python is sensitive in that way.
Great input :slight_smile: