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:

  • RetStr$ returned enclosed MainStr$.
  • MainStr$ string to be enclosed in quotation marks(").

Example 1:

 PRINT ENC$("Hello") ' produces "Hello"


 Syntax 2:
 RetStr$ = ENC$(MainStr$ [, EnclosingChar%])

 Parameters:

  • RetStr$ returned enclosed MainStr$.
  • MainStr$ string to be enclosed by EnclosingChar%.
  • EnclosingChar% [OPTIONAL] ASCII code integer of character to be placed at the beginning and end of the MainStr$ string.

Example 2:

 PRINT ENC$("A",68) ' produces   DAD


 Syntax 3:
 RetStr$ = ENC$(MainStr$ [, LeadChar%, TrailChar%])

 Parameters:

  • RetStr$ returned enclosed MainStr$.
  • MainStr$ string to be enclosed by LeadChar% and TrailChar%.
  • LeadChar% [OPTIONAL] ASCII code integer of character to be placed at beginning of the MainStr$ string.
  • TrailChar% [OPTIONAL] ASCII code integer of character to be placed at end of the MainStr$ string.

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"\nHello, World"
 

Example 2:

 
 RetStr$ = "Hello, "+ ENC$("BCX")+" World"
 

is functionally equivalent to the extended string literal

 
 RetStr$ = E"Hello, \qBCX\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)