Ted Wall wrote:

> Won't have time to look at your request in detail until Monday, I'm 
> off in 30 minutes for the weekend
> 

Well... I finally sorted it all out thanks to your examples. Are you back from 
the weekend (of several 
weeks ago), and now ready for... the weekend, I guess ?!

I modified your template to handle both dragdrop configurations, that is when 
one has checked 'handle 
files separately' and when one hasn't -- dropped files are returned as a list.

I changed some of the @label names and added a couple of parameters here and 
there, but the gist is 
the same as yours. Perhaps one difference is that this label is ready to handle 
the most common case --
at least for me-- of running a program with the dropped files as parameters.

First an example of a bar-button that uses this stuff, then the actual @label.

[5]
; supports dragdrop
id = media
Tooltip = drop»play with VLC/L»media 1:VLC 2:wallpaper
Icon = v:\bin\PortableVLC\App\AppInfo\appicon.ico
LCmd1 = Script
LParam1 = SetString c |
LCmd2 = IF(c == "|")DO

; button just clicked
LCmd3 = .OnMultiClick(?"v:/bin/PortableVLC/PortableVLC.exe", "bar hideshow 
PicturePlayer","","")

LCmd4 = ELSE

; files were dragdropped
LCmd5 = [EMAIL PROTECTED](?#"v:\bin\PortableVLC\PortableVLC.exe" --intf wx#, c)

;Sample: LCmdX = [EMAIL PROTECTED](?#start "" "cmd.exe" /c pause#, c)
; use above line to get visible console windows

; below normally not used except for balloontips
LCmd6 = ; if (contextlast)
LCmd7 = ; command for above if, last filename was read...
LCmd8 = ENDIF

;---- [EMAIL PROTECTED] ------

@DropFiles
static sPgm, vFiles

;exec.scriptdebug(1)
;b! 0(context) 1(arg(1)) 2(arg(2)) 3(arg(3)) 4(contextlast)
;e! 0(context) 1(arg(1)) 2(arg(2)) 3(arg(3)) 4(contextlast)
if (arg(2)=="|")do
  ; active button pressed, arg(3) is menu to show (or some other cmd)
  ; Note: this is entered only if clicked button calls me 
  do( arg(3) )
  quit
else

  ; files were dragdropped - arg(1) is pgrm.exe arg(2) is a single
  ; file or a filelist - NOTE: depending on the pproconf.exe setting
  ; ">Advanced Setup>Other>drag drop many files runs each one separately"
  ; it is necessary to include here code that builds a filelist out
  ; of single filenames from successive calls to this function.
  ; If that setting is unchecked we will recieve the filelist already
  ; built, so this code won't be used.
  if(0 == context)do
    if( vec.exists(vFiles) )
      vec.destroy(vFiles)

    vFiles=vec.create(20,20)
    sPgm = arg(1)
  endif

  vFiles[context] = arg(2)
  ; could use vFiles[context] = _file_ ;but misteriously _file_ is nil
  context=context+1

  if (contextlast)do
    event.createms(300,1, cb("dowork"))
    QUIT
  endif

endif
quit

@dowork
static sPgm, vFiles

;exec.scriptdebug(1)
;b! 0(sPgm) 1(fnames) 2(fn) 3("") 4("")
;e! 0(sPgm) 1(fnames) 2(fn) 3("") 4("")

if (not vec.exists(vFiles))
quit

; I prefer to do below and release the vector as soon as possible
LOCAL fn, fnames= VEC.Makelines(vFiles)
vFiles= vec.destroy(vFiles)

for (local i=1; i<context +1; i=i+1)
fn= LINE(fnames, i)
if (not fn)
break

;do something with fn (can be a single file or a filelist)

    ; work around an old powerpro bug: fix "file""file" ==> "file" "file"
    ; Note: this bug is fixed in recent versions, so this code shouldn't
    ; get exercised much
    local j = index(fn,??""?)
    for( ; j ; )
      fn=select(fn,j-1)++??" "?++remove(fn,j+1)
      j = index(fn,??""?)
    endfor

  do ( "*dos *hide "++sPgm++" "++fn )
  ; to show console pgrms call @DropFiles(?'start "" "cmd.exe" [/c] ...', ...)

endfor

quit



------------------------ Yahoo! Groups Sponsor --------------------~--> 
You can search right from your browser? It's easy and it's free.  See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to