Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Oct 20, 2018 11:07 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: HTTPSocket method or property DNE errors
PostPosted: Tue Jun 12, 2012 1:43 pm 
Offline

Joined: Tue Jun 12, 2012 7:28 am
Posts: 6
I'm having trouble with errors - every time I try to use HTTPSocket methods, I get errors telling me that the method or property does not exist. I'm trying to write a program that, once you hit "start", continuously downloads a url containing an xml file every 10 seconds or so.

I copied this straight from a readme, put it under the "start" push button's action, and I get the same error. In fact, it seems like I somehow am missing methods, because for both the HTTPSocket and the HTMLViewer the language reference lists methods that do not appear when I start typing mySocket.methodname, and attempting to use them throws the same DNE exception.

So, here's two lines of code that are supposed to work and do not - can anyone tell me why I'm getting this DNE error? Thanks (again!):

Dim socket1 as New HTTPSocket
socket1.Download "www.realbasic.com/release.html", GetFolderItem("RB release")


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Tue Jun 12, 2012 2:46 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
socket1.DOWNLOAD???

There is no such method. I think you want socket1.Get.

Note also that autocomplete is context sensitive. For example, PageHeaders returns a value, so if you just type

socket1.PageHeaders

it will not autocomplete, but it will if you type

dim phdr as InternetHeaders = socket1.PageHeaders


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Tue Jun 12, 2012 2:52 pm 
Offline

Joined: Tue Jun 12, 2012 7:28 am
Posts: 6
Thanks for the tip about autocomplete. I copied the download method straight from dan vanderkam's readme on httpsocket 2.0, but maybe it is outdated.


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Tue Jun 12, 2012 4:10 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Had to google that. Yes, that is very old. It looks like it predates the built-in HTTPSocket class. No wonder that documentation doesn't match the existing control. RS has since made their own class. Use the official documentation.

http://docs.realsoftware.com/index.php/HTTPSocket


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Wed Jun 13, 2012 12:17 pm 
Offline

Joined: Tue Jun 12, 2012 7:28 am
Posts: 6
Figured I'd reply here with another question...

I've got a push button whose action is DIM f as FolderItem f = getFolderItem("tempData.txt") Object1.get("myURL", f)

and an HTTPSocket whose DownloadComplete event is

dim i as integer i = ticks while ticks - i < 5 * 60 wend

DIM f as FolderItem f = getFolderItem("tempData.txt") Object1.get("MYURL", f)

I added that 5 second pause because the data was flickering in and out out. So, now what happens is that there is data for 5 seconds, then an empty text file for the next 5 seconds, then updated data for another 5 seconds. Rinse and repeat.

I can't figure out how to stop the file from flickering empty and then full of data. I've tried looping under the push button's action, but that just doesn't update the data.

Any ideas?

Here's a Gist with the code for better formatting.


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Wed Jun 13, 2012 12:52 pm 
Offline

Joined: Fri Nov 16, 2007 10:18 pm
Posts: 195
Location: Portland, OR
The [ code ] tags are your friend:
// PushButton Action:
DIM f as FolderItem
f = getFolderItem("tempData.txt")
Object1.get("www.iobridge.com/api/module/feed.xml?key=4bb3qPlupVx95mFUYM", f)

// HTTPSocket Download complete event:
dim i as integer
i = ticks
while ticks - i < 5 * 60
wend

DIM f as FolderItem
f = getFolderItem("tempData.txt")
Object1.get("www.iobridge.com/api/module/feed.xml?key=4bb3qPlupVx95mFUYM", f)


Seems like a roundabout way of doing things. Why not just put a timer on your project with the period set to 5000 (5 seconds). Then put this is the timer's action event:
Dim f As FolderItem

f = GetFolderItem("tempData.xml")
'Object1.HTTPProxyAddress = "192.168.0.1" ' needed for my environment
'Object1.HTTPProxyPort = 8080 ' needed for my environment
Object1.get("http://www.iobridge.com/api/module/feed.xml?key=4bb3qPlupVx95mFUYM", f)


The above worked for me when I tested.

_________________
Windows: Win7 64bit sp1, Vista 32bit sp2, WinXP 32bit SP3
Linux: RH EL6
Mac: Died in 2011 and took 2 months to notice.

RealStudio: 2012r2


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTPSocket method or property DNE errors
PostPosted: Wed Jun 13, 2012 9:49 pm 
Offline

Joined: Tue Jun 12, 2012 7:28 am
Posts: 6
Oh, thanks. I will try that!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group