Newbie question...
[1/11] from: ronald:gruss:libertysurf at: 6-May-2001 11:41
Hi everybody,
I'm very happy to learn Rebol, and I appriciate the work of all of you. The list is really
dynamic and the feedbacks are interresting.
As a Newbie, I'm trying to write some lines that Rebol could understand ! ;-)))
My script tries to let the user choose a list of words and to make these words appear
in a random order, at request. I tested the script whith a single block and it worked.
But now, why do I get "none" at each request ? Could anybody give me some help ?
random/seed now
menulistes: []
liste_d: copy/deep [
"Moi et famille" [main genou pied tête nez cheveux orteil oreille bras
pouce jambe oeil]
"Objets" [chaise fenêtre baignoire fourchette lait table four canapé
porte lit réfrigérateur]
"Objets personnels" [camion bol cuillère chaussures pyjama "brosse à
dents" oreiller balle nounours accordéon]
"Aliments" [jus pain orange pâtes gâteau fraise viande raisin pomme
carotte banane fromage purée]
"Animaux" [poule cochon cheval souris lion hyppopotame serpent oiseau
dauphin phoque baleine]
]
liste_d: to-block liste_d
choix: first liste_d
forskip liste_d 2 [append menulistes to-string first liste_d]
menulistes: sort menulistes
lecture: func [bl] [to-string pick bb: to-block pick bl 6 random length?
bb]
view center-face lay: layout [
backdrop effect compose [gradient 1x1 (sky) (water)]
across
t: text red ivory 900x300 center font-size 130 ""
return
r: field wrap ivory 900x250 center font-size 100 font-color blue ""
return
button 680x100 effect [gradient 200.0.0 0.200.0] font-size 25 "Suivant"
[t/text: lecture liste_d show t]
text-list 200x100 data menulistes [ t/text: lecture liste_d show t ]
;choix: face/picked
return
]
Ronald Gruss
[2/11] from: gjones05:mail:orion at: 5-May-2001 5:36
From: "Libertysurf"
<snip>
> My script tries to let the user choose a list of words
<<quoted lines omitted: 37>>
> ]
> Ronald Gruss
Hello, Ronald,
The simple answer most is that 'forskip causes 'liste_d to point to the tail
of the
block. This word has to be reset to point to the head. This behavior is
also true
for 'forall. However, 'foreach does not have this behavior.
As a side note, when liste_d is first defined, copy/deep is not required,
since
the word points to that literal block.
Here is a revised listing with comments that point to the areas mentioned
above:
random/seed now
menulistes: []
;;;; copy/deep not really needed here
liste_d: copy/deep [
Moi et famille
[main genou pied tête nez cheveux orteil oreille bras pouce
jambe oeil]
Objets
[chaise fenêtre baignoire fourchette lait table four canapé porte
lit réfrigérateur]
Objets personnels
[camion bol cuillère chaussures pyjama "brosse à dents"
oreiller balle nounours accordéon]
Aliments
[jus pain orange pâtes gâteau fraise viande raisin pomme carotte
banane fromage purée]
Animaux
[poule cochon cheval souris lion hyppopotame serpent oiseau
dauphin phoque baleine]
]
liste_d: to-block liste_d
choix: first liste_d
forskip liste_d 2 [append menulistes to-string first liste_d]
;;;; forskip causes liste_d to point to tail of block - needs to be reset to
head
liste_d: head liste_d
menulistes: sort menulistes
lecture: func [bl] [to-string pick bb: to-block pick bl 6 random length? bb]
view center-face lay: layout [
backdrop effect compose [gradient 1x1 (sky) (water)]
across
t: text red ivory 900x300 center font-size 130 ""
return
r: field wrap ivory 900x250 center font-size 100 font-color blue ""
return
button 680x100 effect [gradient 200.0.0 0.200.0] font-size 25 "Suivant"
[t/text: lecture liste_d show t]
text-list 200x100 data menulistes [t/text: lecture liste_d show t]
;choix: face/picked
return
]
Hope this helps.
--Scott Jones
[3/11] from: gchiu:compkarori at: 5-May-2001 22:58
On Sun, 6 May 2001 11:41:57 +0200
"Libertysurf" <[ronald--gruss--libertysurf--fr]> wrote:
> But now, why do I get "none" at each request ? Could
> anybody give me some help ?
Try this, and watch out for line wrapping...
rebol []
random/seed now
menulistes: []
liste_d: copy/deep [
"Moi et famille" [main genou pied tête nez cheveux orteil
oreille bras pouce jambe oeil]
"Objets" [chaise fenêtre baignoire fourchette lait table
four canapé porte lit réfrigérateur]
"Objets personnels" [camion bol cuillère chaussures
pyjama "brosse àdents" oreiller balle nounours accordéon]
"Aliments" [jus pain orange pâtes gâteau fraise viande
raisin pomme carotte banane fromage purée]
"Animaux" [poule cochon cheval souris lion hyppopotame
serpent oiseau dauphin phoque baleine]
]
choix: first liste_d
foreach [ title datablock ] liste_d [append menulistes
title]
menulistes: sort menulistes
lecture: func [ value [string!] ] [
bl: first next find liste_d value
pick bl random ( length? bl )
]
view center-face lay: layout [
backdrop effect compose [gradient 1x1 (sky) (water)]
across
t: text red ivory 900x300 center font-size 130 ""
return
r: field wrap ivory 900x250 center font-size 100
font-color blue ""
return
button 680x100 effect [gradient 200.0.0 0.200.0] font-size
25 "Suivant"
[t/text: lecture liste_d show t]
text-list 200x100 data menulistes [ t/text: lecture value
show t ]
;choix: face/picked
return
]
--
Graham Chiu
[4/11] from: gchiu:compkarori at: 6-May-2001 19:25
> lecture: func [ value [string!] ] [
> bl: first next find liste_d value
> pick bl random ( length? bl )
> ]
Just remembered about 'select
lecture: func [ value [string!] ] [
bl: select liste_d value
pick bl random ( length? bl )
]
--
Graham Chiu
[5/11] from: ronald:gruss:libertysurf at: 7-May-2001 22:37
Thanks Graham, It works and the code is easier to understand.
--
Ronald Gruss
[6/11] from: cyoungbl:legato at: 3-Aug-2001 11:37
Hello. I decided that as my first experience with REBOL, I want to create a
simple chess game. I'm in the process of creating the chess board. Here is
the code I'm using:
mylayout: [
across
space 0x0
]
loop 4 [
loop 4 [
append mylayout [ box red 50x50 ]
append mylayout [ box black 50x50 ]
]
append mylayout 'return
loop 4 [
append mylayout [ box black 50x50 ]
append mylayout [ box red 50x50 ]
]
append mylayout 'return
]
view layout mylayout
This works, but can somebody tell me if this is the "REBOL way" of doing
things? Is there a more efficient way of accomplishing the same thing?
Thanks,
Carl Youngblood
[7/11] from: cyoungbl:legato at: 3-Aug-2001 11:42
Oops, I mean "checkers"...
[8/11] from: jelinem1:nationwide at: 3-Aug-2001 13:53
; Using the approach you've given, I'd define words for the red and black
squares, since they are used twice each, like thus:
blksqu: [ box black 50x50 ]
redsqu: [ box red 50x50 ]
; then say:
append mylayout blksqu
append mylayout redsqu
; Not anymore "REBOL", really, just eliminating repeated literals. To
stretch the idea you could say:
blksqu: [ box black 50x50 ]
redsqu: [ box red 50x50 ]
blk-red: load reform [redsqu blksqu]
red-blk: load reform [blksqu redsqu]
mylayout: [across space 0x0]
loop 4 [
append mylayout load reform [red-blk red-blk red-blk red-blk
'return]
append mylayout load reform [blk-red blk-red blk-red blk-red
'return]
]
view layout mylayout
; I don't know of another way to "flatten" a list of blocks other than
using "load reform". Convoluted in that I may as well be using strings in
the definition of blksqu and redsqu instead of blocks of words. I wouldn't
say this is any better than the more straight-forward method you provided.
{Michael}
Carl Youngblood <[cyoungbl--legato--com]>
Sent by: [rebol-bounce--rebol--com]
08/03/01 12:37 PM
Please respond to rebol-list
T
To: [rebol-list--rebol--com]
cc:
bcc:
Subject: [REBOL] Newbie question
Hello. I decided that as my first experience with REBOL, I want to create
a
simple chess game. I'm in the process of creating the chess board. Here
is
the code I'm using:
mylayout: [
across
space 0x0
]
loop 4 [
loop 4 [
append mylayout [ box red 50x50 ]
append mylayout [ box black 50x50 ]
]
append mylayout 'return
loop 4 [
append mylayout [ box black 50x50 ]
append mylayout [ box red 50x50 ]
]
append mylayout 'return
]
view layout mylayout
This works, but can somebody tell me if this is the "REBOL way" of doing
things? Is there a more efficient way of accomplishing the same thing?
Thanks,
Carl Youngblood
[9/11] from: ptretter:charter at: 3-Aug-2001 14:50
Seems to me that there is gonna have to be a bit more detail to this so that
code can equate to the movement functions of the chess pieces.
Paul Tretter
[10/11] from: cyoungbl:legato at: 3-Aug-2001 14:03
Yeah, I know. I'm __really__ new to REBOL so I'm just trying to draw the
checker board at the point. BTW, I meant to say "checkers", not "chess".
Thanks,
Carl Youngblood
[11/11] from: g:santilli:tiscalinet:it at: 4-Aug-2001 14:41
Hello [JELINEM1--nationwide--com]!
On 03-Ago-01, you wrote:
J> blksqu: [ box black 50x50 ]
J> redsqu: [ box red 50x50 ]
J> blk-red: load reform [redsqu blksqu]
J> red-blk: load reform [blksqu redsqu]
blk-red: insert insert [] redsqu blksqu
or
blk-red: compose [(redsqu) (blksqu)]
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted