Macro Scheduler Sample: Acquire and save to BMP file

Top  Previous  Next

The following Macro Scheduler script is all that is required to do the following:

 

Check if TWAIN is installed.
Initialize the DTWAIN Dynamic Link Library.
Select a Source
Acquire a page using the Native transfer mode
Save page to a BMP file called "TEST.BMP"
Shut down any open TWAIN Source's and DTWAIN itself

 


 

LibLoad> DTWAIN32.DLL,hLib

If> hLib <> 0

    // check if TWAIN is available

    LibFunc> hLib,DTWAIN_IsTwainAvailable,avail

 

    If> avail<> 0

        // Initialize the library

        LibFunc> hLib,DTWAIN_SysInitialize,ret

 

       // Select the source

        LibFunc> hLib,DTWAIN_SelectSource,TwainSource

 

        If> TwainSource <> 0

              // acquire to a BMP file

              LibFunc> hLib,DTWAIN_AcquireFile,bOk,TwainSource,TEST.BMP,100,17,1000,1,1,1,0

        ENDIF

 

        // Close Source and shutdown DTWAIN

        LibFunc> hLib,DTWAIN_SysDestroy,ret2

    ENDIF

 

    // Unload the DLL

    LibFree> hLib

Endif

 


In the example above, note that the LibLoad and LibFree commands are used to load and unload the DTWAIN librrary.  The LibFunc command calls the desired DTWAIN function with the appropriate parameters.  Please consult your Macro Scheduler documentation for more information on LibLoad, LibFree, and LibFunc commands.

 

In addition, the call to DTWAIN_AcquireFile has numeric arguments (100, 17, 1000, etc.).  These are the DTWAIN constant values that correspond to DTWAIN_BMP, DTWAIN_USELONGNAME, etc.   For Macro Scheduler, it is required that the literal constants be used when calling DTWAIN functions, instead of the symbolic names.   To get the constant's value, please see the DTWAIN32.scp file for a list of the symbolic names and their constant value.

 

Last, the section on Floating Point Issues is recommended for Macro Scheduler users who want to call DTWAIN functions that require floating point parameters.