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

World: r3wp

[Core] Discuss core issues

Gordon
8-May-2005
[1044]
Thanks Tomc; that should do it.
Micha
9-May-2005
[1045x3]
how to decode this url ?
input: uggc%2Fjungvfzlvc.pbz
output: http://whatismyip.com
Anton
9-May-2005
[1048]
rot13: func [s [string!] /local result top][
    result: copy s
    repeat n length? s [

        top: either s/:n >= #"a" [97][65] ; determine upper or lowercase

        if (i: s/:n - top) < 26 [ ; only 26 letters in alphabet affected
            i: i + 13 // 26 ; perform rot13
            poke result n to-char top + i ; insert new letter
        ]
    ]
    result
]
Gabriele
9-May-2005
[1049x5]
sunanda: i can only think of:
>> index? find (as-binary a) xor as-binary b complement charset "^(00)"
== 7
though, i'm not sure it's an easy way, and it is probably overkillif 
a and b are "big".
another option would be to try with parse, though it's gonna boil 
down to some kind of loop anyway.
>> parse a [any [(char: b/1) char (b: next b)]]
== false
>> b
== "45678"
Janeks
9-May-2005
[1054]
How to set correctly progress function for read-net? Or what causes 
following error and :                                            
                >> myProgr: func [ tot bt ] [ print bt / tot ]

>> read-net/progress to-url "http://maps.dnr.state.mn.us/cgi-bin/mapserv36?map=/usr/loca

l/www/docs/mapserver_demos/tests36/expressions/test.map&map_counties_class_expression=(%

5bAREA%5d %3e 7577272785.15339)&layer=title&map_title_class_text=Counties+Larger+Tha
n+Itasca+County&mode=map" :myProgr
0.425625
** Script Error: not is missing its value argument
** Where: read-net

** Near: all [:callback size not callback size length? buffer data: 
true break]
not data
>> source read-net
read-net: func [

    {Read a file from the net (web). Update progress bar. Allow abort.}
    url [url!]

    /progress callback {Call func [total bytes] during transfer. Return 
    true.}
    /local port buffer data size
][
    vbug ['read-net url]
    if error? try [port: open/direct url] [return none]

    size: to-integer any [port/locals/headers/content-length 8000]
    buffer: make binary! size

    set-modes port/sub-port [lines: false binary: true no-wait: true]
    until [
        if not data: wait [60 port/sub-port] [data: true break]
        if data: copy port/sub-port [append buffer data]

        all [:callback size not callback size length? buffer data: true break]
        not data
    ]
    close port
    if not data [buffer]
]
>>
Gabriele
9-May-2005
[1055]
is your callback function returning a value? i think it should return 
true normally, or false if you want to cancel the download.
Allen
9-May-2005
[1056]
Use request-download as a guide. It has everything you need to know. 
you should be able to substitute read-thru with read-net if you wish.
Janeks
10-May-2005
[1057x3]
O'k. My mistake are offen do not tell what is my target. So it is 
to get working status bar in a layout. As I understood it is possible 
by read-thru.
Thanks Gabriele. It was the reason. But to continue regarding status 
bar functions fired by read-thru. Than it is a problem just to kBox/image: 
 read-thru/progress myUrl :myProgr . It is possible just by using 
local file i.e. kBox/image: read-thru/to/progress myUrl %tmpImg.png 
:myProgr
BTW: How to insert newline in a post?
DideC
10-May-2005
[1060]
Click the "pen" icon just up to the input area (near color/ no color 
one)
Janeks
10-May-2005
[1061]
Thanks!
I am getting following parameters of myProgr:
3650 8000
7430 8000
9950 8000
13730 8000
15335 8000
19115 8000
22975 8000
26755 8000
30695 8000
34475 8000
38255 8000
42195 8000
46055 8000
49835 8000
53695 8000
55197 8000
55197 8000


How then to calculate data for progress bar ( decimal from 0 to 1 
)?
Or how to get total bytes?
Allen
10-May-2005
[1062]
Janek. request-download has the example callback you need. View its 
source. here is a snippet. Where prog is the progressbar and stat 
is a label in your layout and stop is a value that controls that 
should be be set false outside of this func to start with, and can 
set to true via a cancel button to force a download to stop before 
completion. 
func [total bytes] [
        prog/data: bytes / (max 1 total) 
        stat/text: reform [bytes "bytes"] 
        show [prog stat] 
        not stop
    ]
Janeks
11-May-2005
[1063]
Thanks Allen!
The problem was so obvious that I did not think about it ;-)

