======slice====== Extract a part of a [[PTPScript:Types:String|String]], [[PTPScript:Types:Number|Number]], or [[PTPScript:Types:Array|Array]]. \\ **Syntax** * ''[[PTPScript:Types:Mixed|Mixed]] slice( [[PTPScript:Types:Mixed|Mixed]] subject, [[PTPScript:Types:Number|Number]] start [, [[PTPScript:Types:Number|Number]] length [, [[PTPScript:Types:Boolean|Boolean]] preserve ] ] )'' \\ **Parameters** * [[PTPScript:Types:Mixed|Mixed]] ''subject'' - The entity to slice. * [[PTPScript:Types:String|String]] - The portion of the String specified by the ''start'' and ''length'' parameters will be returned. * [[PTPScript:Types:Number|Number]] - The Number will be treated as a String. * [[PTPScript:Types:Array|Array]] - The sequence of items in the Array specified by the ''start'' and ''length'' parameters will be returned. * [[PTPScript:Types:Number|Number]] ''start'' - The position to start slicing from. If ''start'' is non-negative, the position will be calculated from the beginning of ''subject'', otherwise it will be calculated from the end. * [[PTPScript:Types:Number|Number]] ''length'' - The number of elements (characters in a String, or items in an Array) to return. If omitted, everything from ''start'' to the end of ''subject'' will be returned. If positive, the sequence will contain that many elements, otherwise if negative, the sequence will stop that many elements from the end of ''subject''. * [[PTPScript:Types:Boolean|Boolean]] ''preserve'' - The optional ''preserve'' parameter only has any effect if ''subject'' is an Array. * **''false''** (default) - The keys in the Array returned will be re-assigned from ''0''. * **''true''** - The original keys will be retained. \\ **Result** * [[PTPScript:Types:Mixed|Mixed]] - The resulting sequence. * [[PTPScript:Types:String|String]] - If ''subject'' is a String or Number. * [[PTPScript:Types:Array|Array]] - If ''subject'' is an Array. Returns a sequence from ''subject'', defined by ''start'' and ''length''.