ENC$ function
Purpose: ENC$ encloses a string, by default, in double quotation marks(") or, optionally, encloses a string with the characters specified.
Syntax 1: RetStr$ = ENC$(MainStr$) Parameters:
Return Value:
|
Example 1:
PRINT ENC$("Hello")
Result:
"Hello"
Syntax 2: RetStr$ = ENC$(MainStr$ [, EnclosingChar%]) Parameters:
Return Value:
|
Example 2:
PRINT ENC$("A", 68)
Result:
DAD
Syntax 3: RetStr$ = ENC$(MainStr$ [, LeadChar%, TrailChar%]) Parameters:
Return Value:
|
Example 3:
PRINT ENC$("HTML", 60, 62)
Result:
<HTML>
Extended String Literal statement
Purpose: Prepending a capital E to the initial quotation mark of a string literal allows the insertion of a functional C escape code into the string.
Example 1:
DIMRetStr$ RetStr$=CHR$(10)&"Hello, World"
is functionally equivalent to the extended string literal
DIMRetStr$ RetStr$=E"\nHello, World"
Example 2:
DIMRetStr$ RetStr$="Hello, "&ENC$("BCX")&" World"
is functionally equivalent to the extended string literal
DIMRetStr$ RetStr$=E"Hello,\qBCX\qWorld"
Remarks:
Note well, that when using the extended string literal statement, any backslash (\) which is part of the string literal must be prepended with a backslash. Any embedded single quotation marks also must be prepended with a backslash.
Here are some typical C escape sequences. See your C compiler documentation for a complete list.
\0 - null - CHR$(0) \a - alert - CHR$(7) \b - backspace - CHR$(8) \t - tab - CHR$(9) \n - newline - CHR$(10) \t - vertical tab - CHR$(11) \f - form feed - CHR$(12) \r - carriage return - CHR$(13) \q - double quotation mark - CHR$(34) \' - Single quotation mark - CHR$(39) \\ - backslash - CHR$(92)