just it is impossible to know what size of image will be that is 
coming from a cgi process with many parameters.
Allen
11-May-2005
[1064]
A easy job for REBOL... http://www.eyon.com/. I can't believe this 
tool needs to be 4mb zipped.
Volker
12-May-2005
[1065]
i like this little function and cant find a good name.
your: func [offset value] [
	if value [value/:offset]
]
usage:
 your 'facet get-style 'field

its sometimes more readable IMHO than putting the interesting word 
far at the end of line.
but i find no good name.. any suggestions?
RebolJohn
12-May-2005
[1066]
Help peoples..

I have the following..
  x: [a b c d]

  foreach y x [ set y make string! {} ] ;make them all empty strings.
then I process/append info into the different groups a,b,c,d.
Now, I want to write each string/list to a file of the same name.
i.e.
  foreach y x [write to-file join y ".txt" ??GETVALUE?? y]

Can someone clue me in on what I do at the ??GETVALUE?? position?

Thanks peoples.
Sunanda
12-May-2005
[1067x2]
foreach y x [print [y get y]]
... so the missing ??getvalue?? is just get
Graham
12-May-2005
[1069x2]
How does one open up the serial port?


I've tried open serial://port1/9600/8 and serial://port1/9600/8 and 
both give me errors ..
this is in windows
Anton
12-May-2005
[1071x3]
Volker, in english, it seems better to write
	'facet of face    (where OF is the function in between)
but we can't do that...
How about TAKE ? ie.
	take 'facet face    ; (read in english: "take 'facet from face")
Graham, try a different port, maybe it's port2 that is mapped in 
your system.
modem: open/lines/no-wait/direct serial://port2/9600/8/none/1  ; 
from an example on rebol-list 2003-12-03
Graham
12-May-2005
[1074]
I meant above that I also tried serial://com1/9600/8 ...
Anton
13-May-2005
[1075]
Well, I was just able to do this with no error:
>> port: open serial://port2/9600/8
>> close port
Graham
13-May-2005
[1076x2]
wonder what's wrong with mine.
I wonder if I have the serial printer attached as a windows printer 
and it's hogging the serial port.
Anton
13-May-2005
[1078]
Check whether it's enabled in device manager
Graham
13-May-2005
[1079x2]
the serial port currently has a serial printer attached
which is working.  I am trying to send some commands to the printer
Anton
13-May-2005
[1081x2]
are you trying to communicate with the printer ?
right ok.
Graham
13-May-2005
[1083]
yes
Anton
13-May-2005
[1084]
You need something to see the status of all ports on your system 
to diagnose, I think, but it looks like, if rebol can't open it, 
that windows already has opened a port to it.
Graham
13-May-2005
[1085x4]
yep, that was it.
I removed the serial printer from the windows printers and now I 
can open the port
now, how do I send a page feed to the printer ... ?
That's 0c isn't it?
Anton
13-May-2005
[1089x2]
You could probably just disconnect the serial cable physically, then 
scan for hardware changes... can save time later on maybe..
Yep, looks like FormFeed (FF) is 0x0C
Graham
13-May-2005
[1091x2]
oh well, it doesn't do what I need it to do.
tried insert port #{0c} but the paper won't feed :(
Anton
13-May-2005
[1093]
Maybe you need to terminate your commands.. ?  See if you can find 
the language that the printer understands.