CHAPTER 5 STORING AND RETRIEVING APPLICATION DATA (Mac os x web server)
CHAPTER 5 STORING AND RETRIEVING APPLICATION DATA 149 In this example, the strNamesArray is resized to allow it to hold up to ten elements. Once an array is resized, you can begin assigning new elements to it. Note Visual Basic programmers should take note that in REALbasic, the Redim statement behaves differently than it does in Visual Basic. Unlike Visual Basic, redimensioning an array in REALbasic does not cause the loss of all the elements already defined in it. Incrementing an Array Size an Element at a Time In addition to redimensioning an array, REALbasic also lets you dynamically append data to the end of an array without first changing its size. This is accomplished through the Append method, as shown in the following. strNamesArray.Append “Dolly” This statement automatically increases the size of the strNamesArray by one and adds a new element to the end of the array. The Append method only works with single-dimension arrays. Inserting Data into the Middle of an Array REALbasic also enables you to insert new elements into any index position you choose within an array. This is accomplished by using the Insert method, as the following shows. strNamesArray.Insert 2, “Dolly” In this example, a new array element is inserted into the third index position of the array. The previously stored data in the array s third index position is reassigned to the fourth index position. Likewise, all other data stored above index position 3 automatically have their index number shifted up by one. The Insert method only works with single-dimension arrays. Deleting Array Elements REALbasic also provides the capability to selectively remove individual array elements using the Remove method. The Remove method works by deleting the data stored in the specified index position. The following statement demonstrates how to remove the third element from an array. strNamesArray.Remove 2 Once an element is deleted, all remaining array elements have their index position shifted down by one position. The Remove method only works with single-dimension arrays. Working with Dictionaries One drawback of working with arrays is you are limited to accessing array elements only by their index position within the array. REALbasic provides an alternative to arrays in the form of dictionaries. A dictionary is an object made up of key-value pairs. What this means is, in
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.