String objects  copy()

Chapter 5: General Objects and Methods

cat()

Description

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

Syntax

cat(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->cat(“abc123”, 3, 3);

mystring.cat(“def456”, 3);

ps->cat(my_string_var,5, 2);

mystring.cat(my_string_var, 10);

Examples

Example 58

string mystr;
mystr = “abcdefg”;
mystr.cat(“123456789”, 3, 4);
//mystr now contains “abcdefg567”




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

View this book as PDF