From OpenSCADAWiki
(Importing a new version from external source) |
(Importing a new version from external source) |
||
Line 1: | Line 1: | ||
Array provides the special property "length" to get the array size "'''var = arr.length;'''". Also array provides the following functions: | Array provides the special property "length" to get the array size "'''var = arr.length;'''". Also array provides the following functions: | ||
− | * ''string join( string sep = "," )'', ''string toString( string sep = "," )'', ''string valueOf( string sep = "," )'' — | + | * ''string join( string sep = "," )'', ''string toString( string sep = "," )'', ''string valueOf( string sep = "," )'' — returns the string with the array elements separated by ''sep'' or the character ','. |
− | * ''Array concat( Array arr );'' — | + | * ''Array concat( Array arr );'' — adds to the initial array the elements of the ''arr'' array. Returns the initial array with changes. |
− | * ''int push( ElTp var, ... );'' — | + | * ''int push( ElTp var, ... );'' — places the element(s) ''var'' to the end of the array, as to the stack. Returns the new array size. |
− | * ''ElTp pop( );'' — | + | * ''ElTp pop( );'' — deletes of the last element of the array and returns of its value, as from the stack. |
− | * ''Array reverse( );'' — | + | * ''Array reverse( );'' — changes the order of the elements of the array. Returns the initial array with the changes. |
− | * ''ElTp shift( );'' — | + | * ''ElTp shift( );'' — shifts of the array to the top. The first element is removed and its value is returned. |
− | * ''int unshift( ElTp var, ... );'' — | + | * ''int unshift( ElTp var, ... );'' — shifts element(s) ''var'' to the array. The first element to the 0, second to the 1 and so on. |
− | * ''Array slice( int beg, int end );'' — | + | * ''Array slice( int beg, int end );'' — returns an array fragment from ''beg'' to ''end'' (exclude). If the value of beginning or end is negative, then the count is made from the end of the array. If the end is not specified, then the end is the end of the array. |
− | * ''Array splice( int beg, int remN, ElTp val1, ElTp val2, ... );'' — | + | * ''Array splice( int beg, int remN, ElTp val1, ElTp val2, ... );'' — inserts, deletes or replaces the elements of the array. Returns the removed elements array. Firstly it is made the removing of elements from the position ''beg'' and in the quantity of ''remN'', and then the values ''val1'' are inserted and so on, beginning from the position ''beg''. |
− | * ''Array sort( );'' — | + | * ''Array sort( );'' — sorts array elements in the lexicographical order. |
Revision as of 12:52, 6 February 2018
Array provides the special property "length" to get the array size "var = arr.length;". Also array provides the following functions:
- string join( string sep = "," ), string toString( string sep = "," ), string valueOf( string sep = "," ) — returns the string with the array elements separated by sep or the character ','.
- Array concat( Array arr ); — adds to the initial array the elements of the arr array. Returns the initial array with changes.
- int push( ElTp var, ... ); — places the element(s) var to the end of the array, as to the stack. Returns the new array size.
- ElTp pop( ); — deletes of the last element of the array and returns of its value, as from the stack.
- Array reverse( ); — changes the order of the elements of the array. Returns the initial array with the changes.
- ElTp shift( ); — shifts of the array to the top. The first element is removed and its value is returned.
- int unshift( ElTp var, ... ); — shifts element(s) var to the array. The first element to the 0, second to the 1 and so on.
- Array slice( int beg, int end ); — returns an array fragment from beg to end (exclude). If the value of beginning or end is negative, then the count is made from the end of the array. If the end is not specified, then the end is the end of the array.
- Array splice( int beg, int remN, ElTp val1, ElTp val2, ... ); — inserts, deletes or replaces the elements of the array. Returns the removed elements array. Firstly it is made the removing of elements from the position beg and in the quantity of remN, and then the values val1 are inserted and so on, beginning from the position beg.
- Array sort( ); — sorts array elements in the lexicographical order.