1. Wxeuphoria network functionality

Matt,

Are the wxeuporia routines for downloading files work yet?

Could I use wxeuphoria to download an internet file or should I stick with
calling wget for now?

--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » topic index » view message » categorize

2. Re: Wxeuphoria network functionality

Jason Gade wrote:
> 
> Matt,
> 
> Are the wxeuporia routines for downloading files work yet?
> 
> Could I use wxeuphoria to download an internet file or should I stick with
> calling
> wget for now?
> 

I've had success with them.  I was downloading the Euforum text file and 
converting it into an rss file.  Here is the routine I used to get the file:
procedure on_timer( atom this, atom event_type, atom id, atom event )
	atom url, stream
	integer fn
	sequence path, current
	path = get_text_value( file_name )
	fn = open( path, "w" )
	if fn = -1 then
		-- error opening the file, should post an error message to the user
		return
	end if
	url = create( wxURL, "http://www.listfilter.com/mlist/current.txt" )
	stream = get_url_input( url )
	if stream then
		current = stream_read( stream )
		puts( fn, "<?xml version='1.0' encoding='utf-8' ?>\n" )
		puts( fn, "<rss version=\"2.0\">\n" )
		puts( fn, "<channel>\n")
		puts( fn, "<title>EuForum</title>\n" )
		puts( fn, "<link>http://www.listfilter.com/EuForum</link>\n" )
