setData()  cat()

Chapter 5: General Objects and Methods

String objects

String objects are null-terminated linear collection of printable characters. To define a string object, use the form:

string obj_name;

You can use C language operators on strings, as shown below:

NoteBecause strings are null terminated, when converting from a blob to a string, if the blob contains a null character, ODL copies into the string only the contents of the blob up to that null character

Use these methods to manipulate string object data, or use the following arithmetic and comparison operators: =, +, ++, !+, <, >, <=, and >=. Adding control characters to a string must be done using the format method or by converting the string to a blob and appending the control character.

You can access individual bytes of string object data by indexing into the string object. String objects have a zero-based index. Do not subscript past the size of the string:

char ch;
string stuff;
stuff = “this is a test.”;
ch = stuff[3]; 
//ch now contains “s”

You can truncate a string by assigning a null to one of the data bytes in the string object:

string stuff;
stuff = “some data, and other data you don’t need”;
stuff[9] = ‘\000’:

You can also use a pointer to the string object:

string *pb;
char first_char;
first_char = (*pb) [0];

NoteIf you use a pointer to a string object, use the format shown in the Usage section under the table heading “Pointer to object.”





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

View this book as PDF