SNIPIT Code Viewer Documentation -------------------------------- Contents -------- I. List of shipped files II. Prerequisites III. Using SNIPIT Code Viewer I. List of shipped files ------------------------ aliases.c Displays the aliases available in the current configuration file. batmove.c Shows how to use the DbiBatchMove function blobio.c Shows how to use BLOBs blobsmpl.c A simple example of using BLOBs block.c How to use blockmove to speed up table access bookmark.c Saving the current record position using bookmarks callback.c Registering a function to be automatically called by IDAPI. config.c Dsplaying the information in the configuration file cr8dbtbl.c How to create a dBASE table cr8pxtbl.c How to create a Paradox table cr8txtbl.c How to create a Text table dbio.c How to manipulate databases drvcaps.c Determining the capabilities of the available drivers errval.c Getting the error value and displaying error information fieldmap.c Changing the fields which are used in a table filter.c Limiting the records accessable from a table using filters format.c Getting the date and time format from the configuration file idxdbase.c Using dBASE indexes idxexpr.c Using dBASE expression indexes idxpdox.c Using Paradox indexes initeng.c How to initialize IDAPI inmemtbl.c How to create an in-memory table lnkcrsr.c How to limit the records of one table depending on the current record in another table lsql.c A simple SQL example on a local table lsqljoin.c An SQL join of a dBASE and a Paradox table lsqllive.c Showing the use of a live answer table navigate.c How to use navigation with IDAPI optparam.c Using optional paramaters when creating a table password.c Using Passwords with Paradox tables prdxsort.c Sorting Paradox tables qbe.c A simple Query by Example (QBE) example qbe2.c A join of a dBASE and a Paradox table using QBE range.c Limiting the records returned from a table to within an upper and lower range rdolock.c Creating a read-only directory (Paradox only) reclock.c Locking Records recupdat.c Inserting and modifying records refinteg.c Creating Referential Integrity Links search.c How to search IDAPI tables secdesc.c Using Auxilliary Passords, also called security descriptors. (Paradox Only) session.c Using multiple sessions with IDAPI softdel.c How to set properties and use soft delete (dBASE only) sqlbind.c Parameter binding in SQL statements sysinfo.c Getting information about the IDAPI system tblinfo.c Getting information about a table tbllist.c Getting a list of the available tables tbllock.c Using table locking tblopen.c How to open a table tbrstrct.c Restructuring a table test.c Basic framework to use for testing or creating new examples textexp.c Exporting data from a Paradox table to a Text table textimp.c Importing data from a Text table to a dBASE table transact.c Using transactions and SQL on remote tables upsize.c Copying local tables to a server. valcheck.c Shows how to use validity checks (Paradox only) input.c Used by SNIPIT for keeping track of the examples snipdata.c Contains the global data used by SNIPIT snipmain.c The main portion of the SNIPIT Code Viewer sniptool.c Helper functions used by the examples snipit.h Contains prototypes for functions used by the SNIPIT Code Viewer id_defs.h File contains #defines used in the SNIPIT Code Viewer makefile Makefile for Borland C++ v4.0 and later makemsc.mak Makefile for Microsoft C\C++ v1.5 snipit.ide Project file for BC 4.0 snipit.def Module Definition file snipit.rc Resource file II. Prerequisites ----------------- The following software must be installed to run SNIPIT Code Viewer: -IDAPI Software Development Kit (SDK) -Microsoft Windows 3.1 or higher The following software must be installed to run SNIPIT Code Viewer from a debugger: -Borland C++ Version 4.02 or higher, or Microsoft C/C++ Version 1.5 -An online debugger compatible with the installed C/C++ compiler (optional) Note: SNIPIT Code Viewer is shipped pre-compiled with Borland C++ Version 4.02. If you are using a different compiler, you can recompile SNIPIT Code Viewer so that you can run it successfully with your compiler's debugger. III. Using SNIPIT Code Viewer ----------------------------- Overview -------- SNIPIT Code Viewer is part of the IDAPI SDK; it is an online utility for viewing and running pre-compiled and linked C code samples that demonstrate IDAPI function calls. You can select a code sample from a list, display it on screen, and cut and paste selections into your own source code. You can run the code sample, and watch as its output messages are displayed on screen. You can also run SNIPIT Code Viewer with an online debugger, stepping through each line of code as it executes. Starting SNIPIT Code Viewer --------------------------- Start the SNIPIT Code Viewer by double-clicking the SNIPIT Code Viewer icon in the IDAPI SDK program group. The SNIPIT Code Viewer window is displayed full screen. You can adjust the window size, or reduce it to an icon. Finding the Appropriate Code Sample ----------------------------------- 1. Find the Code Sample by scrolling through the Sample Code list box. Each code sample is named for the type of IDAPI functionality it demonstrates. For example, 'Table: Create Paradox' shows how to create and delete a simple Paradox table. 2. Click once to select the code sample. When a code sample is selected, the Description list box describes briefly what it does, for example: Create a Paradox table, insert 10 records, then delete the table. The name of the file where the code sample resides is displayed below the Description list box, for example: cr8pxtbl.c All SNIPIT sample code is installed in the SNIPIT directory. Viewing Sample Code ------------------- 1. Double-click the selected code sample or choose the View button (or choose View from the File pull-down menu). The selected code sample is displayed in the Sample Code Viewer window. 2. Use the scroll bar in the Sample Code Viewer window to scroll through the source code. Each code sample is stand-alone, so there is a fair amount of redundant code used to perform routine operations such as initializing the engine and closing the database. For simplicity's sake, SNIPIT Code Viewer does not display all of this redundant code. You see only the names of the internal support functions that perform these routine operations: - ChkRslt Outputs the supplied string if the actual result does not equal the expected result. - CloseDbAndExit Closes the specified database and exits IDAPI. - CreateAndFillTable Creates a table and fills it with random data. This function uses the internal support function FillTable () to generate the data. Examples for all IDAPI field types are included in this function. - DisplayInMemoryTable Dumps a specified number of records to the screen from the specified in-memory table (i.e., virtual table). - DisplayTable Dumps a specified number of records to the screen from the specified table. - FillTable Fills the specified table with random data. This routine can generate data for any IDAPI field type. - InitAndConnect Initializes IDAPI and connects to a standard database (i.e., one used by dBASE and Paradox). - InitAndConnect2 Initializes IDAPI and connects to an SQL database. This function displays available databases and allows the user to select which database is used. - MakeFullPath Returns the fully qualified path to the IDAPI working directory. - Screen Outputs a supplied string to the edit control. - WinMsg Pops up a Windows message box. This function is similar to, but easier to use than the Windows function MessageBox(). Cutting and Pasting Sample Code ------------------------------- 1. Select the code you want to copy from the Sample Code Viewer window, and choose the Copy button to copy it to the clipboard (or choose Copy text from the Edit Menu). Note that all text in the output edit control will be copied if no text is selected. 2. Paste the code from the clipboard into your program's source code. Running Sample Code ------------------- 1. Choose the Run button to execute the selected code sample . Note that the Sample Code Viewer window has now become the Sample Code Output window; it displays the code sample's output as the code executes. If you are running SNIPIT Code Viewer without a debugger, these output messages are all you see. 2. To step through the each line of source code as the application executes, run SNIPIT Code Viewer from an online debugger, as follows: a. Start the online debugger, and run snipit.exe. There is no need to set a breakpoint; a breakpoint has been pre-set at the beginning of each code sample. Note: The preferred application for running the samples is under the Borland C++ Version 4.0 Integrated Development Environment (IDE). The suplied IDAPI.TOK file can be used in the IDE to do syntax highlighting of the IDAPI functions and types. This makes it much easier to see the IDAPI-specific parts of the code. Note: If you cannot run SNIPIT Code Viewer with your debugger, you may need to recompile SNIPIT Code Viewer. (It is shipped pre-compiled with Borland C++ Version 4.0). b. When the SNIPIT Code Viewer window is displayed, select the code sample you wish to run, and choose the Run button. c. The online debugger stops execution at the breakpoint at the beginning of the selected code sample. You can now step through each line of code as it executes, using the appropriate options of your debugger.