Re: Getting this to Work

new topic     » goto parent     » topic index » view thread      » older message » newer message

Matt Lewis wrote:
> 
> Pete Lomax wrote:
> > 
> > c.k.lester wrote:
> > > I didn't know!!! I'd LOVE to have it be pure Eu code. Tell me about it. :)
> > 
> > Well I have to recommend Fabio Ramirez's EInetLib.ew, on which my efforts
> > (pretty
> > much the same only more Edita/Arwen-biased) are made.
> > 
> > mind you, is there nothing in wxEuphoria?
> 
> Yes, wxEuphoria can grab a file off the net.   I was using it before Rob
> actually started offering rss to see what was required to do so.
> 
> Matta
I've still got a demo of this if you want it... I don't know if you've added it
to your wxEuphoria example programs or not.

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, "wb" )
        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 )


--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu