$IPRINT_ON and $IPRINT_ON directives

Purpose:

By default, the BCX translator replaces a backslash (\) with a double backslash (\\). To prevent BCX from replacing a backslash (\) with a double backslash (\\) place $IPRINT_OFF before the line containing the backslash (\). To restore the default behavior place $IPRINT_ON in the code.

$IPRINT_OFF allows the insertion of a functional C escape sequence into a string.

The default BCX setting is $IPRINT_ON.

Syntax:

$IPRINT_OFF
' Code that must have backslashes preserved goes here
$IPRINT_ON

Example 1:

DIM UTF8$, OrigCodePage%
OrigCodePage% = GetConsoleOutputCP()
SetConsoleOutputCP(1252)

DIM HAUTESTYLE$
DIM bassestyle$
DIM guillemets$
DIM droits$
    
$IPRINT_OFF
 HAUTESTYLE$ = "\xC0;\xC2;\xC4;\xC6;\xC7;\xC8;\xC9;\xCA;\xCB;\xCE;\xCF;\xD4;\xD9;\xDB;\xDC;"
 bassestyle$ = "\xE0;\xE2;\xE4;\xE6;\xE7;\xE8;\xE9;\xEA;\xEB;\xEE;\xEF;\xF4;\xF9;\xFB;\xFC;"
 guillemets$ = "\xAB\xBB"
 droits$ = "\xA9\xAE"
$IPRINT_ON

?
 
PRINT HAUTESTYLE$
PRINT bassestyle$
PRINT guillemets$
PRINT droits$

SetConsoleOutputCP(OrigCodePage)

Result:

ÀÂÄÆÇÈÉÊËÎÏÔÙÛÜ
àâäæçèéêëîïôùûü
«»
©®

Example 2:

DIM UTF8$, OrigCodePage%
OrigCodePage% = GetConsoleOutputCP()
SetConsoleOutputCP(1252)

?

$IPRINT_OFF
 MACRO McCoy = "Hello! \nWe're \xa9 The Real McCoypyright Co.!"
$IPRINT_ON
PRINT McCoy$

SetConsoleOutputCP(OrigCodePage)

Result:

Hello!
We're © The Real McCoypyright Co.!

Example 3:

$IPRINT_OFF and MACRO can be used to embed NULL in a string. For example, the code snippets below can be used to embed NULL in the initialization of the lpstrFilter member in the OPENFILENAME structure used by the Win32 API GetOpenFileName and GetSaveFileName dialog box functions.

$IPRINT_OFF
MACRO szBASFilter$   = "BAS Files (*.bas)\0*.bas\0\0"
MACRO szRCFilter$    = "RC Files (*.rc)\0*.rc\0\0"
MACRO szDLGFilter$   = "DLG Files (*.dlg)\0*.dlg\0\0"
MACRO szDLGRCFilter$ = "DLG Files (*.dlg)\0*.dlg\0RC Files (*.rc)\0*.rc\0\0"
MACRO szCFilter$     = "C Files (*.c)\0*.c\0\0"
MACRO szHFilter$     = "H Files (*.h)\0*.h\0\0"
MACRO szEXEFilter$   = "EXE Files (*.exe)\0*.exe\0\0"
MACRO szCHMFilter$   = "CHM Files (*.chm)\0*.chm\0\0"
MACRO szHLPFilter$   = "HLP Files (*.hlp)\0*.hlp\0\0"
$IPRINT_ON

$IPRINT_OFF
MACRO szFilter$     = "EXE Files (*.exe)\0*.exe\0BAS Files (*.bas)\0*.bas\0All Files (*.*)\0*.*\0\0"
MACRO szFilterBas$  = "BAS Files (*.bas)\0*.bas\0All Files (*.*)\0*.*\0\0"
MACRO szFilterObj$  = "LIB/OBJ Files (*.lib)\0*.lib\0OBJ Files (*.obj)\0*.obj\0All Files (*.*)\0*.*\0\0"
$IPRINT_ON