TIP: All About Arrays

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

TIP: All About Arrays

Postby david » Wed Dec 31, 2003 9:23 am

Add all your array tips to this thread!

(1) Make an array out of a field that is a checkbox:
Code: Select all
var myArray = check_field_name.split('\n');

A field that is a check box puts a new line character (\n) between each value in the field.

(2) Determine number of array items:
Code: Select all
var myArrayLength = myArray.length;

(3) Array elements start numbering from zero. To access an array element:
Code: Select all
var myArrayItem1 = myArray[0];

(4) To loop through the elements of an array:
Code: Select all
for ( var i = 0 ; i < myArray.length ; i++ )
{
   application.output(myArray[i]);
}

(5) To load a value list with an array:

Code: Select all
application.setValueListItems('valueListName', myArray);


"valueListName" needs to already be created as a custom value list.

- david
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Return to How To

Who is online

Users browsing this forum: No registered users and 10 guests