Chr Function | |
Convert an ASCII code to a character value.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax FUNCTION Chr(
dwCode AS DWORD
) AS STRING
public static string Chr(
uint dwCode
)
Request Example
View SourceParameters
- dwCode
- Type: DWord
An ASCII code from 0 to 255.
Return Value
Type:
String
A single character that corresponds to
dwCode.
Remarks
Chr() is the inverse of Asc(). Chr() serves a number of common tasks including:
Sending control codes and graphics characters to the screen or printer
Ringing the bell
Converting InKey() return values to characters
Stuffing the keyboard buffer
Chr(0) has a length of 1 and is treated like any other character; this lets you send it to any device or file, including a database file.
Tip |
---|
_Chr() is an operator that does the same thing as the Chr() function.
As an operator, it is evaluated at compile time and can be used in DEFINE, GLOBAL, or STATIC LOCAL statements to specify initial values. Because it does not incur the overhead of a function call, it is more efficient. Here is an example:
1DEFINE CRLF := _Chr(ASC_CR) + _Chr(ASC_LF) |
Remarks
The value of dwChar must be between 0 and 255
The return value of Chr() in XSharp depends on the setting of SetAnsi().
When SetAnsi() = TRUE then the active windows Ansi codepage is used to calculate the character.
When SetAnsi() = FALSE then the active windows Oem codepage is used to calculate the character.
This is different from the behior in most single byte versions of Xbase where Chr() simply returnes a string with a single byte
that matches the number passed to this function.
Examples
These examples illustrate Chr() with various arguments:
1? Chr(Asc("A") + 32)
2? Chr(7)
3? Chr(72)
See Also