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

World: r3wp

[Rebol School] Rebol School

Henrik
25-Feb-2009
[2458]
As I said, you need a DO block (I think you missed that). Then you 
create a function to create the URL-SITE url. Then you use that as 
input with BROWSE and that will work.
PatrickP61
25-Feb-2009
[2459]
Thanks Henrik, I'll give it a try
Henrik
25-Feb-2009
[2460]
inspiration:

view [group [f: field] group [button do [probe get-face f]]]
PatrickP61
25-Feb-2009
[2461x2]
Henrik,  I added the following code:

    eval-url-site:	does [to-url ajoin [k-prefix txt-site k-suffix]]
and then after the button "open" i have:
    button "Open"	browse eval-url-site
I get a ***GUI Error: Cannot parse the GUI dialect

But if I type browse eval-url-site at the console, it works -- What 
am I missing?
Henrik
25-Feb-2009
[2463x2]
Patrick, it is still incorrect WRT to the DO block. Try reading my 
inspiration line.
you must DO right at the button.
PatrickP61
25-Feb-2009
[2465]
Ohhhh, I missed that
kib2
26-Feb-2009
[2466]
How to solve such problem ?
It seems like input-file is evaluated with none as infile value.

REBOL []

container: make object! [
    infile: none
    input-file: read join infile ".txt"
]

c: make container [infile: %rme/test]
PeterWood
26-Feb-2009
[2467x2]
When you are making the container Rebol evaluates the code in the 
argument block. So in this case, it first  sets infile to none and 
then tries to set input-file to the result of evaluting read join 
infile ".txt".
To achieve what I think you want you need to make input-file a function!:

container: make object! [
	infile: none
	input-file: make function! [] [read join infile ".txt"]
]
Geomol
26-Feb-2009
[2469]
Or use DOES again:
input-file: does [read join infile ".txt"]


When stuff is evaluated can be a bit difficult to figure out. The 
more you use and learn about REBOL, the more clear it will become.
kib2
26-Feb-2009
[2470x2]
So "input-file: does [read join infile ".txt"]" is the same I suppose.
Geomol: sorry, too late :)
Pekr
26-Feb-2009
[2472]
what about 'construct? It does not evaluate anything :-)
kib2
26-Feb-2009
[2473]
I've just tried this :

REBOL []

container: make object! [
    infile: none
    content: none
    input-file: does [content: read join infile ".txt"]
]

c: make container [infile: %user]

But it fails.
Geomol
26-Feb-2009
[2474x2]
construct doesn't work in this case, because then input-file just 
become the word READ.
Kib, what fails? You have to call input-file, before you have the 
result in content.
kib2
26-Feb-2009
[2476x2]
I named my script "ooo.r" and I have a "user.r" file inside that 
directory too.
sorry : "user.txt"
Geomol
26-Feb-2009
[2478]
c: make container [infile: %user]
d/input-file

now c/content should hold your file content.
kib2
26-Feb-2009
[2479]
>> do %ooo1.r
Script: "Untitled" (none)
>> c/infile
== %user
>> c/content
== none
Geomol
26-Feb-2009
[2480]
You have to call input-file. :-)
kib2
26-Feb-2009
[2481x3]
Geomol: hoops!!! my fault, I was calling "infile" not "input-file" 
!
works fine now !
I'm mising something here :

#!/usr/bin/rebol -q

REBOL [
    Title: "Tests with oo programming"
    Date: 26-Feb-2009
    Author: "Kib"
    File: "ooo1.r"
    Purpose: "nothing interesting"
]

son: make object! [
    parent: none
    name: "object b"
    get-parent: does [print parent]
]

mother: make object! [
    name: "object a"
    son-instance: make son [parent: self]
]

pony-mum: make mother []
print ["object name: " pony-mum/name]
print ["instance name: " pony-mum/son-instance/name]

print ["instance name:(other method) " pony-mum/son-instance/get-parent]

What's wrong with the last call ?
Graham
26-Feb-2009
[2484]
son-instance: make son [parent: self] 

self refers to son-instance
kib2
26-Feb-2009
[2485]
Graham : as i'm inside mother, self refers to a mother no ?
Graham
26-Feb-2009
[2486x2]
It looks like you're inside son-instance
mother: make object! [ name: "object a" myparent: self son-instance: 
make son [ parent: myparent ]]
kib2
26-Feb-2009
[2488]
>>it looks like you're inside son-instance


I don't understand why, sorry. I'm inside mother (I mean, when I 
write it "son-instance", but maybe it's a bad Python habit). 
 
mother: make object! [
    name: "object a"
    son-instance: make son [parent: self]
]
Graham
26-Feb-2009
[2489x2]
http://rebol.com/r3/docs/concepts/objects-self.html
you're creating a new object son-instance so self now refers to son-instance
kib2
26-Feb-2009
[2491x2]
You mean when I write "make son ..." I'm already inside the son object 
?
that may explain my problem
Graham
26-Feb-2009
[2493]
I think so.
kib2
26-Feb-2009
[2494x2]
ok: thanks !
Is there any lib somewhere to encode or decode a file to utf-8 ?
Anton
27-Feb-2009
[2496x2]
Test it:
>> son: context [parent: self]
>> son/parent = son
== true
You could do:

	mother: context [
		son: context compose [parent: (self)]
	]

so now

	>> mother/son/parent = mother
	== true
Graham
27-Feb-2009
[2498]
better idea :)
Anton
27-Feb-2009
[2499]
Oldes did some work with unicode, if I remember correctly.
kib2
27-Feb-2009
[2500]
Anton: hi! thanks a lot: what's the meaning of the parenthesis here 
?
Anton
27-Feb-2009
[2501x4]
The COMPOSE rebuilds the block, with anything in parens evaluated 
first.
So SELF will be evaluated before the second CONTEXT has a chance 
to see it.
But, if you're curious, you can always have a look yourself, using 
PROBE, eg:

	mother: context [son: context compose probe [parent: (self)]]

	mother: context [son: context probe compose [parent: (self)]]
mother: context [son: context probe compose [parent: (self)]]

etc..
kib2
27-Feb-2009
[2505x2]
ah...funny : nice example.
For the encoding, I was asking this because all my accented chars 
in HTML appear correctly but one, the "à".
Anton
27-Feb-2009
[2507]
Just move the probe from right to left to find out what's happening.