Key Pages: [
Rope Home Page |
Basics (tutorial) |
Language Reference |
Download
]
Rope Language Reference - "substr".
The "substr" action returns a specified portion of an original string (refer to string for comments on Rope's string handling). "substr" takes three arguments (in the following order) ..
- the original string
- the offset at which the sub-string is to start
- the desired sub-string length.
For example, this script prints the word "Three".
put( "Three blind mice" $a )
substr( $a 0 5 ) println
And this prints "bli"
put( "Three blind mice" $a )
substr( $a 6 3 )
Note:
- It is an error for either the offset or length to be negative
- Offset zero refers to the first character in the string, and offset one refers to the second (etc), as per the conventions of C, Java, Perl - etc.
- If the "offset" is beyond the end of the string, the result will silently (ie: no error is reported) be an empty return string.
- If the "length + offset" is greater than the length of the string, then the return will be shorter than the specified length.
- Unlike the "substr" function in some other languages, the Rope version requires all three arguments.
Lowth.com: [
Home |
Rope |
P2PWall |
LinWiz |
cutter |
Protector - Free Antivirus software |
TapeIO ]