SOLVED: props.onValue from Custom-modul

Hi
is it possible to put the onValue entrys from the custom-modul?
Is the syntax

props.onValue = \`
..
\`
	receive('/EDIT', 'matrix_art', {'props': `JS{{
	var props = {}
	var VARartName = [${artName}]
	var VARartColor = [${artColor}]
	var MatrixIndex = [17,18,19,20,37,38,39,40,57,58,59,60,13,14,15,16,33,34,35,36,53,54,55,56,9,10,11,12,29,30,31,32,49,50,51,52,5,6,7,8,25,26,27,28,45,46,47,48,1,2,3,4,21,22,23,24,41,42,43,44]
	props.colorWidget = VARartColor[$]
	props.alphaFillOff = 1
	props.alphaFillOn = 0
	props.lineWidth = 0
	props.padding = 1
	props.css = "font-size: 80%"
	props.wrap = "soft"
	props.mode = "tap"
	props.label = VARartName[$]
	props.address = "/program"
	props.preArgs = [
		1,
		MatrixIndex[$]-1
	]
	props.target = "midi:OSC"
	props.onValue = \`
	var instrumentCode = parseInt(get("text_code", value))
	var vepKeys = get('variable_vepKeys')
	var s1 = parseInt(vepKeys.keys[instrumentCode].'s' + MatrixIndex[$]-1) 
	var e1 = parseInt(vepKeys.keys[instrumentCode].'e' + MatrixIndex[$]-1) 
	var sk1 = vepKeys.keys[instrumentCode].'sk' + MatrixIndex[$]-1
	var ek1 = vepKeys.keys[instrumentCode].'ek' + MatrixIndex[$]-1
	set ("range_2A_art_keyboard", [s1,e1+1])
	set ("text_2A_art_range_key_start", sk1)
	set ("text_2A_art_range_key_end", ek1)
	\`
	return props
	}}`
	});

If i am doing that way, I receive this error

Bildschirmfoto 2023-03-17 um 18.51.03

There error message shows that the onValue was set but contains syntax errors (btw you didn't post the full error message, there should be a line number indication that points to where the problem is). At first glance I see at least one syntax error:

Statements such as

vepKeys.keys[instrumentCode].'s'

are not valid in javascript, should be

vepKeys.keys[instrumentCode].s
// or
vepKeys.keys[instrumentCode]['s']

Thanks for the tip... I have already made further progress.

Is it possible that in the props.onValue the variable $ is recognized?
I tried this in Line 5 to replace the value 14 with $, but the message comes that $ is not defined.

	props.onValue = `
	var MatrixIndex = [17,18,19,20,37,38,39,40,57,58,59,60,13,14,15,16,33,34,35,36,53,54,55,56,9,10,11,12,29,30,31,32,49,50,51,52,5,6,7,8,25,26,27,28,45,46,47,48,1,2,3,4,21,22,23,24,41,42,43,44]
	var instrumentCode = parseInt(get("text_code", value))
	var vepKeys = get('variable_vepKeys')
	var s = parseInt(vepKeys.keys[instrumentCode].s[$]) 
	var e = parseInt(vepKeys.keys[instrumentCode].e14) 
	var sk = vepKeys.keys[instrumentCode].sk14
	var ek = vepKeys.keys[instrumentCode].ek14
	set ("range_2A_art_keyboard", [s,e+1])
	set ("text_2A_art_range_key_start", sk)
	set ("text_2A_art_range_key_end", ek)
	`

Bildschirmfoto 2023-03-18 um 09.30.35

$ is only defined in the matrix' props property, use getIndex() in scripts instead.

Hey great... getIndex() is the solution that helps for my matrix.
Very thanks Jean-Emmanuel

Here is the fixed code I have now:

	props.onValue = `
	var MatrixIndex = [17,18,19,20,37,38,39,40,57,58,59,60,13,14,15,16,33,34,35,36,53,54,55,56,9,10,11,12,29,30,31,32,49,50,51,52,5,6,7,8,25,26,27,28,45,46,47,48,1,2,3,4,21,22,23,24,41,42,43,44]
	var instrumentCode = parseInt(get("text_code", value))
	var vepKeys = get('variable_vepKeys')
	var s = parseInt(vepKeys.keys[instrumentCode]['s' + MatrixIndex[getIndex(this)]])
	var e = parseInt(vepKeys.keys[instrumentCode]['e' + MatrixIndex[getIndex(this)]]) 
	var sk = vepKeys.keys[instrumentCode]['sk' + MatrixIndex[getIndex(this)]]
	var ek = vepKeys.keys[instrumentCode]['ek' + MatrixIndex[getIndex(this)]]
	set ("range_2A_art_keyboard", [s,e+1])
	set ("text_2A_art_range_key_start", sk)
	set ("text_2A_art_range_key_end", ek)
	`
1 Like