home *** CD-ROM | disk | FTP | other *** search
- /* PrintAppIcon for Directory Opus 5.5
- by Leo 'Nudel' Davidson for Gods'Gift Utilities
- email: leo.davidson@keble.oxford.ac.uk www: http://users.ox.ac.uk/~kebl0364
-
- $VER: PrintAppIcon.dopus5 1.4 (1.7.96)
-
- Adds an icon to your Opus screen which you can drop files on to have
- them printed. Printing is done by the internal "Print" command of DOpus.
- If you want printing to be done in some other way, email me.
-
- If you drop a directory on the icon instead of a file, the directory
- listing will be printed. This only works from DOpus listers -- drops from
- any other program always get sent to "Print". Note: Directory printing
- is done by redirecting the output of the "list" command to the PRT:
- device.
-
- Supports close and snapshot (writes snapshot information to the filecomment
- of the icon -- don't snapshot if you want to keep the comment).
-
- Just put this script in DOpus5:Modules to enable it.
-
- Specify your icon below, without ".info" at the end.
-
- If you want the AppIcon to be there from startup set "initstart" below
- to "y". Whether you do or not a command called "OpenPrintAI" will be added
- to Opus which can be used to open a new AppIcon at any time. "OpenPrintAI"
- takes an optional argument which specifies the name of a different icon
- to use, without ".info" at the end.
-
- //---------------------------------------------------------------------------*/
- iconname = "DOpus5:Icons/PrintFilesAppIcon"
- initstart = y
- /*---------------------------------------------------------------------------*/
- options results
- options failat 11
- parse arg DOpusPort function source dest arguments
-
- If (function~='init' & function~="OpenPrintAI") then exit
-
- Address value DOpusPort
-
- If ~Show('L','rexxsupport.library') then
- call addlib('rexxsupport.library',0,-30,0)
-
-
- /* add restart command (for restart after closing the icon) - quit after that if initstart off */
- if function = 'init' then do
- dopus command "OpenPrintAI" program "PrintAppIcon" desc "'(Re)open Print AppIcon'" template "ICON/K"
- if left(Upper(initstart),1) ~= "Y" then exit
- end
-
-
- If (function="OpenPrintAI" & arguments~="") then do
- iconname = arguments
- end
-
- /* Get unique name and open a port. */
- Call Forbid()
- i = 0
- myportname = "DOPrintIcon."i
- Do i=0 While Show("P",myportname)
- myportname = "DOPrintIcon."i
- End
- If ~openport(myportname) then do
- Call Permit()
- dopus request '"PrintAppIcon: Could not open message port" OK'
- Exit
- End
- Call Permit()
-
-
- /* See if there is any snapshot info in the icon's filecomment */
- address command "list >PIPE:"myportname" "iconname".info LFORMAT %c"
- if open(comfile,"PIPE:"myportname,"R") then do
- comment = readln(comfile)
- close(comfile)
- end
-
- If Word(comment,1) = "NudelSnap:" Then do
- comment = word(comment,2)
- comcom = index(comment,",")
- comx = left(comment,comcom-1)
- comy = right(comment,length(comment) - comcom)
- comment = "POS" comx comy
- End
- Else
- comment = ""
-
-
- /* add an icon */
- dopus addappicon myportname "''" 1 comment info snap close icon iconname quotes
- icon=result
-
-
-
- /* loop around */
-
- flag = 0
- do while flag = 0
- call waitpkt(myportname)
-
- packet=getpkt(myportname)
- arg0=getarg(packet,0)
- arg1=getarg(packet,1)
- arg2=getarg(packet,2)
- arg3=getarg(packet,3)
- arg4=getarg(packet,4)
-
- call reply(packet,0)
-
- if arg0 = 'dropfrom' then do
- allents = arg2
- If arg3 = 0 then call getall_alien
- Else do
- lister query arg3 path
- printpath = strip(result,"B",'"')
- call getall
- end
- do i = 1 to entries
- if type.i < 0 then
- command wait print name name.i
- if type.i > 0 then do
- address command "run >NIL: list >PRT:" name.i "DATES"
- end
- end
- end
-
- if arg0 = 'close' then flag = 1
- if arg0 = 'removed' then flag = 2
- if (arg0 = 'info' | arg0 = 'doubleclick') then do
- dopus setappicon icon busy on
- dopus request '"PrintAppIcon for Directory Opus'|| '0a'x ||"by Leo 'Nudel' Davidson"||'" OK|Close'
- If RC = 0 then flag = 1
- dopus setappicon icon busy off
- end
- if arg0 = 'snapshot' then
- address command 'filenote 'iconname'.info "NudelSnap:' arg2'"'
- if arg0 = 'unsnapshot' then
- address command 'filenote 'iconname'.info'
- end
-
-
- /* remove icon */
- if flag~=2 then dopus remappicon icon
- Call closeport(myportname)
- Exit
-
-
- /* GetAll functions adapted from ArcDir.dopus5 written by Edmund Vermeulen */
-
- getall:
- entries=0
- do while allents~=''
- entries=entries+1
- parse var allents '"' name.entries '"' allents
- if name.entries='' then
- type.entries=0
- else do
- lister query arg3 entry '"'name.entries'"' stem fileinfo.
- type.entries=fileinfo.type
- name.entries = printpath || name.entries
- end
- end
- return
-
- getall_alien:
- entries=0
- do while allents~=''
- entries=entries+1
- parse var allents '"' name.entries '"' allents
- if name.entries='' then
- type.entries=0
- else
- type.entries= -1
- end
- return
-