Cicode Programming Reference > Cicode Function Categories > String Functions > StrSetChar

StrSetChar

Sets a single character into a string or buffer. Use this function to build up a string, character by character, and terminate the string with the end-of-string character 0 (zero). (If you use a string without a terminator in a function that expects a string, or in a Cicode expression, you could get invalid results.) To use the string to build up a buffer, you do not need the terminating 0 (zero).

Syntax

StrSetChar(sText, iOffset, Char)

sText:

The destination string. Must be a String type variable.

iOffset:

The offset in the string, commencing at 0.

Char:

The ASCII character to set into the string.

Return Value

0 (zero) if successful, otherwise an error code is returned.

Related Functions

StrGetChar

Example

! Set chars in buffer, Buf is NOT a valid string
! and cannot be used where a normal string would be used.
FOR i = 0 To length DO
StrSetChar(Buf, i, 30 + i);
END
StrSetChar(sStr, 0, 13); ! put CR into string
StrSetChar(sStr, 1, 0); ! terminate so may be used as a normal string

See Also

String Functions, Using the Caret Escape Sequence Character

Published June 2018