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

World: r3wp

[Rebol School] Rebol School

kib2
5-Mar-2009
[2596]
that does not work...even the print message does not appear. An idea 
?

monlayout: [
    origin 0x0 space 0x0 across
    ; --- define a new button (style)
    style p image %vide.png 
    style node image %but.png 
    effect [draw [line]] feel [ 
        engage: func [f a e /local x y island] [
            if a = 'over [
                print "over"
                x: round/down e/x / 40 + 1
                y: round/down e/y / 40 + 1
                island: game/:x/:y
                if island/ways <> none [
                    foreach v island/ways [

                        append f/effect/draw to-pair [x y] to-pair [v/x v/y] show f
                    ]
                ]
            ]
        ]
    ]
]
Geomol
5-Mar-2009
[2597]
The effect isn't attached to a style. You have style definitions, 
and then effect.
kib2
5-Mar-2009
[2598]
it isn't attached to the node style ?
Geomol
5-Mar-2009
[2599x3]
yes, but it's just a definition. Where is your buttons? :-)
Put extra p and node at the bottom of your momlayout.
*monlayout*
kib2
5-Mar-2009
[2602]
that changes nothing.
My buutons are appened at runtime like this :

out: copy []
foreach line hashi [
    foreach letter line [ 
        either (letter = "")
            [repend out ['p letter] ]
            [repend out ['node letter]] 
    ]
    repend out ['return]
]

then ... monlayout def  

then ...
 
append monlayout out
Geomol
5-Mar-2009
[2603]
Do you layout monlayout after this?
kib2
5-Mar-2009
[2604]
Yes, like this :
view center-face layout monlayout
Geomol
5-Mar-2009
[2605x2]
This works here:


myl: [style node image logo.gif effect [draw [line]] feel [engage: 
func [f a e] [if a = 'over [append f/effect/draw e/offset show f]]]]
append myl [node "my node"]
view layout myl
You have a simple bug somewhere, I guess. :-)
kib2
5-Mar-2009
[2607]
hum...the problem is actualy to know where !
Geomol
5-Mar-2009
[2608]
repend out ['return]
is overkill. Just write:
append out [return]
(notice without ' ) or
append out 'return
kib2
5-Mar-2009
[2609]
funny, if I change 'over to 'down I have something on screen.

But I just can't understand why I then got an error about Invalid 
path value: x
Near: x: round/down e/x / 40
Geomol
5-Mar-2009
[2610x2]
e/x -> e/offset/x
See: http://www.rebol.com/docs/view-system.html#section-5.9
kib2
5-Mar-2009
[2612]
Right, thanks.
PatrickP61
6-Mar-2009
[2613x2]
Quest to all:

What is the easiest / best way to convert a file path to a dir path?
Example
FILE-PATH: request-file	; assigns a specific file path
== %/C/Documents and Settings/Owner/filename.txt

How can I assign a variable like FILE-DIR: to become the directory 
of FILE-PATH  i.e.  %/C/Documents and Settings/Owner/ 
Ideas?
All I really need to do is truncate everything after the last "/" 
.. is that right?
kib2
6-Mar-2009
[2615]
Maybe just : first split-path %/C/Documents and Settings/Owner/filename.txt 
?
PatrickP61
6-Mar-2009
[2616x2]
I'll try it
Yes that worked, I was able to the following:
change-dir FILE-DIR
Thank you
kib2
7-Mar-2009
[2618]
Hi.
Here's my code : http://clojurepastebin.appspot.com/3001

I don't understand REBOL's behaviour here at the second step of the 
output.
I also saw that putting parenthesis like this:
s: s + (v/1 * v/2)

gave the right answer, but i wanted to know why operators priority 
were not applied correctly.
Geomol
7-Mar-2009
[2619x5]
Rebol evaluate from left to right. There is no operator priority. 
It's because of performance, I guess.
Also note, that infix operators (like + - * / etc.) are evaluated 
before prefix functions. So

random 4 + 5

is the same as

random (4 + 5)
And note, that things like = is also an operator.

>> if 3 = 1 + 2 [print 'ok]
** Script Error: Expected one of: logic! - not: integer!
>> if 1 + 2 = 3 [print 'ok]
ok
And operators can also be prefix, which looks kinda weird:

>> + 4 5
== 9
>> random + 4 5
== 2
List of operators:
>> ? op!
kib2
7-Mar-2009
[2624]
Geomol: sorry for the delay, it was lunch time for me.

It's the first langage where i see no operator priority (maybe with 
Lisp, but it's because of its notation).

Thanks, and that may explain why I wasn't able to draw something 
correctly in a GUI app.
BrianH
7-Mar-2009
[2625]
Having only a single level of operator precedence was done to make 
it faster to program in REBOL. It makes it easier to remember the 
precedence rules when reading or writing REBOL, something that anyone 
with experience in most programming languages can tell you is tricky 
at times. Having fewer language rules to remember makes the language 
less distracting from the programming process. Though it is also 
faster to run, as it makes DO simpler (and even moreso in R3).
kib2
8-Mar-2009
[2626x2]
BrianH: this seems a right approach to me, it makes sense.
How's responsible of Rebol wiki contents ?

The docs on R3 GUI (written by Kr bacon) are really pleasant to read.
PatrickP61
10-Mar-2009
[2628x2]
Question to all
How can I get the results of a PRINT to load into a block?
ie  File-list-blk: LIST-DIR
or File-Details-blk: LIST-DIR/L
Steeve
10-Mar-2009
[2630]
just overide print functions during a short time
PatrickP61
10-Mar-2009
[2631]
Can you give example such as getting the results of LIST-DIR/L?
Steeve
10-Mar-2009
[2632]
hmm... something like that

p: :print
out: []
print: func [v][append out reform v]
list-dir
print: :p
probe out
PatrickP61
10-Mar-2009
[2633]
ahhh, so you temporarily capture the source of PRINT into P
then clear a block called OUT
then change the print to append results to it,
then LIST-DIR will invoke the PRINT command to the new function
and reset PRINT back to original defintion.
Steeve
10-Mar-2009
[2634]
right
Dockimbel
10-Mar-2009
[2635]
You can also use this script : http://www.rebol.org/view-script.r?script=capture.r

do http://www.rebol.org/download-a-script.r?script-name=capture.r
capture on
list-dir
capture off
probe get-captured
PatrickP61
10-Mar-2009
[2636x2]
tried it out, but no luck, R3 is giving Script error: list-dir does 
not allow set-word! for it's 'path argument

I think I have to dig into the LIST-DIR a little more to see how 
it works

I had hoped there would be an easier way to take the results of a 
PRINT and be able to load it into a block instead of putting to the 
console.
Dockimbel, I'll give it a try
Steeve
10-Mar-2009
[2638]
it's because list-dir needs an argument not furnished in my example
PatrickP61
10-Mar-2009
[2639]
Thank Steeve and Dockimbel, I think I can play with it a little more
Dockimbel
10-Mar-2009
[2640]
If you use LIST-DIR in a script, you should provide the directory 
argument or enclose it with brackets like : do [list-dir]
Steeve
10-Mar-2009
[2641x2]
or list-dir %.
or (list-dir)
PatrickP61
10-Mar-2009
[2643]
good to know
PatrickP61
12-Mar-2009
[2644x2]
I'm playing around with FORM-DATE.R from the rebol.org site and I'm 
having trouble with a couple of commands

I am trying to define a new date-code of lowercase h to return the 
hour in regular time, not military time such that 13-24 would be 
1-12.

ie	#"h"	[PICK	[ time/hour  ( time/hour - 12 ) ]  time/hour > 12 ]		<-- 
pick the value of time/hour to be between 1-12
but when I try an example such as:

am: does [form-date 2009-01-02/03:04:05 "%y%m%d %h:%M%P"]	<-- I get 
 "090102 time/hour - 12:04AM"    hours is realy 03

pm: does [form-date 2009-11-12/13:14:15 "%y%m%d %h:%M%P"]	<-- I get 
"091112 time/hour:14PM"

how do I get r3 to evaluate the time/hour - 12 or the time/hour value 
before it picks the results?
I see a small error in my conditions, it should read  time/hour < 
12 instead of > 12