home *** CD-ROM | disk | FTP | other *** search
- C is the only language besides assembly language that can be used for writing
- memory-based BlackBoxes. Disk-Based BlackBoxes are also easy to do in C.
-
-
- ; ----------------------- MEMORY-BASED BLACKBOXES -----------------------
-
-
- When writing a Memory-Based BlackBox, you will need to generate two versions
- of your source code. The first version will be for the .OBJ to link into
- your source code, and the second will be for creating the .BBX.
-
-
- The steps for writing a Memory-Based BlackBox in C are as follows:
-
-
- 1. Write the C procedure as you normally would for an external procedure
- to be called from another C routine. Remember that BlackBoxes are
- always treated as procedures, not functions.
-
- For BlackBoxes, it is a good idea to keep to the following rules:
-
- 1. Any temporary space that's allocated should be released by the
- procedure before exiting.
-
- 2. Do NOT access the enviroment strings! As a C BlackBox, you do not
- have access to the enviroment strings of the program, since you do
- not know whether you are being run by FLOWCHRT.EXE or the created
- program.
-
- 3. Try to make the BlackBoxes as self-contained as possible.
-
-
- 2. For the parameters of the C procedure, the first is ALWAYS going to
- be an integer passed by value. This will be the LANGUAGE TYPE of the
- calling procedure. Most BlackBoxes will not use this, but it must
- still be declared as the first parameter in the BlackBox. The rest
- of the parameters follow in the reverse order that you intend to
- request.
-
- For example, if you want the BlackBox to request the following:
-
- 1. An Integer Value to be passed
- 2. A Resulting Integer Variable (int *)
- 3. A Resulting CheckBox Variable (char *
-
- The declaration of the procedure would look like this:
-
- void YOUR_BLACKBOX (lang_type, CheckBox_Result, Int_Result, Int_Value)
-
- int lang_type, Int_Value, *Int_Result;
- char *CheckBox_Result;
-
- 3. The C file should be ready for creating the .OBJ to link into the compiled
- C program. Compile, but do not link, this file, and copy the .OBJ created
- to a different name. The naming convention used by MATRIX is to add a
- c on to the file name, so that name.OBJ becomes nameC.obj.
-
-
- 4. In the source code, change the name of the BlackBox procedures to "main".
- This will create a .C suitable to make the .BBX. Compile this file and
- link it with the libraries CBBX_LIB+LLIBCE, along with the /NOE and /NOD
- flags. The order of the libraries is very important! You MUST link
- CBBX_LIB first, because it contains a modified version of the C Startup
- Code to accomodate the BlackBox structure. Rename this file to a .BBX.
-
- The Link command would might look like this:
-
- LINK /NOD /NOE your_bbx, your_bbx.bbx ,,CBBX_LIB+LLIBCE;
-
-
-
-
- ; ------------------------ DISK-BASED BLACKBOXES ------------------------
-
- A Disk-Based BlackBox written in C is basically a normal, self-contained,
- executable program which follows a few simple rules.
-
- 1. Any memory which is allocated by the disk-based blackbox MUST be
- deallocated before exiting the program.
-
- 2. Any File Handles which are opened must be closed before exiting the
- program.
-
- 3. The Disk-Based BlackBox CANNOT leave the screen in text mode before
- exiting, and it should preserve the top two lines of the screen in
- case a menu is present from the calling procedure.
-
- 4. The Interrupt vectors 0F3H and 0F4H cannot be replaced.
-
- 5. The program must exit normally, it cannot terminate and stay resident.
-
-
- The procedure for calling a disk-based blackbox is as follows:
-
- 1. The parameters are pushed on the stack as if calling a memory-based
- blackbox. Note that the last parameter pushed will always be the
- LANGUAGE_TYPE integer value.
-
- 2. The value of the stack pointer and stack segment is stored in the
- graphics device driver using int 0F3H
-
- 3. An EXEC call (DOS CALL 21H, subfunction 4BH) is made to load and
- execute the disk-based blackbox.
-
- 4. Your Disk-Based BlackBox makes a call to int 0F3H to obtain the
- stored pointer to the passed data.
-
- 5. Whatever action required is performed.
-
- 6. Return whatever status values using the pointers passed.
-
- 6. Your Disk-Based BlackBox exits normally, after having deallocated any
- allocated memory and closing any file handles.
-
- 7. The calling program continues execution.
-
-
- The call for obtaining the pointer to the passed data is:
-
- parameter_block = GET_BLACKBOX_PARAM_PTR ();
-
- This returns a far pointer to a parameter block, whose structure is
- determined by the parameters requested by the BlackBox.
-
- The first field in the parameter block structure is always an integer
- value, LANGUAGE_TYPE, which indicates the language of the calling
- procedure. Then those parameters in the header file follow in reverse
- order.
-
- Example: A Disk-Based BlackBox which asks for
-
- 1. A File Name (pointer to array of characters)
- 2. An Integer Value (passed by value)
- 3. An Integer Variable (passed by reference)
- 4. A CheckBox Variable (passed by reference)
-
- The Structure for the parameter block would be:
-
- struct BlackBox_Parameter_Block {
-
- unsigned language_type;
- char *CheckBox_Variable; /* CheckBoxes are of type char */
- int *Integer_Variable;
- int Integer_Value;
- char *File_Name;
-
- };
-
- In order to access the GET_BLACKBOX_PARAMETER_PTR call, you must link in
- the object module BBXPTR_C.OBJ on this disk.
-