CHR$ function

Purpose:

CHR$ returns a string which contains the character[s] corresponding to the Windows Code Page code point integer argument[s], each of which must have a value between 0 and 255.

Up to, approximately, 8000 comma separated Windows Code Page code point integers can form the function argument list.

Syntax:

RetStr = CHR$(ASCode1, [ASCode2, ... ASCode26])

Return Value:

  • Data type: STRING
    RetStr string which contains the character[s] corresponding to the Windows Code Page code point integer arguments[s].

Parameters:

  • Data type: INTEGER
    ASCode1 [OPTIONAL] parameter containing Windows Code Page code point integer[s]. Up to, approximately, 8000 comma separated Windows Code Page code point integers can form the CHR$ parameter argument list.

Example 1:

DIM str1$
str1$ = CHR$(66)
PRINT str1$;
str1$ = CHR$(67)
PRINT str1$;
str1$ = CHR$(88)
PRINT str1$

Result:

BCX

Example 2:

DIM str1$
str1$ = CHR$(66, 67, 88)
PRINT str1$

Result:

BCX

Remarks:

CHR$ is a function complementary to ASC, which returns the Windows Code Page code point value when given a character argument.

Example 3:

CHR$ can be used to construct a binary string.

DIM A$

memcpy(A$, CHR$(65, 66, 67, 13, 10, 13, 10, 0, 0, 0, 67, 66, 65), 13)

OPEN "Test.bin" FOR BINARY NEW AS FP1
PUT$ FP1, A$, 13
CLOSE

BCX Console Sample Programs using CHR$ function.