Command DownloadFile() help!

Find quick help here to get you started with Hollywood
Post Reply
divsalv
Posts: 23
Joined: Sun Mar 22, 2015 3:01 am

Command DownloadFile() help!

Post by divsalv »

Hi, I need help for the command DownloadFile (), i wrote an example, and I have a problem.

Code: Select all

Function tmp(cnt)
		DebugPrint (cnt)
	EndFunction

	DownloadFile("www.url.it/file", {File = "tmp.txt",func=tmp(userdata=count)})	
The file is downloaded, but the program stops, if I add code after the command DownloadFile () is not executed, and the function tmp () is executed only one time, how can I do to create a status bar if I do not return values ?

Thanks in advance for your help.

Would welcome an example.
divsalv
Posts: 23
Joined: Sun Mar 22, 2015 3:01 am

Re: Command DownloadFile() help!

Post by divsalv »

nobody?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Command DownloadFile() help!

Post by airsoftsoftwair »

There are lots of problems with your code. Check the documentation of DownloadFile(). There is no "func" tag in the options table, it is an additional parameter. Also, read up on the basics of the Hollywood programming language because your code shows some misunderstanding of fundamental concepts, i.e. doing the following

Code: Select all

func = tmp(userdata=count)
will call the function tmp() with the result of the comparison "userdata=count" as the parameter and write the function's return value into the variable/table element "func". This is definitely not what you want.

Correct code would be something like this:

Code: Select all

Function func(msg)
   DebugPrint(msg.action, msg.count, msg.total)
EndFunction

DownloadFile("http://www.url.it/file", {File = "tmp.txt"}, func) 
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

Re: Command DownloadFile() help!

Post by lazi »

There is a server which holds files with awkward names like this:
http://localhost/dokumentumok/$0000007E ... %A9ter.PNG

These file names are already encoded and can not do anything for DownloadFile() to open it.
It sends this request to the server: GET /dokumentumok/%240000007EGy%f5ry%20P%e9ter.PNG HTTP/1.1

I have not found any strict restrictions about file naming of a http server. It varies on implementations and on the host filesystem/OS.

I think a switch would be nice for DownloadFile() to control the file name encoding.
Or is there any other way?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Command DownloadFile() help!

Post by airsoftsoftwair »

Yes, I think this makes sense because in case the server can deal with non ISO 8859-1 characters you'll have a problem anyway so it would be good if DownloadFile() also accepted encoded URLs. I'll see what I can do about this.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Command DownloadFile() help!

Post by airsoftsoftwair »

Code: Select all

- New: DownloadFile() and UploadFile() support a new tag named "Encoded" now; if this is set to TRUE,
  DownloadFile() and UploadFile() will assume that the URL you've passed is already percentage-encoded
  and no more encoding will be done
User avatar
lazi
Posts: 625
Joined: Thu Feb 24, 2011 11:08 pm

Re: Command DownloadFile() help!

Post by lazi »

Hmm, I can smell the 6.1 in the air(soft) :-)
Post Reply