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

World: r3wp

[Rebol School] Rebol School

Henrik
5-Mar-2009
[2576]
for R3 there will also be information about whether the function 
modifies the input. that would be useful as well.
kib2
5-Mar-2009
[2577]
hum... I've made some rules in my OO calc sheet to set some styles 
(ie color a line on two), and if I had native/mezzanines it will 
break all.
I've to find an issue.: maybe add a column for that.
Henrik
5-Mar-2009
[2578]
Actually there are also action! types, which are related to natives.

Perhaps one-letter identification in a separate column:

N = Native, A = Action, F = Function, M = Modifies Input, etc.
kib2
5-Mar-2009
[2579]
Ok, great suggestions !
Henrik
5-Mar-2009
[2580]
it's probably a good idea to keep separate sheets for R2 and R3, 
since some functions have moved from mezzanine to native and vice 
versa in R3.
Geomol
5-Mar-2009
[2581x2]
I'm wondering, if it's important for a newbie to the language to 
distinguish between natives, actions and functions. Wouldn't it just 
confure more?
Even as an experienced REBOL programmer, I seldom look at those things. 
It's only in cases, where I need utterly performance, or if I wanna 
see, what some function does.
kib2
5-Mar-2009
[2583]
CheatSheet Updated to v1.2 .

Geomol: that makes sense to me, but sure that may be confusing. But 
it's not a problem on this sheet, just don't take the second column 
into account.
Geomol
5-Mar-2009
[2584x2]
Looks good! :-)
Maybe (follow) should be (continued)? What does the english-speaking 
here say?
Brock
5-Mar-2009
[2586]
Can the two Series blocks not be combined into one list on the right 
side of the page?
kib2
5-Mar-2009
[2587x3]
Brock: yes, I already had that in mind. Next release :)
Brock : done!
Is it possible to draw something inside an over function  (in a GUI 
app) ?
Geomol
5-Mar-2009
[2590x5]
If I understand you correct, then I do that in Canvas RPaint, so 
yes. Have you tried that paint program?
view layout [box 400x400 effect [draw [line]] feel [engage: func 
[f a e] [if a = 'over [append f/effect/draw e/offset show f]]]]

Try paint with the mouse.
Ups, was that a one-line paint program? ;-P
*Ops*
There's a lot of REBOL One-liners here, you might find amusing:
http://www.rebol.com/oneliners.html
kib2
5-Mar-2009
[2595x2]
Geomol: thanks, that will be a lot more complicated for my case.
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).