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:
|
Example 1:
PRINT ENC$("Hello") ' produces "Hello"
Syntax 2: RetStr$ = ENC$(MainStr$ [, EnclosingChar%]) Parameters:
|
Example 2:
PRINT ENC$("A",68) ' produces DAD
Syntax 3: RetStr$ = ENC$(MainStr$ [, LeadChar%, TrailChar%]) Parameters:
|
Example 3:
PRINT ENC$("HTML",60,62) ' produces <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:
RetStr$=
CHR$
(
10
)
+
"Hello, World"
is functionally equivalent to the extended string literal
RetStr$=
E
"
\n
Hello, World"
Example 2:
RetStr$=
"Hello, "
+
ENC$
(
"BCX"
)
+
" World"
is functionally equivalent to the extended string literal
RetStr$=
E
"Hello,
\q
BCX
\q
World"
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) \" - double quotation mark - CHR$(34) \' - Single quotation mark - CHR$(39) \\ - backslash - CHR$(92)