Creates and opens a MIF/MID file for writing; initializes the export subsystem.
Syntax
intl pipExportInitMIF ( pipHandle h, pstr outputFileName,
pipExporter *exp_h );
Arguments
h
The handle returned by pipInit for the current instance of Spatial+. Input.
outputFileName
The path and filename of the output MIF and MID files to generate. Input.
*exp_h
The export handle returned by the function. This handle should be used by all other pipExport functions. Output.
Return Value
PIP_OK
PIP_ERROR
Prerequisites
pipInit
Alternates
pipExportInitBNA, pipExportInitShape, or pipExportInitTab
Notes
This function creates and opens both MIF and MID files. These files store exported standalone objects or exported objects from GSB (Spatial+ object) files.
For a complete description of the MIF/MID file format, see MapInfo® MIF/MID Format.
This function returns a pipExporter handle via a pointer. This handle should be used instead of pipHandle as input for the other pipExport_ functions (pipExportInitBNA , pipExportInitShape , and pipExportInitTab excepted).
Example
/* This code example demonstrates an export operation using the GSB file created in the import operation example.
Only minor changes would be necessary to use this sample to export ESRI's BNA, SHP, or TAB files */
#include <stdlib.h> #include <string.h> #include <stdio.h>
#include <pipapi.h>
int main( int argc, char **argv )
{
pipHandle h; pipExporter exp_h;
intl percent; intl line;
char name[32]; char errMsg[256]; char errDetail[256];
intl ret_val; intl completed = 1;
/* Initialize Spatial+ handle */
h = pipInit( 11111111, "c:\\lic\\SPATIAL.LIC" );
/* Get handle for export functions */
ret_val = pipExportInitMIF( h, "c:\\spatial\\trade.mif", &exp_h );
if(ret_val == PIP_ERROR)
{
pipErrorGet(h, errMsg, errDetail);
printf("An error has occurred: %s, %s\n", errMsg, errDetail); return 1;
}
/* Open GSB file for exporting */
ret_val = pipExportOpen( exp_h, "c:\\spatial\\trade.gsb", PIP_OPEN_NO_CACHE );
/* Read GSB file until no more objects are found */
do {
ret_val = pipExportWrite( exp_h, name, sizeof(name), &percent, &line ); if(ret_val == PIP_ERROR)
{
if (percent < 100)
{
pipErrorGet(h, errMsg, errDetail);
printf("An error has occurred: %s, %s\n", errMsg, errDetail );
/* Flag used to signal pipExportTerm to discard file */
completed = 0;
}
break;
}
printf("Object exported: %s, Percent: %d\r", name, percent);
} while( ret_val == PIP_OK );
/* Done exporting, close import file */
pipExportClose( exp_h );
/* Done exporting, terminate import subsystem */
pipExportTerm(exp_h, completed );
/* Finished with Spatial+ processing. Free handle */
pipTerm(h);
return 0;
}