home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / Dopus5 / DC-OP55B.LZX / Opus5 / storage / Modules / PrintAppIcon.dopus5 < prev   
Encoding:
Text File  |  1996-07-01  |  4.7 KB  |  177 lines

  1. /* PrintAppIcon for Directory Opus 5.5
  2.    by Leo 'Nudel' Davidson for Gods'Gift Utilities
  3.    email: leo.davidson@keble.oxford.ac.uk  www: http://users.ox.ac.uk/~kebl0364
  4.  
  5. $VER: PrintAppIcon.dopus5 1.4 (1.7.96)
  6.  
  7.    Adds an icon to your Opus screen which you can drop files on to have
  8.    them printed. Printing is done by the internal "Print" command of DOpus.
  9.    If you want printing to be done in some other way, email me.
  10.  
  11.    If you drop a directory on the icon instead of a file, the directory
  12.    listing will be printed. This only works from DOpus listers -- drops from
  13.    any other program always get sent to "Print".  Note: Directory printing
  14.    is done by redirecting the output of the "list" command to the PRT:
  15.    device.
  16.  
  17.    Supports close and snapshot (writes snapshot information to the filecomment
  18.    of the icon -- don't snapshot if you want to keep the comment).
  19.  
  20.    Just put this script in DOpus5:Modules to enable it.
  21.  
  22.    Specify your icon below, without ".info" at the end.
  23.  
  24.    If you want the AppIcon to be there from startup set "initstart" below
  25.    to "y". Whether you do or not a command called "OpenPrintAI" will be added
  26.    to Opus which can be used to open a new AppIcon at any time. "OpenPrintAI"
  27.    takes an optional argument which specifies the name of a different icon
  28.    to use, without ".info" at the end.
  29.  
  30. //---------------------------------------------------------------------------*/
  31. iconname  = "DOpus5:Icons/PrintFilesAppIcon"
  32. initstart = y
  33. /*---------------------------------------------------------------------------*/
  34. options results
  35. options failat 11
  36. parse arg DOpusPort function source dest arguments
  37.  
  38. If (function~='init' & function~="OpenPrintAI") then exit
  39.  
  40. Address value DOpusPort
  41.  
  42. If ~Show('L','rexxsupport.library') then
  43.     call addlib('rexxsupport.library',0,-30,0)
  44.  
  45.  
  46. /* add restart command (for restart after closing the icon) - quit after that if initstart off */
  47. if function = 'init' then do
  48.     dopus command "OpenPrintAI" program "PrintAppIcon" desc "'(Re)open Print AppIcon'" template "ICON/K"
  49.     if left(Upper(initstart),1) ~= "Y" then exit
  50.     end
  51.  
  52.  
  53. If (function="OpenPrintAI" & arguments~="") then do
  54.     iconname = arguments
  55.     end
  56.  
  57. /* Get unique name and open a port. */
  58. Call Forbid()
  59.     i = 0
  60.     myportname = "DOPrintIcon."i
  61.     Do i=0 While Show("P",myportname)
  62.         myportname = "DOPrintIcon."i
  63.         End
  64.     If ~openport(myportname) then do
  65.         Call Permit()
  66.         dopus request '"PrintAppIcon: Could not open message port" OK'
  67.         Exit
  68.         End
  69. Call Permit()
  70.  
  71.  
  72. /* See if there is any snapshot info in the icon's filecomment */
  73. address command "list >PIPE:"myportname" "iconname".info LFORMAT %c"
  74. if open(comfile,"PIPE:"myportname,"R") then do
  75.     comment = readln(comfile)
  76.     close(comfile)
  77.     end
  78.  
  79. If Word(comment,1) = "NudelSnap:" Then do
  80.     comment =   word(comment,2)
  81.     comcom  =  index(comment,",")
  82.     comx    =   left(comment,comcom-1)
  83.     comy    =  right(comment,length(comment) - comcom)
  84.     comment = "POS" comx comy
  85.     End
  86. Else
  87.     comment = ""
  88.  
  89.  
  90. /* add an icon */
  91. dopus addappicon myportname "''" 1 comment info snap close icon iconname quotes
  92. icon=result
  93.  
  94.  
  95.  
  96. /* loop around */
  97.  
  98. flag = 0
  99. do while flag = 0
  100.     call waitpkt(myportname)
  101.  
  102.     packet=getpkt(myportname)
  103.     arg0=getarg(packet,0)
  104.     arg1=getarg(packet,1)
  105.     arg2=getarg(packet,2)
  106.     arg3=getarg(packet,3)
  107.     arg4=getarg(packet,4)
  108.  
  109.     call reply(packet,0)
  110.  
  111.     if arg0 = 'dropfrom' then do
  112.         allents = arg2
  113.         If arg3 = 0 then call getall_alien
  114.         Else do
  115.             lister query arg3 path
  116.             printpath = strip(result,"B",'"')
  117.             call getall
  118.             end
  119.         do i = 1 to entries
  120.             if type.i < 0 then
  121.                 command wait print name name.i
  122.             if type.i > 0 then do
  123.                 address command "run >NIL: list >PRT:" name.i "DATES"
  124.                 end
  125.             end
  126.         end
  127.  
  128.     if arg0 = 'close' then flag = 1
  129.     if arg0 = 'removed' then flag = 2
  130.     if (arg0 = 'info' | arg0 = 'doubleclick') then do
  131.         dopus setappicon icon busy on
  132.         dopus request '"PrintAppIcon for Directory Opus'|| '0a'x ||"by Leo 'Nudel' Davidson"||'" OK|Close'
  133.         If RC = 0 then flag = 1
  134.         dopus setappicon icon busy off
  135.         end
  136.     if arg0 = 'snapshot' then
  137.         address command 'filenote 'iconname'.info "NudelSnap:' arg2'"'
  138.     if arg0 = 'unsnapshot' then
  139.         address command 'filenote 'iconname'.info'
  140.     end
  141.  
  142.  
  143. /* remove icon */
  144. if flag~=2 then dopus remappicon icon
  145. Call closeport(myportname)
  146. Exit
  147.  
  148.  
  149. /* GetAll functions adapted from ArcDir.dopus5 written by Edmund Vermeulen */
  150.  
  151. getall:
  152. entries=0
  153. do while allents~=''
  154.     entries=entries+1
  155.     parse var allents '"' name.entries '"' allents
  156.     if name.entries='' then
  157.         type.entries=0
  158.     else do
  159.         lister query arg3 entry '"'name.entries'"' stem fileinfo.
  160.         type.entries=fileinfo.type
  161.         name.entries = printpath || name.entries
  162.         end
  163.     end
  164. return
  165.  
  166. getall_alien:
  167. entries=0
  168. do while allents~=''
  169.     entries=entries+1
  170.     parse var allents '"' name.entries '"' allents
  171.     if name.entries='' then
  172.         type.entries=0
  173.     else
  174.         type.entries= -1
  175.     end
  176. return
  177.