httpSocket - overload not recognised

Hi
I’m having a but of a senior moment. Why would this give me an error that implies it is not able to select the right method from httpSocket?

[code] dim s1 as string
//1. trim and make lower case
s1 = lowercase( trim( Me.text) )

// hash it
s1 = md5(s1)

//add to gravatar url
s1 = “http://www.gravatar.com/avatar/” + s1 + “.jpg”

//sock1 is a subclassed httpSocket
//picture1 is a folderitem in a property

//compile error here - "there is more than one item with this name … " all highlighted in yellow
sock1.get(s1, pictureFile)[/code]

Is pictureFile really a FolderItem? It might be a Picture, then you would have that error message.

Eli

No, it is definitely a FolderItem.

… is the indication that the compiler cannot decide which of the HTTPSocket.Get methods to use. Usually this is because one of the arguments is not of the correct type.

By the way your comment in the code above says that picture1 is a folderitem in a property, not pictureFile

Are you sure you didn’t write

call sock1.get(s1, pictureFile)

That would result in the compile error you describe. If so, remove “call”.

Eli - yes, that is what I thought and have been looking for my error, but I can’t see it. And yes, my comments in the code didn’t quite keep up - it is meant to refer to pictureFile not picture1

Tim - no, the code is a direct copy/paste from Xojo - there is no call.

Whats in your subclass ?
This compiles just fine

[code] dim s1 as string
dim pictureFile as folderitem
dim sock1 as new httpsocket

sock1.get(s1, pictureFile)[/code]

Norman

Ah, I think you’ve found my duh moment. Sock1 was just a subclass of httpSocket to get access to the downloadComplete event. It would appear that it needs instantiating or adding to a layout to get it to work.

I have finally got the socket to work, but not in the way I had expected.

I had expected to use httpsocket.get(URL) followed by downloadComplete event to get the associated download file. But this event doesn’t seem to fire, nor does the error event.

The only event that seems to fire after .get is .pageReceived. At least that contains the content which can be converted to a memory block and then into a picture, if you happen to already know the size of the picture.

Is there a trick to getting downloadComplete to fire?

[quote=192856:@James Pitchford]I have finally got the socket to work, but not in the way I had expected.

I had expected to use httpsocket.get(URL) followed by downloadComplete event to get the associated download file. But this event doesn’t seem to fire, nor does the error event.

The only event that seems to fire after .get is .pageReceived. At least that contains the content which can be converted to a memory block and then into a picture, if you happen to already know the size of the picture.

Is there a trick to getting downloadComplete to fire?[/quote]

From what I understand in the LR, DownloadComplete has a FolderItem property. That could imply it fires only when Get is used with a Folderitem. Which would make the name logical. You may want to try

HTTPSocket.Get ( URL As String, File As FolderItem )

instead of simply (URL).

Different events will be raised depending on the version of Get that you call. Get(String, FolderItem) raises the DownloadComplete event; Get(String) raises the PageReceived event.

Andrew

That is certainly what I expected on reading the manual. But in my example get(string, folderItem) is raising the PageReceived event and not the downloadComplete event.

Interestingly, when called, folderItem is nil - and the PageReceived event is raised.
However, if I instantiate a folder item, then the Error event is raised - code 1.

[quote=193004:@James Pitchford]Andrew

That is certainly what I expected on reading the manual. But in my example get(string, folderItem) is raising the PageReceived event and not the downloadComplete event.

Interestingly, when called, folderItem is nil - and the PageReceived event is raised.
However, if I instantiate a folder item, then the Error event is raised - code 1.[/quote]

Do you get a file ?

It works as expected for me using RS2011r4.3.

That makes sense: if the FolderItem is Nil then there’s no file to download to so PageReceived is raised instead.

[quote]However, if I instantiate a folder item, then the Error event is raised - code 1.[/quote] I don’t know what error 1 is, that’s weird.

From HTTPSocket.Error

[quote]An additional error code is:
1- Download file could not be created.[/quote]

[quote=193004:@James Pitchford]Andrew

That is certainly what I expected on reading the manual. But in my example get(string, folderItem) is raising the PageReceived event and not the downloadComplete event.

Interestingly, when called, folderItem is nil - and the PageReceived event is raised.
However, if I instantiate a folder item, then the Error event is raised - code 1.[/quote]
So you’re clear that you need to pass a valid, writable folderitem right? And it needs to point to a file, not a folder.