home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / WordProcessors / slt-pgs3.lzx / PageStream3 / Scripts / SendtoBME.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-10-20  |  4.4 KB  |  166 lines

  1. /* $VER: SendtoBME.rexx 2.0 (19.07.96)
  2.    Copyright 1996 SoftLogik Publishing Corporation
  3.    May not be distributed without SoftLogik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. TRACE OFF
  7.  
  8. /* Make sure rexx support is opened */
  9. IF ~SHOW('L','rexxsupport.library') THEN
  10.    CALL ADDLIB('rexxsupport.library',0,-30)
  11.  
  12. ADDRESS 'PAGESTREAM'
  13.  
  14. /* Check and see if one picture is selected */
  15. getobject type objtype
  16. if objtype~=12 then do
  17.     ADDRESS 'PAGESTREAM'
  18.     allocarexxrequester '"Send to Editor Error!"' 368 59
  19.     reqhandle=result
  20.     addarexxgadget reqhandle EXIT 286 42 70 label "_Exit"
  21.         Exithandle=result
  22.     addarexxgadget reqhandle TEXT 8 10 352 border none string "'One picture must be selected to edit in BME.'"
  23.     addarexxgadget reqhandle TEXT 8 20 352 border none string "'Select only one picture and try again.'"
  24.     doarexxrequester reqhandle
  25.     freearexxrequester reqhandle
  26.     EXIT
  27. end
  28.  
  29. /* Stop the user from messing things up while away */
  30. 'lockinterface true'
  31.  
  32. /* Find out if it's internal or external */
  33. 'getpicture fileinfo fstem'
  34.  
  35. /* Append PageStream3: if not a full path */
  36. if pos(':',fstem.file)=0 then fstem.file='PageStream3:'||fstem.file
  37.  
  38. /* If imported from ram file, fix the space problem with ram disk */
  39. if left(fstem.file,9)='Ram Disk:' then fstem.file='Ram:'||right(fstem.file,length(fstem.file)-9)
  40. filepath=fstem.file
  41. if pos('/',filepath)~=0 then filename=right(filepath,length(filepath)-lastpos('/',filepath))
  42. else filename=right(filepath,length(filepath)-lastpos(':',filepath))
  43.  
  44. /* If untitled, then give it a name */
  45. if fstem.file='PageStream3:' then filename='UntitledPicture'
  46.  
  47. /* Export the picture to a temp file if internal */
  48. if fstem.mode=INTERNAL then do
  49.     filepath='t:'filename
  50.     'exportgraphic file 'filepath' filter iffilbm status force'
  51. end
  52.  
  53. /* Get the start date and time info */
  54. sTemp = statef(filepath)
  55. Parse VAR sTemp dum dum dum dum iSDays iSMins iSTicks .
  56.  
  57. 'refresh wait'
  58.  
  59. /* Set the default BME path */
  60. bmepath='PageStream3:BME'
  61. preffile='PageStream3:SendtoBME.prefs'
  62.  
  63. /* If BME doesn't exist in the default path, check SendtoBME.prefs */
  64. if ~exists(bmepath) then do
  65.     if open(.ifile, preffile, 'R') then do
  66.         bmepath=readln(.ifile)
  67.         call close(.ifile)
  68.         askuser='no'
  69.         end
  70.     else do
  71.         askuser='yes'
  72.     end
  73.     /* If BME doesn't exist in the set pref path, ask the user where it is */
  74.     if ~exists(bmepath) | askuser='yes' then do
  75.         getfile TITLE "'Please locate BME'" load path "'PageStream3:'" file BME posbutton 'Ok' negbutton 'Cancel'
  76.         if RC=10 then signal cancel
  77.         bmepath=result
  78.         if open(.ifile, preffile, 'W') then do
  79.             call writeln(.ifile, bmepath)
  80.             call close(.ifile)
  81.         end
  82.     end
  83. end
  84.  
  85.  
  86. /* Run BME */
  87. ADDRESS COMMAND
  88. 'run >nil:' bmepath
  89.  
  90. /* Wait until the ARexx port shows up */
  91. do 20
  92.     if ~show(P, 'BME') then call delay(50)
  93. end
  94.  
  95. /* If the ARexx port didn't show up, alert the user and exit */
  96. if ~show(P, 'BME') then do
  97.     ADDRESS 'PAGESTREAM'
  98.     allocarexxrequester '"Send to Editor Error!"' 368 59
  99.     reqhandle=result
  100.     addarexxgadget reqhandle EXIT 286 42 70 label "_Exit"
  101.         Exithandle=result
  102.     addarexxgadget reqhandle TEXT 8 10 352 border none string "'BME could not be started.'"
  103.     doarexxrequester reqhandle
  104.     freearexxrequester reqhandle
  105.     'refresh continue'
  106.     'lockinterface false'
  107.     EXIT
  108. end
  109.  
  110. ADDRESS 'BME'
  111. 'screentofront'
  112. 'open 'filepath
  113.  
  114. /* Wait for the user to finish in BME */
  115. do forever
  116.     if show(P, 'BME') then do
  117.         'getpicture 'filepath
  118.         if rc=0 then call delay(50)
  119.         else signal update
  120.     end
  121.     else signal update
  122. end
  123.  
  124.  
  125. /* Update PageStream and exit */
  126. UPDATE:
  127.     ADDRESS 'PAGESTREAM'
  128.     'screentofront'
  129.     'revealwindow current'
  130.  
  131.     /* If it's external, we don't have to do anything */
  132.     if fstem.mode=EXTERNAL then signal cancel
  133.  
  134.     /* Get the end date and time info */
  135.     sTemp = statef(filepath)
  136.     Parse VAR sTemp dum dum dum dum iEDays iEMins iETicks .
  137.  
  138.     /* If the picture hasn't changed, don't update pgs */
  139.     if iSDays=iEDays & iSMins=iEMins & iSTicks=iETicks then signal cancel
  140.  
  141.     'editpicture external file 'filepath
  142.     'editpicture internal'
  143. signal cancel
  144.  
  145.  
  146. CANCEL:
  147. ADDRESS 'PAGESTREAM'
  148. 'refresh continue'
  149. 'lockinterface false'
  150. ADDRESS COMMAND
  151. /*'delete t:'filename' >NIL:'*/
  152. 'delete t:'filename
  153. EXIT
  154.  
  155.  
  156. DOALERT:
  157. parse arg astring
  158. /* Display an alert requester */
  159.         allocarexxrequester '"Script Alert"' 334 55
  160.             hAlertReq=result
  161.         addarexxgadget hAlertReq TEXT 8 12 268 border none string '"'astring'"'
  162.         addarexxgadget hAlertReq EXIT 252 38 70 label "_Exit"
  163.         doarexxrequester hAlertReq
  164.         freearexxrequester hAlertReq
  165. RETURN
  166.