Pull Down Menu with Variable Array

I would like to have a pull down menu that will allow me to assign a value to a variable.

I have created a two column Array where the first column is DESCRIPTION and the second column is the NAME of a file.

The Array is 10 rows long.

When I scroll down the array when I find the description I want I want it to grab the corresponding NAME of that file and assign it to a variable that will be used in other procedures.

I’ve tried the “Popup Button Options” without success. I have had success with “Popup Button Options” when “hard wired” but not when it is a variable.

I have confirmed that the variable is a two column array with this case having 10 rows.

Can someone give me a little advice here?

Thanks.

Here’s my take on this double array used in a Popup Menu Button Object. This is what I set up as the variables for my test:

letfileglobal testMenu="One•Something1
Two•Something2
Three•Something3
Four•Something4
Five•Something5
Six•Something6
Seven•Something7
Eight•Something8
Nine•Something9
Ten•Something10"
letfileglobal menuOut=""
letfileglobal fileOut=""

Now for the Popup Menu Button Options I have Data set to menuOut, Data Source set to Field/Variable and Mode set to Formula. In the Formula pane I have:

arraycolumn(testMenu,1,cr(),"•")

In the Procedure pane I have:

fileOut=arraylast(array(testMenu,arraysearch(arraycolumn(testMenu,1,cr(),"•"),menuOut,1,cr()),cr()),"•")

Now the Popup Button only shows the first column of the testMenu variable for choosing (the Description in your example). Once chosen, the attached procedure searches the first column of testMenu for the value of menuOut that has been selected and uses that value to find the corresponding compound element of in the testMenu array. It then extracts the second or last part of that element. Now when you select Seven from the popup list, fileOut will have a value of Something7.

You can change the separators to the ones you are currently using. The only problem may be if you have two Descriptions with the same exact value.

Thanks Gary.

Wow, no wonder I had challenges.

Still banging away at your example. The only thing left is for me to see the Variable “fileOut”

Once again you’re up to the challenge.

Amazing!

I have it working Gary.

My last problem seeing the variable was not using the
showvariables statement.

Thank you again.

Gary, I have to hand it to you. When I read the original question, I didn’t understand it and I thought it was impossible. However, I was just misreading it. Fortunately you did not do that.

Now that you’ve helped me understand the actual question, I have a slight improvement on the answer. In the Procedure panel I think it would be much simpler to use the arraylookup( function, which is designed for exactly this purpose.

Another gem I forgot existed even though something was nagging me that a simpler solution was possible. This simplifies my original procedure code of:

fileOut=arraylast(array(testMenu,arraysearch(arraycolumn(testMenu,1,cr(),"•"),menuOut,1,cr()),cr()),"•")

to:

fileOut=arraylookup(testMenu, menuOut, cr(), "•", "")

More than a ‘slight’ improvement in my opinion. Also I should add the showvariables fileOut that I left off the original code.

All too common among us by my experience.

Thanks for the help. Sorry if I did not explain my challenge correctly.