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

World: r3wp

[Rebol School] Rebol School

PatrickP61
6-Mar-2009
[2614]
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
[2644x5]
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
I will ask Christopher for his assistance,  I think this may not 
be the right forum to answer this question.
Please disregard my post.  I missed the fact that the upper case 
i handles this.
I guess I can answer my own question!  :-)
Vladimir
27-Mar-2009
[2649]
I guess this is the best place to ask this question:


I wrote many scripts in rebol that helped me a lot but they were 
all just that... small scripts (I think biggest of them all was 40-50 
lines...).

My question is, what would be "Rebol way" of writing more complicated 
applications in rebol ?

Stuff like game or accounting application, something with many parts....

What would be differences from other languages? And why would it 
be better? :)
What about dialects?

Should rebol programmer start with making a specific dialect first?
Chris
27-Mar-2009
[2650]
'Dialect' is a good term for what a dialect is, but 'Domain Specific 
Language' is perhaps a better indicator of the problems dialects 
solve.
Vladimir
27-Mar-2009
[2651]
ok... :) thats what I ment... 

So should one start from bottom, from basics? Like in in accounting 
"calculate tax for one item" and then make functions for all more 
complicated stuff ? something like that?
Sunanda
27-Mar-2009
[2652]
A dialect is a good way of structuring a user interface.

I think your question is more related to the underlying structure 
of the code that implements the whole application -- not just the 
dialect.. Does that sound about right?
Vladimir
27-Mar-2009
[2653x2]
Yes.... for example I used Visual Fox pro a lot... and its great 
for stuff like that... It has Separate concepts like Database, Data 
entry forms, Print reports etc....
Or, how to make writing apps simpler ?
Chris
27-Mar-2009
[2655]
It's similar I suppose to prototyping with a GUI, designing the front-end 
first and building the application to drive it.  I prefer working 
that way...
Vladimir
27-Mar-2009
[2656]
I used asm, basic, pascal, c, database, clipper, foxpro.......... 
I kinda know how to use those in an efficient manner.... 
What about rebol?
Henrik
27-Mar-2009
[2657]
Well, I tend to write a lot of small code files and string them together 
with a preprocessor.
Vladimir
27-Mar-2009
[2658]
Designing gui in rebol is quite simple, with rebgui even more....
So one aproach would be:
1. Make interface look like it shoud be
2. attach code to be executed on events
Henrik
27-Mar-2009
[2659]
I don't think there is a particularly REBOLish way to write large 
programs. You just figure out a reasonable way to do it.
Vladimir
27-Mar-2009
[2660]
:)
Chris
27-Mar-2009
[2661]
V: similar with dialects...
Vladimir
27-Mar-2009
[2662]
So no magic rebol wand to make it better than the rest ? :)
Henrik
27-Mar-2009
[2663]
actually there might be: generate REBOL code with REBOL.