/* Script to scan into ImageEngineer via ScanQuix.
   Scanner software running on Workbench. */

/* © 1997 by Volkmar Funke */

/* $VER: ScanImage.rexx 1.0 (27.01.97) */

/* [english translation (parts) by Andreas R. Kleinert] */

address 'IMAGEENGINEER'
options results
options failat 25     /* ScanToDisk returns 0 or 20 */

TRACE OFF

tempfile='T:IE_ScannnedImage'

ok=1
call SCAN()           /* Scans the image into a temporary file */
call IMPORTGRAPHIC()  /* Loads Image into ImageEngineer */
call DELETEFILE()     /* Removes temporary image file */

EXIT



SCAN:
/* Scans the image into a temporary file using the program "ScanToDisk". */
  if not 1=open('path','ENV:ScanQuix/Path','READ') then do
    ok=0
    return
  end

  pragma('DIRECTORY',READLN('path'))
  address command 'ScanQuix3/ScanToDisk FILE="'tempfile'" TRUECOLOR NOICONS  NOGUI PUBSCREEN=Workbench'
  if RC>=5 then do
  ok=0
  return
  end

return



IMPORTGRAPHIC:
/* Loads the image into ImageEngineer */
  if ok=0 then
    return

  IE_TO_FRONT

  'Open' tempfile

if rc~=0 then do
     ADDRESS 'IMAGEENGINEER'
    REQUEST '"Scanner error !!"' ' "OK" '
    EXIT
end



DELETEFILE:
/* removes temporary file */
  address command 'delete >NIL: 'tempfile

return
