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

  1. /* Graphik Import mittels MetaView */
  2.  
  3. METAVIEW = ':Aminet/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. ARTPORT = ADDRESS()
  14. say ARTPORT
  15. if (LEFT(ARTPORT, 10) ~= "ArtStudio") then do /* not started from ArtStudio */
  16.     say "Please start me from ArtStudio!"
  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 "Bilder:"
  68.     FILENAME = result
  69.     LOAD FILENAME
  70.     SAVE "t:test.ilbm" AS ILBM
  71.     QUIT
  72.  
  73. /*
  74. **  Import the temporary file in application
  75. */
  76.  
  77. ADDRESS COMMAND
  78.     "ECHO" VALUE FILENAME ">t:infotext"
  79.  
  80. ADDRESS VALUE ARTPORT
  81.     LOAD "t:test.ilbm"
  82.     SETINFOTEXT "t:infotext"
  83.  
  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.