I see two issues in this example that I think should help you resolve the issue:
The first to consider is that 0 is not a valid entry - if you look at the storage keys you’ll see that the presets all start at 1 - preset1, preset2, etc.
Looking closely at the recall script we can see that we’re joining the word “preset” with an integer in order to reconstruct the string that we’re using as a key.
The second, and probably more important thing to know / think about, is that chops are floats. So while it may look like an integer to you, under the hood it’s evaluated as a a float… so 1 becomes 1.0. Subsequently you end up with a key that’s preset1.0, which doesn’t have a match in the dictionary.
If you cast your chop channel to an integer first, it looks like things all work as expected:
[code]# attempt 2: doesn’t working
this should grab the chan1 from constant1 chop
but doesn’t seems to work
recallVal = int(op( ‘constant1’ )[ ‘chan1’ ])
Does that all make sense?