r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
17-Feb-2010
[1972x4]
You would have to modify the existing awake handler to print.

I don't think you can display a progress bar as the only way to update 
the GUI is by creating a GUI event, and that is not documented yet.
So, in this example of sending a fax http://rebol.wik.is/Rebol3/R3_GUI/Sendfax.r


the net-log function is altered to update the GUI ... but in fact 
nothing happens until all the network actiivty ceases.
In R2 you'd do a wait to allow the GUI to update ... but you can't 
do a wait inside a wait
The http protocol lacks any net-log or debugging so could write one 
and insert it into the awake handler ...
ChristianE
17-Feb-2010
[1976]
Thanks, Graham, your answer is appreciated. I was thinking along 
the lines of repeatedly waiting on an open http port for only a short 
while and on every loop iteration updating a busy indicator just 
to show that something is going on. Sounds like that's not possible, 
so I think I'll leave it as it is for now.
Gabriele
18-Feb-2010
[1977]
request-download shows a progress bar.
Graham
18-Feb-2010
[1978]
>> value? 'request-download
== false
ChristianE
18-Feb-2010
[1979]
Gabriele, it seems as if that REQUEST-DOWNLOAD has yet to find it's 
way into R3. Though on the other hand, it's seems very likely to 
me that you know about R3 resources I'm not aware of.
Henrik
18-Feb-2010
[1980x2]
if you can do a read and get the number of bytes read into a callback 
then you have the possibility of creating your own progress bar.
R2's read-thru does this.
ChristianE
18-Feb-2010
[1982]
Ok, Henrik, are you saying that theoretically it should be possible 
to adapt REQUEST-DOWNLOAD or alike to R3 with current R3/HTTP-scheme? 
If so, I'll have a go and study the source, it's just that I am not 
able to tell wether I just dont get it or if something is missing 
for now. Is it expected to be possible yet?
Henrik
18-Feb-2010
[1983]
I don't know if it's possible with the current R3/HTTP scheme.
ChristianE
18-Feb-2010
[1984]
Thanks, Henrik, anyway. I'll take Gabriele's answer for a "yes, it's 
possible" because he has written the scheme, so he would know for 
sure ;-) I'll study his protocol and the underlying TCP stuff deeper 
after the weekend.
Gabriele
19-Feb-2010
[1985x5]
ah, sorry guys, didn't notice this was a R3 group. hmm, it shoud 
in principle be even easier for R3, but i guess there are no examples 
to show...
starting from here: http://www.rebol.net/wiki/Scheme:_HTTP
what you want is the bottom of the page, "Lowest level: asynchronous 
operation"
you need basically to respond to 'connect and do a read, use 'read 
events to report progress, and use 'done to know when all the data 
is ready.
(this assumes that there have been no major changes to http since 
last time i touched it.)
Graham
19-Feb-2010
[1990]
As I mentioned before ... you can't still update the gui without 
the information on how to create a gui event
Henrik
19-Feb-2010
[1991]
Graham, do you mean use 'do-style to run an actor?
Graham
19-Feb-2010
[1992]
No, I mean how do you update the gui while in the middle of a network 
operation ?  The only way to force the gui to change is to generate 
a GUi event, like a mouse click etc but a fake event
Henrik
19-Feb-2010
[1993x2]
I'd say the useful solution in R2 at least is to use a call-back 
like read-thru does, so you solve the issue in the networking code, 
not in the GUI cide.
code.
Gabriele
19-Feb-2010
[1995]
graham, in my vid, you would just use set-face on the progress bar. 
i don't know about Carl's version. it would be very surprising if 
it required creating an event.
Henrik
19-Feb-2010
[1996]
it's not much different in Carl's version.
Graham
19-Feb-2010
[1997x2]
set-face doesn't update until the network activity has ceased
Maybe I did something wrong ... perhaps someone else can try it
Henrik
19-Feb-2010
[1999]
how are you doing it? the set-face has to be called from somewhere 
within the networking code. alternatively something is synced which 
shouldn't be synced.
Graham
19-Feb-2010
[2000]
http://rebol.wik.is/Rebol3/R3_GUI/Sendfax.r

I update the GUI in the awake handler
Henrik
19-Feb-2010
[2001]
inside prot-fax-r?
Graham
19-Feb-2010
[2002]
Yes ... as I redefine net-log in the gui to do the updating, and 
net-log is used inside pro-fax.r
Henrik
19-Feb-2010
[2003x2]
ok, I see it
what good does the last line do?
Graham
19-Feb-2010
[2005]
what last line?
Henrik
19-Feb-2010
[2006]
set-face/field a1 tail get-face a1 'locate 
txt
Graham
19-Feb-2010
[2007x4]
sets the text cursor ?
been a while since I wrote that code .. hard to remember now!
I wonder if it's there to force the text to scroll to that point 
...
The issue in updating an area is to show the new text ... which may 
be out of sight unless you somehow force the area to scroll down 
to the new text
ChristianE
19-Feb-2010
[2011x5]
Gabriele, thanks for the clarification. I'll give it a try over the 
weekend.
On first examination, executing the following code seems like an 
unexpected error. Doing
port: make port! http://www.rebol.com
port/awake: funct [event] [
    port: event/port
    switch/default event/type [
        read    [prin "read:"    copy  port]
        lookup  [prin "lookup:"  query port open port]
        wrote   [prin "wrote:" ]
        connect [prin "connect:" read  port]
        ready   [prin "ready:"   close port]
        custom  [prin "custom:"]
        done    [prin "done:"  ]     
        close   [prin "close:" ]
        error   [prin "error:" ]
        custom  [prin "custom:"]
    ][
        true
    ]
]
open port
wait port
gives
connect:wrote:read:custom:** Script error: res: needs a value

** Where: either case check-data either switch check-response switch 
applier wake-up loop applier wait catch either applier do vv
** Near: either headers/content-length <= length? port/data [
    sta...
Graham
19-Feb-2010
[2016x2]
in prot-http.r, in http-awake function, there is a switch statement

res: switch state/state


try adding a switch/default instead

and use 'none for the default to see what happens
and probe state/state to see what value might be causing this error
ChristianE
20-Feb-2010
[2018x4]
HTTP-AWAKE is the event handler for the underlying TCP port, from 
my understanding the awake handler for the HTTP scheme should be 
way simpler.
I'm getting better results with
port: make port! http://www.rebol.com
port/awake: funct [event] [
    port: event/port
    prin join event/type ":"
    
    switch/default event/type [
        connect [read  event/port false]
        ready   [read  event/port false]
        read    [query event/port false]
        custom  [copy  event/port false]
        done    [true]
        close   [true]
    ][
        false
    ]
]
open port
wait port
That gives the following output: