by Invisible Ray » Sat Nov 14, 2015 7:21 pm
I got it to work, but I had to use a slight workaround.
Function of the script: Use a select list to trigger predefined sets of layer effects via functions
variables used in the script:
# list used to populate a text list control
fxList = ['none','scale','scale_w']
# assigning variables to functions
fx0 = nofx
fx1 = fscale
fx2 = fscale_w
# ordered list of the variables
funcList = [fx0,fx1,fx2]
# control name and Script Connect message of the text list control
'lfxL'
lfx = 0 #index position of low freq fx selected
mfx = 0 #index position of mid freq fx selected
hfx = 0 #index position of hi freq fx selected
# list used to store params for the three FX functions
# is low active, lfx, is mid active, mfx, is high active, hfx
actFX = [0,lfx,0,mfx,0,hfx]
<script snippet in 'MessageEvent() module>
if msg == 'lfxL':
myFunc = module.getValue('lfxL', 'selection') #get item selected in list
listPos = fxList.index(myFunc)
actFX[1] = listPos
********************************
What the code does:
1) user selects an item in the list
2) the selection sends a message: 'lfxL'
3) variable myFunc is set to the text of the item selected in the list
4) listPos is set to the index position of myFunc when found in the list 'fxList'
5) actFX list item at position [1] is updated with the value of listPos
What I would like to do to make the code more efficient:
I should be able to directly assign the index position of the item selected in lfxL to the item actFX[1]
My problem is that I can't figure out how to return the index number of an item selected in a list control. I can return the text of the selected item, but not the index number, so I have to search for the text string in a list of the items, then assign that number to the actFX list.
** using this built in function: module.getValue('lfxL', 'selection') **
It doesn't matter what I choose for the Value of the control attribute.
If I set it to "Text" I get the text of the item selected
If I set it to "Abs. Index" I get 0, no matter which item I select
If I set it to "Prop. Index" I get 0, no matter which item I select