Description
Arrays can be used in MetaScript to generate a static list to be used in Virtual Ticket popup menu fields. A static list would be used in situations where a SQL Query will not produce the list of items because they aren't stored anywhere in the database. Keeping your list sorted in alphabetical order requires the correct MetaScript sorting parameter to keep the list sorted correctly while the list continues to grow.
Example
This example demonstrates how to sort a static list that has been generated by a MetaScript array.
- Open a form in the form editor.
- Open the Global MetaScript Editor.
- Enter the following script into the Global MetaScript Editor:
function
getList()
{
var myList = new Array("Joe", "Steve", "Bob", "Sally", "Mike");
return myList.sort();
} - Create a popup field control on the form and assign a database field to it in the Field selector of the Control Properties panel.
- Make the field Editable by selecting "Yes" for the "Editable" value in the Control Properties panel.
- Select "MetaScript" in the Popup is filled by control of the Control Properties panel.
- Type "getList()" in the List MetaScript control of the Control Properties panel.
- Result: When the form is opened and the popup field is selected, the entries in the popup will appear in the following order:
Resources