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

World: r3wp

[Rebol School] Rebol School

Geomol
25-Feb-2009
[2425x4]
a: [0] simply mean, a become this block with zero inside, if a isn't 
already this block. If a already is this same block, this same part 
of memory, it has no effect. To always make a block with zero inside, 
you need to use COPY or REDUCE.
I was often confused by this, I remember.
When you get used to it, it's pretty smart.
This is only within functions. If you write a: [0] at the console 
prompt, a become a new block with zero inside (you typed a new block, 
so it isn't the same, and it kinda makes sense). :-)
kib2
25-Feb-2009
[2429]
>> print abc
** Script Error: abc has no value
Ok, no problem I understand

>> print <abc>
<abc>
Why does this work ?
Geomol
25-Feb-2009
[2430x2]
abc is seen as a word, and it doens't have a value. <abc> is a tag! 
datatype, like "abc" is a string datatype:
>> type? <abc>
== tag!
and it also is a series, like strings are series:
>> second <abc>
== #"b"
kib2
25-Feb-2009
[2432]
Geomol: I wasn't aware there was a tag type !
Henrik
25-Feb-2009
[2433x2]
kib2:

build-tag [img src dot.gif]
kib2, to see all types:

? datatype!
kib2
25-Feb-2009
[2435]
Really useful : thanks !
Geomol
25-Feb-2009
[2436]
I've forgot, what a symbol! datatype is!?
kib2
25-Feb-2009
[2437]
s there any 'Challenge' channel for submitting a problem ?
Geomol
25-Feb-2009
[2438]
Puzzles
kib2
25-Feb-2009
[2439]
Geomol: ok, thanks.
Geomol
25-Feb-2009
[2440x2]
And answers go to Puzzle Answers
And people expect rewards. ;-)
kib2
25-Feb-2009
[2442x2]
All my gratitude !
I already solved it, but it's not nice (and maybe faulty)
PatrickP61
25-Feb-2009
[2444x5]
Another question:  How do you setup Rebol code to be performed when 
a button is pressed?

Lets say I want a VID to show a list of websites to open to, and 
I set the default to HULU.
I have the following to setup the correct url:
 k-prefix:	[http://www.]
k-suffix:	[.com]
txt-site:	[hulu]
url-site:	to-url ajoin [k-prefix txt-site k-suffix]
OK, that works when I do a browse url-site
But when I put it after a button like this:
    group [

        button "Open"	browse url-site    <-- this code works only if it is 
        done before the VIEW  
        button "Reset" 	reset 
        button "Cancel"	close
I tried to replace the browse url-site with
browse to-url ajoin [k-prefix txt-site k-suffix]   to no avail.

Is there a way to "predefine" the code above the VIEW so that when 
the button is pressed, it will perform the desired task like

button "Open"    format-and-browse-site    <-- where this has been 
set to do the url-site assignment and browse funtions?
I'm guessing this may have something to do with the DO , DOES, REDUCE, 
or other such functions
Henrik
25-Feb-2009
[2449]
Is this R2 or R3?
PatrickP61
25-Feb-2009
[2450]
R3
Henrik
25-Feb-2009
[2451]
button "Open" do [browse url-site]

I think.
PatrickP61
25-Feb-2009
[2452]
Hi Henrik,

This issue is not when to do the browse, that works, but when the 
url-site is properly assigned.
Henrik
25-Feb-2009
[2453]
I'm not sure what you mean.
PatrickP61
25-Feb-2009
[2454x4]
Try this:
REBOL []
; Assignments ------------------------------------
k-prefix:	[http://www.]
k-suffix:	[.com]
txt-site:	[hulu]
url-site:	to-url ajoin [k-prefix txt-site k-suffix]

; Main-procedure ---------------------------------
load-gui
view [
    title "WebSite Selector" 
    text "Please choose a website you would like to open" 
    panel 2 [
        label "URL:" 
        txt-site: field "Hulu"
        label "WebSites:" 
        area 
    ] 
    group [
        button "Open"	browse url-site 
        button "Reset" 	reset 
        button "Cancel"	close 
]	]
When you press Open, it will open the browser to Hulu.com
But I need to modify the code so that I can change the HULU to another 
site like GOOGLE
So, I need to replace button "Open" browse url-site with something 
that will evaluate the url-site AT THAT TIME, rather than what I 
have it defaulted to
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
[2474]
construct doesn't work in this case, because then input-file just 
become the word READ.