WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Drag and Drop a file onto a compiled WinBatch Script Icon and Open FTP Site

 Drag and Drop 

Question:

I would like to create a program associated with an Icon on a Win95 desktop which allows me to drop a file onto the icon and the program opens the appropriate ftp site (which happens to be a QMS printer which is FTP compatible) and "put"s the file to that site. If nothing was dragged and dropped onto that Icon, I want the program to prompt me for the file.

I have a registered copy of Winbatch and I have downloaded the winsock extender. I am creating this program on Win95.

Can this be done? How do I determine if something has been dropped onto the icon? What other commands do I have to know in WinBatch?

Answer:

Turns out to do true drag and drop you need the compiler. However FileMenu (which is what you get when you right click a file) can be educated to have a "FTP THIS" menu item.

If you have the compiler, you just compile an exe file and put the exe on the desktop. The name of the file that is dragged onto the WB EXE will show up as the variable "param1". (See the WinBatch.hlp file (NOT the WIL help file) to read more about command line parameters.) You'll test for the status of param0, and if it is greater than 0, then you'll do something.

If param0>0  then ...
If the icon was double clicked (rather than the file being dragged and dropped onto it), then param0 (which is the number of parameters) would be zero.

To keep the application from failing when double-clicked without a file dragged to it, (param0 would in this case equal 0), add the following code:

	If Param0==0 then Param1=""
	

The Internet WinSock extender ought to be able to do the entire FTP transfer part of your procedure.

So step 1 is to make a WBT script that prompts you for a file name and FTPs it to your printer. Here's what you gotta do ...

  1. Figure out FileMenu - basically right click a file and look for the "Edit Menu Item" stuff. Read about it in the WinBatch help file.
  2. When you get it figured out, add this script to it. Then to FTP the file, just right-click it and away it goes...
;Duper Super Auto-Ftp program.
;Add this to your FileMenu.  When you want to
;FTP the file someplace, just right-click on the file menu
;and select FTP

;FTP the file someplace
	;Initialize these variables accordingly
	host="ftp.windowware.com"
	userid="xxxxx
        pswd="yyyyyyy"
        acct=""
        destdirectory="/www/wwwftp/wbxx/"
        
        dafile=CurrFilePath()
        dafile=FileNameLong(param1)
        dabasicfile=FileRoot(dafile)
        x=FileExtension(dafile)
        if x!="" then dabasicfile=strcat(dabasicfile,".",x)
        daremotefile=strcat(destdirectory,dabasicfile)
        
AddExtender("wwwsk34I.dll")  ; this is the WinSock extender
        
        hSession=FtpOpen(host,userid,pswd,acct,1)
        if !IsNumber(hSession)
            Message("FTP Open Error",hSession)
            exit
        endif
        rs=FtpChDir(hSession,destdirectory)
        if rs!=""
            Message("FTP ChDir Error",rs)
            exit
        endif
        rs=Ftpput(hSession, dafile, daremotefile, "B")
        FtpClose(hSession)
        if rs!=""
           Message("FtpPut Error",rs)
        else
           Display(1,"Ftp Success",daremotefile)
	endif	

Article ID:   W13444
Filename:   How to Drag and Drop a file onto a Icon.txt
File Created: 2006:08:24:12:11:32
Last Updated: 2006:08:24:12:11:32