clr()  cut()

Chapter 5: General Objects and Methods

copy()

Description

Copies part of a blob, starting at location offset for a user-defined length, and places the copy into another blob or string. The first character in a blob is always at offset 0. If the offset plus the length is greater than the total length of the blob, or if the length is -1, the copy() method copies data from the offset position to the end of the blob.

Syntax

copy(int offset, int length, {blob | string} destination);

Parameter

Description

offset

Starting location to copy data. The first character in a blob is always at offset 0.

length

Number of characters to copy.

destination

blob or string in which to place the data.

Return value

Integer. Returns the specified length of data copied, if successful, and 0, if failed.

Examples

Example 42

blob other_blob; 
//Blob object to place copied data into 
pb->copy (5,20,&other_blob); 

//copies 20 char of data, starting at an offset of 5
blob my_blob;	
//places it into new_stuff
string new_stuff; 
//blob object to copy data from
my_blob = “abcdefghijk”; 
//string object to copy data to
my_blob.copy(4,-1,&new_stuff); 
//copy data from my_blob from “e” to end of blob, and //places it into new_stuff. my_blob is unchanged and //new_stuff now contains “efghijk”.

Usage

Pointer to object

Object

pb->copy(0, 4, &some_blob);

myblob.copy(0, 4,&some_blob_ptr);

pb->copy(4, 4, &namestring);

myblob.copy(4, 4, &string_ptr);





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

View this book as PDF