home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / External_ieb / Process_AutoFX.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  5.4 KB  |  188 lines

  1. /*
  2. ** $VER: Process_AutoFX.ieb 1.05, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 25/1 1997 Stockholm/Sweden
  6. **
  7. ** Accesses ImageFX's AutoFX arexx scripts (.ifx) through any of IE batch
  8. ** system's executers. Requires the commercial software package
  9. ** ImageFX 2.0 or later. ImageFX is Copyright © by Nova Design.
  10. **
  11. */
  12.  
  13. options results
  14. signal on error
  15.  
  16. parse arg input command
  17. input = upper(strip(input))
  18. address 'IMAGEENGINEER'
  19.  
  20. select  /* Required batch script commands */
  21.   when input = 'INFO' then    return get_info()
  22.   when input = 'CONFIG' then  return get_config(command)
  23.   when input = 'PROCESS' then return process_image(command)
  24.   otherwise do
  25.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  26.     return '<ERROR>'
  27.   end
  28. end
  29.  
  30. exit 0
  31.  
  32. /* Required "Get_info" procedure  ------------------------------------ */
  33. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  34.  
  35. get_info:
  36.   if ~show('P','IMAGEFX.1') then do  /* check for arexx port */
  37.     if ~exists('ImageFX:ImageFX') then do  /* check for executable */
  38.       'REQUEST' '"Could not locate ImageFX !"' '" OK "'
  39.       return '<ERROR>'
  40.     end
  41.     else do
  42.       address 'COMMAND' 'run >NIL: ImageFX:ImageFX'  /* run ImageFX */
  43.       address 'COMMAND' 'waitforport IMAGEFX.1'      /* wait for port */
  44.  
  45.       if RC~=0 then do
  46.         'REQUEST' '"Could not locate ImageFXs arexx port!'d2c(10)||,
  47.           'Attempt to run ImageFX failed!"' '" OK "'
  48.         return '<ERROR>'
  49.       end
  50.     end
  51.   end
  52.  
  53.   back = 'OK F'
  54. return back
  55.  
  56. /* Required "Get_config" procedure  ---------------------------------- */
  57.  
  58. get_config:
  59.   parse arg '"'command'"'
  60.  
  61.   if command ~= '' then parse var command '#'ifx_file nil
  62.  
  63.   'IE_TO_FRONT'
  64.  
  65.   /* Unchanged config, only picked for first image */
  66.  
  67.   if command = '' then do
  68.     'GET_FILE' '"Select an ImageFX AutoFX script."' '" OK "' '"ImageFX:Rexx/AutoFX/"'
  69.     if (RC=5) then return '<ERROR>'
  70.     ifx_file = strip(result,B,'"')
  71.     if upper(right(ifx_file,4)) = '.PRE' then ifx_file = get_base(ifx_file)
  72.   end
  73.  
  74.   /* Run AutoFX ifx .pre script */
  75.  
  76.   if exists(ifx_file'.pre') then do
  77.     address 'IMAGEFX.1' 'ScreenToFront'
  78.     signal off error
  79.     address 'IMAGEFX.1' 'RX' ifx_file'.pre' '1'
  80.     signal on error
  81.     if RC~=0 then do
  82.       'IE_TO_FRONT'
  83.       return '<ERROR>'
  84.     end
  85.  
  86.     /* Scan AutoFX pre script for SETCLIPs */
  87.  
  88.     str_name = '' ; str_val = ''
  89.     if open('ifx',ifx_file'.pre','R') then do until eof('ifx')
  90.       ifx_line = readln('ifx')
  91.       if compress(upper(left(ifx_line,7))) = 'BASE=' then interpret ifx_line
  92.       ifx_offset = index(upper(ifx_line),'CALL SETCLIP(')
  93.       if ifx_offset ~= 0 then do
  94.         parse var ifx_line nil '('sub_name',' nil
  95.         ifx_offset = index(upper(sub_name),'ARG(1)')
  96.         if ifx_offset ~= 0 then do
  97.           sub_name = delstr(sub_name,ifx_offset,6)
  98.           sub_name = insert('1',sub_name,ifx_offset-1)
  99.         end
  100.         interpret 'sub_name = ' sub_name
  101.         str_name = str_name||strip(sub_name)'&'
  102.         sub_val = translate(strip(getclip(sub_name)),'º',' ')
  103.         if ~datatype(compress(sub_val,'-'),'N') then str_val = str_val '#'sub_val '#&'
  104.         else str_val = str_val sub_val '#&'
  105.       end
  106.     end
  107.     else return '<ERROR>'
  108.  
  109.     nil = close('ifx')
  110.  
  111.     'IE_TO_FRONT'
  112.  
  113.   end /* pre script scanning */
  114.   else do
  115.     'REQUEST' '"This AutoFX script does not have any settings."' '" OK "'
  116.     str_name = 'dummy_clip&'
  117.     str_val = '#Gummi-anka'
  118.   end
  119.  
  120.   back = '#'ifx_file '#'str_name str_val
  121. return back
  122.  
  123. /* Required "Process_image" procedure  ------------------------------- */
  124.  
  125. process_image:
  126.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'frame':'num_frames'"'
  127.   parse var options '#'ifx_file '#'str_name str_val
  128.  
  129.   do until str_name = ''
  130.     parse var str_name sub_name'&'str_name
  131.     if strip(sub_name) = '' then leave
  132.  
  133.     new_val = ''
  134.     do until sub_val = '&'
  135.       parse var str_val sub_val str_val
  136.       sub_val = compress(sub_val,'#')
  137.       if sub_val = '&' then leave
  138.       new_val = new_val sub_val
  139.       if strip(str_val) = '' then leave
  140.     end
  141.  
  142.     nil = setclip(sub_name,translate(strip(new_val),' ','º'))
  143.   end
  144.  
  145.   ifx_file = strip(ifx_file)
  146.   address 'IMAGEFX.1' LoadBuffer Force '"'src_image'"'
  147.  
  148.   if exists(ifx_file) then do
  149.     if frame = 1 then address 'IMAGEFX.1' 'ScreenToFront'
  150.     address 'IMAGEFX.1' 'RX' ifx_file frame '-' '-' '1' num_frames
  151.   end
  152.   else do
  153.     'REQUEST' '"Could not locate AutoFX script!'d2c(10)ifx_file'"' '" OK "'
  154.     return '<ERROR>'
  155.   end
  156.  
  157.   address 'IMAGEFX.1' SaveBufferAs ILBM '"'dst_image'"'
  158.  
  159.   back = 'OK'
  160. return back
  161.  
  162. /* Internal procedures  ---------------------------------------------- */
  163.  
  164. get_base:
  165.   parse arg get_base_in
  166.   if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
  167.   else get_base_back = get_base_in
  168. return get_base_back
  169.  
  170. /*******************************************************************/
  171. /* This is where control goes when an error code is returned by IE */
  172. /* It puts up a message saying what happened and on which line     */
  173. /*******************************************************************/
  174.  
  175. error:
  176. if RC=5 then do
  177.     IE_TO_FRONT
  178.     LAST_ERROR
  179.     'REQUEST "'||RESULT||'"'
  180. end
  181. else do
  182.     IE_TO_FRONT
  183.     LAST_ERROR
  184.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  185. end
  186.  
  187. return '<ERROR>'
  188.