ImageGear for C and C++ on Windows v19.9 - Updated
Check the Feeder and Increment Filenames
User Guide > How to Work with... > Common Operations > Scanning > ISIS Scanning > More ISIS Characteristics > Check the Feeder and Increment Filenames

The following example uses IG_ISIS_drv_is_loaded to continue scanning as long as there are pages in the feeder. For each page scanned, a TIFF file is created called FILEnnnn.TIF, where nnnn is a number that increments with each page scanned.

 
Copy Code
AT_ERRCOUNT ScanBatch(HISISDRV hScan)
{
    AT_ERRCOUNT errorCount = IGE_SUCCESS;
    HISISDRV hFileWriter = 0;
    LONG feederFlags = 0;
    AT_LMODE feederStatus = 0;
    int page = 0;
    char lpcFileName[MAX_PATH+1];
    BYTE buffer[8192];

    // Load and initialize the file writing driver.
    errorCount = IG_ISIS_drv_load_init_pipe(0, "PIXFPACK", &hFileWriter, 0);
    if (errorCount != IGE_SUCCESS)
    {
         return errorCount;
    }

    // Link already-loaded scanner driver with file writing driver.
    IG_ISIS_drv_link(hScan, hFileWriter);

    // Set the file type and open attributes.
    IG_ISIS_tag_set_long(hFileWriter, IG_ISIS_TAG_FILETYPE, 0, IG_ISIS_FILETYPE_TIFF);
    IG_ISIS_tag_set_long(hFileWriter, IG_ISIS_TAG_OPENATTRIBUTE, 0,
            IG_ISIS_OPENATTRIBUTE_CREATE | IG_ISIS_FILE_BOTH);

    // Check whether there is a page loaded.
    IG_ISIS_tag_get_long(hScan, IG_ISIS_TAG_FEEDER, 0, &feederFlags);
    if (feederFlags & IG_ISIS_FEEDER_TELLFEED)
    {
        IG_ISIS_drv_is_page_loaded(hScan, IG_ISIS_FEEDER_FEED, &feederStatus);
        if (feederStatus & IG_ISIS_DRV_STACKPAGE)
        {
            printf("There is a page ready in the feeder.\n");
        }
        else
        {
            printf("The feeder is empty.\n");
        }
    }
    else
    {
        printf("Cannot tell if page is loaded.\n");
    }

    errorCount = IG_ISIS_drv_is_page_loaded(hScan, IG_ISIS_FEEDER_FEED, &feederStatus);

    while ((feederStatus == IG_ISIS_DRV_STACKPAGE) && (errorCount == IGE_SUCCESS))
    {
        // While there is a page in the feeder, get ready to scan by incrementing
        // a numeric portion of the filename for each page scanned.
        sprintf(lpcFileName, "File%04d.tif", page++);
        IG_ISIS_tag_set_ascii(hScan, IG_ISIS_TAG_OUTPUTNAME, lpcFileName);

        // Run the zone.
        errorCount = IG_ISIS_run_zone(hScan, buffer, sizeof(buffer));
        if (errorCount == IGE_SUCCESS)
        {
            // Check for page in feeder again, and stay in the loop if present.
            errorCount = IG_ISIS_drv_is_page_loaded(hScan, IG_ISIS_FEEDER_FEED, &feederStatus);
        }
    }

    // Clean up drivers.
    IG_ISIS_drv_link(hScan, 0);
    IG_ISIS_drv_unload(hFileWriter);

    return errorCount;
}       

In the above example, the scanner driver was already loaded by some previous code in the application. This code fragment does not attempt to unload the scanner driver because it didn't load it. When using IG_ISIS_drv_is_loaded(), remember that the information about whether or not a page is loaded is in the function's third parameter (&feederStatus), not in the return value. A negative return value from IG_ISIS_drv_is_loaded() means there was an error completing the function.