cat()  debug()

Chapter 5: General Objects and Methods

copy()

Description

Copies data from the source, starting at the offset for a specified length, and replaces the data in the string with the copied data. The first character in the source is always at an offset of zero. The offset parameter is optional. If an offset if not given, copying starts with the first character in the source and continues for the specified length.

Syntax

copy(string source, int length, int offset);

Parameter

Description

source

Source of the data to copy. Can be another string object or a literal, enclosed in double quotes.

length

The number of characters of data to copy.

offset (optional)

Location from which to begin copying data. The first character in a string or literal is always at offset zero.

Return value

Integer. Returns 1 for success, and 0 for failure.

Usage

Pointer to object

Object

ps->copy(“abc123”,3,3);

mystring.copy(“def456”,3,1);

ps->copy(my_string_var, 5);

mystring.copy(my_string_var, 10);

Examples

Example 59

string mystr;
string new_stuff;
mystr = “abcdefg”;
new_stuff = “123456789”;
mystr.copy(new_stuff, 5, 2);
// mystr now contains "34567"




Copyright © 2005. Sybase Inc. All rights reserved. debug()

View this book as PDF