puts( fn, "<description>EuForum RSS Feed - Official Euphoria Message
Board</description>\n" )
		
		to_rss( fn, current )
		
		puts( fn, "</channel>\n</rss>\n" )
		delete_instance( stream )
	else 
		puts(2, "Stream failed!\n")
	end if
	delete_instance( url )
	close(fn)
end procedure


Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. Re: Wxeuphoria network functionality

Matt Lewis wrote:
> 
> Jason Gade wrote:
> > 
> > Matt,
> > 
> > Are the wxeuporia routines for downloading files work yet?
> > 
> > Could I use wxeuphoria to download an internet file or should I stick with
> > calling
> > wget for now?
> > 
> 
> I've had success with them.  I was downloading the Euforum text file and 
> converting it into an rss file.  Here is the routine I used to get the file:
> }}}
<eucode>
> procedure on_timer( atom this, atom event_type, atom id, atom event )
> 	atom url, stream
> 	integer fn
> 	sequence path, current
> 	path = get_text_value( file_name )
> 	fn = open( path, "w" )
> 	if fn = -1 then
> 		-- error opening the file, should post an error message to the user
> 		return
> 	end if
> 	url = create( wxURL, "http://www.listfilter.com/mlist/current.txt" )
> 	stream = get_url_input( url )
> 	if stream then
> 		current = stream_read( stream )
> 		puts( fn, "<?xml version='1.0' encoding='utf-8' ?>\n" )
> 		puts( fn, "<rss version=\"2.0\">\n" )
> 		puts( fn, "<channel>\n")
> 		puts( fn, "<title>EuForum</title>\n" )
> 		puts( fn, "<link>http://www.listfilter.com/EuForum</link>\n" )
> 		puts( fn, "<description>EuForum RSS Feed - Official Euphoria Message
> Board</description>\n" )
> 		
> 		to_rss( fn, current )
> 		
> 		puts( fn, "</channel>\n</rss>\n" )
> 		delete_instance( stream )
> 	else 
> 		puts(2, "Stream failed!\n")
> 	end if
> 	delete_instance( url )
> 	close(fn)
> end procedure
> </eucode>
{{{

> 
> Matt Lewis

Thanks, Matt.

I don't think I've looked at the latest release of wxeuphoria, but I remember
looking in your documentation and it saying that it wasn't working correctly. At
least that is the way I understood it.

This example helps and now I have one less excuse for getting started!

--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Wxeuphoria network functionality

Jason Gade wrote:
> 
> Thanks, Matt.
> 
> I don't think I've looked at the latest release of wxeuphoria, but I remember
> looking in your documentation and it saying that it wasn't working correctly.
> At least that is the way I understood it.
> 

The wxHTTP class doesn't work, but you can use wxURL and the socket classes.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

5. Re: Wxeuphoria network functionality

Matt Lewis wrote:
> 
> Jason Gade wrote:
> > 
> > Thanks, Matt.
> > 
> > I don't think I've looked at the latest release of wxeuphoria, but I
> > remember
> > looking in your documentation and it saying that it wasn't working
> > correctly.
> > At least that is the way I understood it.
> > 
> 
> The wxHTTP class doesn't work, but you can use wxURL and the socket classes.
> 
> Matt Lewis

Any good pointers on how to learn to do that? The wxwidgets docs are a bit thick
for me.

Say I wanted to download the file http://www.rapideuphoria.com/archive.zip
How would I do that, or where would I learn?

--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Wxeuphoria network functionality

Jason Gade wrote:
> 
> Matt Lewis wrote:
> > 
> > 
> > The wxHTTP class doesn't work, but you can use wxURL and the socket classes.
> > 
> 
> Any good pointers on how to learn to do that? The wxwidgets docs are a bit
> thick
> for me.

I think the best way is to just keep trying.  Look at the code I've posted,
maybe at the code in the wxEuphoria files, and compare that to what you 
see in the wxWidgets docs.  As you go along, you'll probably start to 
pick up on things.  You can also ask me about things you run across.

My documentation is often a bit light.  If you can fill out the docs
in any place that gave you trouble, I'd appreciate it (and so would anyone
else who came after you).
 
> Say I wanted to download the file <a
> href="http://www.rapideuphoria.com/archive.zip">http://www.rapideuphoria.com/archive.zip</a>
> How would I do that, or where would I learn?
> 

Here is a modified version of what I posted earlier.  It will download the
file specified in the box and save it.  It just stores everything in one
sequence and a single write.  To break it up, take a look at stream_read(),
and you could put that into your own code, and dump the result to a file
as you go.

without warning
include wxEuphoria.e
include wxText.e
include wxButton.e
include wxNet.e

global constant
main = create( wxFrame, {0, -1, "Download Demo", 0, 0, 419, 200,
wxDEFAULT_FRAME_STYLE }),
panel = create( wxPanel, main ),
file_label = create( wxStaticText, {panel, -1, "File name:", 13, 34, 116, 22 }),
file_name = create( wxTextCtrl, {panel, -1,
"http://www.rapideuphoria.com/index.html", 135, 34, 300,  23 }),
download_button = create( wxButton, {panel, -1, "Download Now", 13, 126, 96, 30
})


procedure on_click( atom this, atom event_type, atom id, atom event )
	atom wxurl, stream
	integer fn, ix
	sequence url, current, path
	url = get_text_value( file_name )
	path = reverse( url )
	ix = find( '/', path )
	if ix then
		path = reverse( path[1..ix-1] )
	
	else
		path = reverse( path )		
	end if
	
	wxurl = create( wxURL, url )
	stream = get_url_input( wxurl )
	if stream then
		fn = open( path, "w" )
		if fn = -1 then
			puts(2, "Could not open file!\n" )
		else
			current = stream_read( stream )
			puts( fn, current )
			delete_instance( stream )       			
			close(fn)
		end if
	else
		puts(2, "Stream failed!\n")
	end if
	delete_instance( wxurl )
	 
	
end procedure
set_event_handler( download_button, -1, wxEVT_COMMAND_BUTTON_CLICKED,
routine_id("on_click"))

wxMain( main )


new topic     » goto parent     » topic index » view message » categorize

7. Re: Wxeuphoria network functionality

Matt Lewis wrote:
> 
> Jason Gade wrote:
> > 
> > Matt Lewis wrote:
> > > 
> > > 
> > > The wxHTTP class doesn't work, but you can use wxURL and the socket
> > > classes.
> > > 
> > 
> > Any good pointers on how to learn to do that? The wxwidgets docs are a bit
> > thick
> > for me.
> 
> I think the best way is to just keep trying.  Look at the code I've posted,
> maybe at the code in the wxEuphoria files, and compare that to what you 
> see in the wxWidgets docs.  As you go along, you'll probably start to 
> pick up on things.  You can also ask me about things you run across.
> 
> My documentation is often a bit light.  If you can fill out the docs
> in any place that gave you trouble, I'd appreciate it (and so would anyone
> else who came after you).

I noticed that blink
I'll do what I can, but no promises.
 
<snipped code>

Thanks, Matt. I'll see what I can do.

I don't have a very good track record on completing projects, but I like this
idea that I have.

But it uses networking, gui, and database (EDS) none of which I've programmed
before.

Would I get any benefit from reading the developer sources for wxeuphoria, or
should I stick with your demo programs for now? I know some of it is
automatically generated which is even harder to read than normal code.

At least, I think you said some of it was automatically generated.

Anyway, thanks!

--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Wxeuphoria network functionality

Jason Gade wrote:
> 
> Would I get any benefit from reading the developer sources for wxeuphoria, or
> should I stick with your demo programs for now? I know some of it is
> automatically
> generated which is even harder to read than normal code.
> 
> At least, I think you said some of it was automatically generated.
> 

There are two things that are auto-generated.  All the imports (define_c_var)
and the platform specific code gets commented or uncommented.  Most of
the code is pretty simple, and just wraps the calls, doing stuff like 
putting a sequence into a wxString, and so forth.  Some routines do a bit
more, and might help you understand how things work.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

9. Re: Wxeuphoria network functionality

Matt Lewis wrote:
> Here is a modified version of what I posted earlier.  It will download the
> file specified in the box and save it.  It just stores everything in one
> sequence and a single write.  To break it up, take a look at stream_read(),
> and you could put that into your own code, and dump the result to a file
> as you go.
> 
> }}}
<eucode>
> without warning
> include wxEuphoria.e
> include wxText.e
> include wxButton.e
> include wxNet.e
> 
> global constant
> main = create( wxFrame, {0, -1, "Download Demo", 0, 0, 419, 200,
> wxDEFAULT_FRAME_STYLE }),
> panel = create( wxPanel, main ),
> file_label = create( wxStaticText, {panel, -1, "File name:", 13, 34, 116, 22
> }),
> file_name = create( wxTextCtrl, {panel, -1,
> "http://www.rapideuphoria.com/index.html", 135, 34, 300,  23 }),
> download_button = create( wxButton, {panel, -1, "Download Now", 13, 126, 96,
> 30 })
> 
> 
> procedure on_click( atom this, atom event_type, atom id, atom event )
> 	atom wxurl, stream
> 	integer fn, ix
> 	sequence url, current, path
> 	url = get_text_value( file_name )
> 	path = reverse( url )
> 	ix = find( '/', path )
> 	if ix then
> 		path = reverse( path[1..ix-1] )
> 	
> 	else
> 		path = reverse( path )		
> 	end if
> 	
> 	wxurl = create( wxURL, url )
> 	stream = get_url_input( wxurl )
> 	if stream then
> 		fn = open( path, "w" )
> 		if fn = -1 then
> 			puts(2, "Could not open file!\n" )
> 		else
> 			current = stream_read( stream )
> 			puts( fn, current )
> 			delete_instance( stream )       			
> 			close(fn)
> 		end if
> 	else
> 		puts(2, "Stream failed!\n")
> 	end if
> 	delete_instance( wxurl )
> 	 
> 	
> end procedure
> set_event_handler( download_button, -1, wxEVT_COMMAND_BUTTON_CLICKED,
> routine_id("on_click"))
> 
> wxMain( main )
> </eucode>
{{{


Other than changing the open() call to "wb", this works great! Maybe you could
put it in your demos.

--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Wxeuphoria network functionality

Jason Gade wrote:
> 
> 
> Other than changing the open() call to "wb", this works great! Maybe you could
> put it in your demos.

Oops.  I was testing on Linux and forgot to do that.  And yes, I was planning
on adding it...

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu