FUNCTION:  String.removeAt

String.removeAt(string, index, separator)
 
The String.removeAt function takes the given string, removes the element at the given index, removes the given separator, and returns the modified string.
 
This function treats a string as an array composed of elements delimited by a separator that is composed of one or more specified characters (including white space). The first index position is numbered zero and the last index position is the total number of the elements minus one. The total number of elements in the string can be found by using the String.elements function.
 
You can insert new elements using the String.insertAt function.
 
The mandatory string parameter can be any string containing one or more of any combination of characters and white spaces.
 
The mandatory index parameter is the position of the element in the string array. A negative index number will cause the first element to be removed and will not generate an error. An index number larger than the actual number of elements will cause the last element to be removed and will not generate an error.
 
The mandatory separator parameter can be any character or white space that you wish to use to divide the string into substrings called elements. This parameter can also be an empty string.
 
Code for RemoveAtExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   removeAt example
   </p>
   <do type="accept">
      <go href="RemoveAtExample.wmls#findremoveat()" />
   </do>
</card>

<card id="card2">
<p>
   string = $(oldstring)
   <br />
   index = $(index)
   <br />
   separator = $(separator)
   <br />
   new string = $(newstring)
</p>
</card>

</wml>

 
Code for RemoveAtExample.wmls
extern function findremoveat()
{
   var oldstr = Dialogs.prompt("Enter a string", "Hello wireless world!");
   var indx = Dialogs.prompt("Enter an index", "1");
   var sep = Dialogs.prompt("Enter a separator", " ");
   var newstr = String.removeAt(oldstr, indx, sep);
   WMLBrowser.setVar("oldstring", oldstr);
   WMLBrowser.setVar("index", indx);
   WMLBrowser.setVar("separator", sep);
   WMLBrowser.setVar("newstring", newstr);
   WMLBrowser.go("InsertAtExample.wml#card2");
};

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information