Page 1 of 1

Option menu tagged to array

Posted: Wed Nov 11, 2015 6:14 pm
by saviour
Hi guys,,

Please need some help. I dont know if it is possible or not. But lets see.

I have some data array in field "mylist" in following manner:

xx,xxx
yy,yyy
zz,zzz

I am able to populate option menu ( with xx or yy or zz);

Now, Is it possible to having either option selected, retreive related data as in array like xx to retrieve xxx.....

Thanks....

Re: Option menu tagged to array

Posted: Wed Nov 11, 2015 8:06 pm
by dunbarx
Hi.

I assume you do not want to see the "related" data in the actual button, that is, you want to see "xx" but "get" "xxx". Is this true?

If so, load the array into a custom property, and grab the associated data, since it is already built. A "key" would be chosen from the option menu and the associated element pulled from the property. Do you know how to do that?

Craig Newman

Re: Option menu tagged to array

Posted: Thu Nov 12, 2015 2:17 am
by saviour
Thanks for that.. :D

Yes, I want related data 'XXX' in another custom variable or field if key "XX' chosen in the menu. Please guide me :oops:

Re: Option menu tagged to array

Posted: Thu Nov 12, 2015 5:51 pm
by jacque
You can shorten the handler a bit:

Code: Select all

on preopencard
    put fld "MyList" into gMyArray
    split gMyArray by cr and comma
   set the text of btn "listIn" to the keys of gMyArray
end preopencard
The do what Craig said, use the selection as the array key to get the value.

Re: Option menu tagged to array

Posted: Thu Nov 12, 2015 7:33 pm
by dunbarx
OK. I am going to do this for you, but you have to examine each line (there are only a few) of the following handlers and tell me what they do. On a new card, make a field, standard button, and an option button. Name the option button "XYZ".

In the field, put your:

Code: Select all

xx,xxx
yy,yyy
zz,zzz
In the script of the standard button:

Code: Select all

on mouseUp
     put fld 1 into gMyArray
     split gMyArray by cr and comma
     set the text of btn "XYZ" to the keys of gMyArray
   set the relatedData of btn "XYZ" to gMyArray
end mouseUp
In the script of the option button:

Code: Select all

on menuPick pItemName
   get the relatedData of me
   answer it[pItemName]
end menuPick
A little Jacque, a little me. I expect comments.

Craig

Re: Option menu tagged to array

Posted: Fri Nov 13, 2015 3:31 pm
by saviour
Thanks a lot guys.

Your suggestions are like lightbulb to me. I am able to do it by putting the menu selection in another variable and finally feeding it to the array.

put gMyArray[tOption] into tName
Answer tName

Thanks again.