how to: insert items into a drop-down box using transcript

Ken Ray kray at sonsothunder.com
Thu May 12 21:07:59 EDT 2005


On 5/12/05 4:56 PM, "Emilio Gagliardi" <emilio at ualberta.ca> wrote:

> Greetings revolution programmers,
> I hope that someone can point me in the right direction of some
> examples or tutorials that demonstrate how to use transcript to add
> items to a drop down list based on some variable.  For example, on
> PreOpenCard reads the directories where the application is currently
> loaded and then generates a drop-down list with items that match the
> available directories.

OK. The first thing to keep in mind is that this is not like REALBasic or
Visual Basic, etc. where you need to iterate through the items that the drop
down button will contain, adding each one to the list through each
iteration.

It is extremely simple... Suppose you had a variable that had a
return-delimited list of strings, like:

  One
  Two
  Three
  Four

and the variable that held this data was called "tList", and the drop-down
button you want to use is called "DropDown", you would do this:

  put tList into btn "DropDown"

That's it! Now you can drop down the menu button and see the menu displayed.
When you select an item from the list, you get a "menuPick" message, so the
button would have a script like:

on menuPick pChoice
  -- Do what you want with the selected menu item in "pChoice"
end menuPick

Now to get the actual list of directories, you can check out the code here
to get you going:

  http://www.sonsothunder.com/devres/revolution/revolution.htm?_file007

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list