$ONENTRY directive
Purpose: Directive to perform functions after BCX translation but before any $COMPILER, $LINKER, $RESOURCE, or $ONEXIT directives.
Syntax: $ONENTRY "StringLiteralDirective" Parameters:
|
Example:
$ONENTRY "echo Starting to compile $file$"
$ONEXIT directive
Purpose: Directive to perform functions after BCX translation and after any $COMPILER, $LINKER, $RESOURCE, or $ONENTRY directives.
Syntax: $ONEXIT "StringLiteralDirective" Parameters:
|
Example:
$ONEXIT "echo Completed compiling the C translation of $FILE$"
$BCX$ macro substitute
$BCX$ is a replaceable macro substitute for the path to the \bin\ directory containing the BC.EXE file.
☞ The $BCX$ macro can be used only with the $COMPILER, $LINKER, $RESOURCE, $ONENTRY and $ONEXIT directives.
Syntax: $BCX$ Parameters:
|
Remarks:
This path is derived from the Registry entry made during the BCX installation process and includes a trailing backslash.
If the \bin\ directory has been moved since the installation then this macro will not function properly. To correct the Registry entry after such a move run the BCX translator with the -r switch.
BC -r
To determine, for certain, the value which would be returned by the $BCX$ macro, run the following one line program.
PRINT BCXPATH$
$FILE$ macro substitute
$FILE$ is a self-referencing substitute for the file name without the extension. For example, if the file name is ThisFile.bas, $FILE$ will substitute ThisFile.
$FILE$ can be used only with the $COMPILER, $LINKER, $RESOURCE, $ONENTRY and $ONEXIT directives.
Syntax:
$FILE$
Parameters:
|
$PELLES$ macro substitute
$PELLES$ is a replaceable macro substitute for the root path, including a trailing backslash, of the Pelles C installation. The root path is derived from the Registry entry made by the Pelles C installation process. If the Pelles C directory has been moved since the installation then this macro will not function properly.
To determine for certain the value which would be returned by the $PELLES$ macro, run the following one line program.
PRINT PELLESPATH$
The $PELLES$ macro can be used only with the $COMPILER, $LINKER, $RESOURCE, $ONENTRY, and $ONEXIT directives.
Syntax: $PELLES$ Parameters:
|
$WARNINGS_OFF and $WARNINGS_ON directives
Purpose: BCX emits, in the C translation, a number of #pragma statements which can disable some C/C++ compilation warnings.
The $WARNINGS_OFF directive suppresses the C/C++ compiler warnings specified in the #pragma statements. This is the default when neither warning directive is used.
The $WARNINGS_ON directive does not suppress any warnings. The compiler will issue warnings according to the warning level options that are set.
The BCX command line option -w will activate the $WARNINGS_ON directive, in addition to activating BCX BASIC translation warnings.
☞ The $WARNINGS directive, functionally equivalent to the $WARNINGS_ON directive is deprecated.
$LEANANDMEAN directive
Purpose: The $LEANANDMEAN directive is a wrapper for the Win32 API WIN32_LEAN_AND_MEAN define. When $LEANANDMEAN is used, some header files are excluded by windows.h including the OLE, RPC, and network headers.
$NOWIN directive
Purpose: Creates program with no WIN32 header files.
By default, BCX includes several common WIN32 header files. You can disable this by adding the line $NOWIN to your BASIC program source code. This will save you from having to remove those Win32 *.h files if you want to use the "C" code with another non-windows "C" compiler -- such as the free Turbo C compiler from Borland.
$RESOURCE directive
Purpose: Directive to invoke a resource compiler. If the $LINKER directive is used then the $RESOURCE directive must be placed before the $LINKER directive.
Syntax: $RESOURCE "ResourceCompiler" ["ResourceFile.rc"] Parameters:
|
Example:
$RESOURCE "$PELLES$\bin\porc.exe" "Resource.rc"
BCX_RESOURCE statement
Purpose: This statement is used to inline statements which would usually be placed in an .rc resource file.
If the BCX_RESOURCE statement is used without a prior $RESOURCE directive, a file named $FILE$__.rc is created in the default directory. In this case the $FILE$__.rc file is not compiled.
If a .rc resource file has been specified as a parameter in the $RESOURCE directive, the specified .rc file is copied to a new file named $FILE$__.rc to which the BCX_RESOURCE statements are concatenated. The $FILE$__.rc file is then compiled into a .res file. If the $LINKER directive is used after the $RESOURCE directive, the resulting .res file is also linked into the .exe file.
Syntax: BCX_RESOURCE .rc format statement Parameters:
|
Example:
The following example requires an icon file and a .bmp file named, respectively, "smiley.ico" and "smiley.bmp". Click here to download a .zip file containing the .ico and .bmp files. Save the example code below as test32.bas, unpack the smiley.zip and save the following batch file into the same directory and run the batch file to compile.
Compilation Batch file:
CALL povars32.bat bc test32
GUI "BCX_RESOURCE", ICON, 1234 $RESOURCE "$PELLES$\bin\porc.exe" $COMPILER "$PELLES$\Bin\pocc -W1 -Gd -Go -Ze -Zx -Tx86-coff $FILE$.c" $LINKER "$PELLES$\Bin\polink _ -release _ -machine:X86 _ -subsystem:windows _ $FILE$.obj _ -OUT:$FILE$.exe" BCX_RESOURCE 1234 ICON "smiley.ico" SUB FORMLOAD GLOBAL Form1 AS HWND Form1 = BCX_FORM("BCX_RESOURCE", 0, 0, 150, 153) BCX_SET_FORM_COLOR(Form1,QBCOLOR(31)) GLOBAL hCtl AS CONTROL hCtl = BCX_BMPBUTTON("smiley.bmp", _ Form1, _ 5678, _ 9, _ 9, _ 0, _ 0) CENTER(Form1) SHOW(Form1) END SUB BEGIN EVENTS SELECT CASE CBMSG CASE WM_CLOSE DestroyWindow(Form1) EXIT FUNCTION END SELECT END EVENTS
$BCX_RESOURCE directive
Purpose: The $BCX_RESOURCE directive performs the same function as the BCX_RESOURCE statement above but it is used to bracket a block of resource statements. A $BCX_RESOURCE directive is placed before and after the resource statements.
Syntax: $BCX_RESOURCE /** Resource statements go here */ $BCX_RESOURCE |
Example:
$BCX_RESOURCE #define IDM_FONT 40001 "IDMAINMENU" MENU BEGIN MENUITEM "&About Me !", IDM_FONT END $BCX_RESOURCE
GETRESOURCE function
Purpose: The GETRESOURCE function returns, if successful, a pointer to the first byte of the resource; otherwise NULL is returned. The size of the resource is also returned through the &ResourceSize parameter.
Syntax: RetLPVOID = GETRESOURCE(ResourceID AS INTEGER, _ ResourceType AS STRING, _ &ResourceSize) Return Value:
Parameters:
|
Example: Save the example code below as test32.bas, save the following batch file into the same directory and run the batch file to compile.
Compilation Batch file:
CALL povars32.bat bc test32
$RESOURCE "$PELLES$\bin\porc.exe" $COMPILER "$PELLES$\Bin\pocc -W1 -Gd -Go -Ze -Zx -Tx86-coff $FILE$.c" $LINKER "$PELLES$\Bin\polink _ -release _ -machine:ix86 _ -subsystem:console _ -OUT:$FILE$.exe _ $FILE$.obj _ $FILE$__.res" BCX_RESOURCE 12345 RCDATA "C:\\Windows\\Media\\Ring05.wav" BCX_RESOURCE 12346 RCDATA "C:\\Windows\\Media\\Alarm05.wav" BCX_RESOURCE 12347 RCDATA "C:\\Windows\\Media\\tada.wav" GLOBAL hInstance AS HINSTANCE ? : ? : ? : PRINT " Playing Ring05.wav " :? : ? : ? PlayRcSound(hInstance, 12345) SLEEP(100) ? : ? : ? : PRINT " Playing Alarm05.wav " :? : ? : ? PlayRcSound(hInstance, 12346) SLEEP(100) ? : ? : ? : PRINT " Playing tada.wav " :? : ? : ? PlayRcSound(hInstance, 12347) ? "Done, Hit any Key to Quit." KEYPRESS SUB PlayRcSound(hInst AS HINSTANCE, ResourceID%) DIM lpSndData AS LPVOID DIM RSize AS ULONG lpSndData = GETRESOURCE(ResourceID%, RT_RCDATA, &RSize) IF lpSndData <> 0 THEN PlaySound((LPCTSTR) lpSndData, hInstance, SND_MEMORY+SND_SYNC) EXIT SUB END IF END SUB
$COMPILER directive
Purpose: Directive to invoke a compiler.
Syntax: $COMPILER "StringLiteralDirective" Parameters:
|
Example:
$COMPILER "$PELLES$\Bin\pocc -W1 -Gd -Go -Ze -Zx -Tx86-coff $FILE$.c"
Using the Pelles C Compiler driver, cc.exe, the following example, when placed at the beginning of the code for a DLL, will compile and link automatically when the bc.exe translator has finished translating the code file.
Example:
$COMPILER "$PELLES$\Bin\CC -W1 -Gz -Ze -Zx -Go -Tx86-coff $FILE$.c -release -machine:ix86 -subsystem:windows -dll"
$LINKER directive
Purpose: Directive to invoke a linker.
Syntax: $LINKER "StringLiteralDirective" Parameters:
|
Example 1: Windows mode
$LINKER "$PELLES$\Bin\polink _ -release _ -machine:ix86 _ -subsystem:windows _ -OUT:$FILE$.exe _ $FILE$.obj "
Example 2: Console mode
$LINKER "$PELLES$\Bin\polink _ -release _ -machine:ix86 _ -subsystem:console _ -OUT:$FILE$.exe _ $FILE$.obj "
$BCXVERSION directive
Purpose:
The $BCXVERSION directive is placed at top of source file and if the BCX version is less than that specified by the directive, BCX will abort with a message that the translator must be updated. If the BCX version is equal to or greater than that specified by the directive, a statement is emitted stating the version of the translator specified in the $BCXVERSION directive.
The $BCXVERSION directive can be used to specify the minimum version of the BCX translator required to translate the program.
Syntax: $BCXVERSION "Version String" Parameters:
|
Example:
The following will abort code translation if the BCX version is prior to 3.82a.
$BCXVERSION "3.82a"
BCXVERSION$ variable
Purpose: BCX_VERSION$ can be used to retrieve the version of the BCX translator that was used when the program was translated.
Syntax: RetStr = BCX_VERSION$ Return Value:
Parameters:
|
Example 1 : This example will return the version of the BCX translator that was used when the example was translated.
DIM RetStr$ RetStr$ = BCX_VERSION$ PRINT RetStr$