home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -in_the_mag- / graphics / metaview / arexx-examples / finalwriter_import.rexx < prev    next >
OS/2 REXX Batch file  |  1998-05-13  |  2KB  |  102 lines

  1. /* Graphics Imports with MetaView for FinalWriter*/
  2.  
  3. METAVIEW = 'MetaView:MetaView'    /* Please complete the path */
  4.  
  5. OPTIONS RESULTS
  6. SIGNAL ON FAILURE
  7. SIGNAL ON SYNTAX
  8.  
  9. /*
  10. ** Looking for our start process
  11. */
  12.  
  13. APLPORT = ADDRESS()
  14.  
  15. if (LEFT(APLPORT, 6) ~= "FINALW") then do /* not started from Application */
  16.     say "Please start me from Application!"
  17.     EXIT
  18. end
  19.  
  20. /*
  21. ** Create a new Metaview process:
  22. ** first look for the allready running processes
  23. ** then the new Port will be the next one
  24. */
  25.  
  26. do NUMBER = 0 to 20
  27.     if (SHOW(PORTS,"METAVIEW." || NUMBER) = 0) then
  28.     leave
  29. end
  30.  
  31. /*
  32. ** Searching for MetaView: 1. our path above,
  33. **    2. path in env:MetaView.path
  34. ** or 3. you must have a assign "MetaView:"
  35. */
  36.  
  37. if (EXISTS(METAVIEW)=0) then do
  38.     if OPEN("MVVAR","env:MetaView.path","Read") then do
  39.         METAVIEW = READLN("MVVAR")
  40.     end
  41.     if (EXISTS(METAVIEW)=0) then do
  42.         METAVIEW = "MetaView:MetaView"
  43.     end
  44. end
  45.  
  46. /*
  47. ** Enable warnings for WaitForPort
  48. */
  49.  
  50. OPTIONS FAILAT 5
  51. ADDRESS COMMAND
  52.     "run " || METAVIEW || " NODISPLAY"
  53.     MVPORT = "METAVIEW." || NUMBER
  54.     "WaitForPort " || MVPORT
  55.  
  56. /*
  57. ** Ignore the other errors
  58. */
  59.  
  60. OPTIONS FAILAT 21
  61.  
  62. /*
  63. ** Do all needed thinks with MetaView (LOAD,SAVE,QUIT...)
  64. */
  65.  
  66. ADDRESS VALUE MVPORT
  67.     REQUESTFILE ""
  68.     FILENAME = result
  69.     LOAD '"'FILENAME'"'
  70.     SAVE '"T:Test.eps"' AS EPS
  71.     QUIT
  72.  
  73. /*
  74. **  Import the temporary file in application
  75. */
  76.  
  77. ADDRESS VALUE APLPORT
  78.     InsertImage 'T:Test.eps'
  79.     ObjectIMG = Result
  80.     IF (ObjectIMG = 0) then exit_msg('"Error loading graphicfile"')
  81.     SetObjectTitle ObjectIMG '"'FILENAME'"'          /* Remember objectfilename   */
  82.     SetObjectParams ObjectIMG Linked No Display Full /* Save object with document */
  83.     Redraw
  84. EXIT
  85.  
  86. FAILURE:
  87.     ADDRESS COMMAND
  88.     REQUESTCHOICE "Error" """Can't find" METAVIEW "!""" "OK"
  89.     EXIT
  90.  
  91. SYNTAX:
  92.     say "Error on line" SIGL ":" ERRORTEXT(RC) "!"
  93.     EXIT
  94.  
  95. exit_msg: procedure
  96. DO
  97.     parse arg message
  98.     if message = '' then exit
  99.     ShowMessage 1 0 message '"" "" "OK" "" ""'
  100.     exit
  101. END
  102.