[REBOL]
[1/14] from: sharriff::aina::med-iq::de at: 21-Nov-2000 11:21
I use forms to display my results in my simple Bulletin-Board, this
approach is not very "Space economical", i would like to output the output
in alternating background colours. Does anyone one have an algorithm that
alternates for a given value an output? example
bulletin: [ [article one] [article two] .......[article n ] ]
for every aticle print alternating table rows with diffrent colours
I have tried to peek the code in Free Bullein-boards but they were in PERL,
which I donīt speak at all.
Cheers
Sharriff Aina
[2/14] from: brett:codeconscious at: 21-Nov-2000 5:30
Re: (No subject)Date: Wed, 22 Nov 2000 00:30:29 +1100
row-colour: 'blue
for row 1 10 1 [
print row-colour
row-colour: either equal? row-colour 'blue ['black]['blue]
]
Brett.
g'nite...
----- Original Message -----
From: <[Sharriff--Aina--med-iq--de]>
To: <[rebol-list--rebol--com]>
Sent: Tuesday, November 21, 2000 10:21 PM
Subject: [REBOL]
I use forms to display my results in my simple Bulletin-Board, this
approach is not very "Space economical", i would like to output the output
in alternating background colours. Does anyone one have an algorithm that
alternates for a given value an output? example
bulletin: [ [article one] [article two] .......[article n ] ]
for every aticle print alternating table rows with diffrent colours
I have tried to peek the code in Free Bullein-boards but they were in PERL,
which I donīt speak at all.
Cheers
Sharriff Aina
[3/14] from: sharriff:aina:med-iq at: 21-Nov-2000 14:48
..err Brett, it took me so long to decide whether to ask, since I thought
it would be too embarrasing. But alas! no matter how hard I squint at this
snippet, the less I understand. I tried it out in the console, it works,
but the value that makes the "print" switch baffles me... either checks to
see if " row-colour " is eqaul to " 'blue
" right? but row-clour has already been passed the reference to 'blue so
it should always be true?????!!
Please bear with me
Sharriff Aina
med.iq information & quality in healthcare AG
"Brett Handley"
<[brett--codecons] An: <[rebol-list--rebol--com]>
cious.com> Kopie:
Gesendet von: Thema: [REBOL] Re: (No subject)Date: Wed, 22 Nov 2000 00:30:29
+1100
[rebol-bounce--re]
bol.com
21.11.00 13:30
Bitte antworten
an rebol-list
row-colour: 'blue
for row 1 10 1 [
print row-colour
row-colour: either equal? row-colour 'blue ['black]['blue]
]
Brett.
g'nite...
----- Original Message -----
From: <[Sharriff--Aina--med-iq--de]>
To: <[rebol-list--rebol--com]>
Sent: Tuesday, November 21, 2000 10:21 PM
Subject: [REBOL]
I use forms to display my results in my simple Bulletin-Board, this
approach is not very "Space economical", i would like to output the output
in alternating background colours. Does anyone one have an algorithm that
alternates for a given value an output? example
bulletin: [ [article one] [article two] .......[article n ] ]
for every aticle print alternating table rows with diffrent colours
I have tried to peek the code in Free Bullein-boards but they were in PERL,
which I donīt speak at all.
Cheers
Sharriff Aina
[4/14] from: chris:starforge:demon at: 21-Nov-2000 15:36
[Sharriff--Aina--med-iq--de] wrote:
> ..err Brett, it took me so long to decide whether to ask, since I thought
> it would be too embarrasing. But alas! no matter how hard I squint at this
<<quoted lines omitted: 3>>
> " right? but row-clour has already been passed the reference to 'blue so
> it should always be true?????!!
Go through it in the loop by hand:
start with row-colour: 'blue
print blue
row-colour equals 'blue so set row-colour to 'black
print black
row-colour is not equal to 'blue so set row-colour to 'blue
and so on...
Haven't seen one like that outside C or assembler though :) A lot of
people
prefer to do a modulo 2 on the loop counter and use a different colour
depending n whether the result is 0 or 1 (I failed a job test once
because
I used this sort of flip rather than a modulo, seems some people
consider
it a bit "dirty"..))
Chris
--
New sig in the works
Explorer2260 Designer and Coder
http://www.starforge.co.uk
[5/14] from: brett:codeconscious at: 22-Nov-2000 10:22
> Haven't seen one like that outside C or assembler though :)
How about Cobol? ;)
>A lot of people
> prefer to do a modulo 2 on the loop counter and use a different colour
> depending n whether the result is 0 or 1
If it were rotating through 3 or more colours or the number of bands was a
parameter then modulo is the way to go.
Then again it would probably look hideous :)
For this flexibility you pay the cost of a calculation plus a test and an
assignment.
Whereas the simple flag costs the test and an assignment.
Since it is a simple flag I should probably have used a logic rather than a
word like this
highlight-flag: true
for row 1 10 1 [
print highlight-flag
highlight-flag: not highlight-flag
]
> (I failed a job test once
> because
> I used this sort of flip rather than a modulo, seems some people
> consider
> it a bit "dirty"..))
Sounds like the employer failed :)
Flags have always been valid state variables - they've just been given a bad
name when used as examples of what not to do in object oriented programming.
They still have their uses.
Brett.
[6/14] from: gmassar::dreamsoft::com at: 21-Nov-2000 16:37
Another programmer's trick:
b: 1
for i 1 10 1 [print pick ['blue 'black] b: divide 2 b]
Try it!
Geo... an old timer
[7/14] from: al:bri:xtra at: 5-Dec-2000 15:01
[ALLY] -><-
Anton wrote:
> By the way, are you using the "cut-line" (at the end) with rebol (or
what?) I remember chatting about this ages ago...
-><-
in my signature, because I think it's a neat idea. It would be nice
if it worked. I must put it in my eText system to signal a earlier than
normal end of input.
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
[8/14] from: foodsafety:ains:au at: 11-Jan-2001 0:46
I was wondering how '? (or 'help) can take a word as an input without the
word or it's function being evaluated first. Rebol evaluates from
right-to-left as in:
>> return-string: does [ print "ABC" return " A string! "]
>> print trim return-string
ABC
A string!
In that example 'return-string is evaluated first (I think), then 'trim,
then 'print. So what about:
>> ? return-string
USAGE:
RETURN-STRING
DESCRIPTION:
(undocumented)
If this followed the same rule as before then the string "ABC" should have
been printed before the help text. Since '? isn't a native function I
can't see how it can break the standard convention. I thought
>> source ?
... would provide an answer but the output just confused the hell outta
me. I have tried to write functions like this in the past but never had
any success. Clearly my concecpt of the standard convention must be wrong.
Could somebody clarify it for me in plain english please.
SpliFF
[9/14] from: brett:codeconscious at: 11-Jan-2001 11:56
The trick is to use a literal notation for the parameter to the function
when creating the function.
>> myfunc: func[ 'uneval-param ][ print mold uneval-param ]
>> myfunc test
test
The literal notation ( a tick before the word) informs Rebol that we want
the parameter passed to the function literally as opposed to being evaluated
prior to passing into the function.
There maybe a better explanation in the manual. Just look for the section on
functions.
Brett.
[10/14] from: ryanc:iesco-dms at: 10-Jan-2001 18:33
Hi SpliFF,
Your answer is hidden in the source of these functions:
>> source help
help: func [
"Prints information about words and values."
'word [any-type!]
/local value args item name refmode types attrs rtype
] ....
>> source source
source: func [
"Prints the source code for a word."
'word [word!]
] ....
Notice that they ask for 'word literally, instead of just word. In the
function header "dialect" the literial notation ' has basically the same
meaning--dont evaluate. So instead of the parameter being evaluated before
assignment within the function, it is just grabbed as-is. Same effect as if
you had used a literal notation on the parameter itself.
To further demonstrate, we can look at the native function 'and:
>> source and
and: native [
"Returns the first value ANDed with the second."
value1 [logic! number! char! tuple!]
value2 [logic! number! char! tuple!]
]
Notice its values are not asked for literally, and therefore will be evaluated
prior to assignment internally within the function.
--Ryan
SpliFF wrote:
> I was wondering how '? (or 'help) can take a word as an input without the
> word or it's function being evaluated first. Rebol evaluates from
<<quoted lines omitted: 23>>
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
I am enough of an artist to draw freely upon my imagination.
Imagination is more important than knowledge. Knowledge is
limited. Imagination encircles the world.
-Einstein
[11/14] from: rebol:techscribe at: 10-Jan-2001 21:38
Hi SpliFF,
1. Try
>> print 1 print 2 print 3
You'll get
1
2
3
which goes to show that - as a rule - REBOL evaluates from left to
right, unless instructed to do otherwise. "Instructed to do otherwise"
is a little cryptic, so here goes:
>> return-string: does [print "ABC" return " A string! "]
>> print trim return-string
Left to right:
First print is evaluated. The word print evaluates to a function that
expects an argument. Aha. Let's fetch an argument for print, otherwise
we cannot complete the evaluation. The next token in the input stream is
the word trim. Now trim is evaluated. Hey, it's also a function, and the
trim function also requires an argument. This argument must be a string.
Let's look at the next token. The word return-string is evaluated. Oh
my, it's also a function. Let's evaluate that function. The
return-string function is now evaluated.
During the evaluation of the return-string function first the string
ABC
is printed, because the function is being evaluated from left to
right, and then return is evaluated, which is a function (actually a
value of type native!) that requires an argument of type any-type!
(any-type! includes the type unset! which is represented by no value,
i.e. f: does [return] - return here with no argument - is legal) that
returns the string " A string! ". (BTW, you do not *have* to use return
here, since the last value of a block is returned by default, i.e. f:
does [return "this"] is works the same as f: does ["this"]).
trim is passed " A string! " as its argument, it is successfullly
evaluated, and the result of evaluating it is passed to print.
Regarding ? using help would be more useful in your case. You will see
that ? is a function that expects a literal word ('word) as its
argument. When ? is evaluated REBOL looks attempt to interpret the next
token in the input stream as a word, and does not evaluate that word,
because ? wants a literal word, i.e. the word itself, and not its value.
So return-string is not evaluated, instead the literal word
return-string is passed to ?.
Hope this helps,
Elan
SpliFF wrote:
[12/14] from: ptretter:norcom2000 at: 20-Jan-2001 17:12
We have now established chat on #rebol on EFNET on IRC. Also anyone know when QNX version
of /core experimental will be extended or new one released the other one is expired.
Paul Tretter
[13/14] from: alanwall:sonic at: 20-Jan-2001 19:53
Hello Paul
On 20-Jan-01, Paul Tretter wrote:
> We have now established chat on #rebol on EFNET on IRC. Also anyone know
> when QNX version of /core experimental will be extended or new one
> released the other one is expired.
>
> Paul Tretter
>
Not sure as to your ? but wanted the list to know that a newer version of
QNX RTOS is out
Regards
--
In God we trust... all others we voice verify.
-- Scherker
JMS Trustee http://www.jms.org
HP=http://www.sonic.net/~alanwall/
First computer solar powered vic-20
AmigaQNX-notAmigaNG=no good
computers for people not suits
sent via Yam ver2.2 on AmigaForever verIV
Be a Rebel get Rebol@ rebol.com
UIN#=9391028
[14/14] from: agem:crosswinds at: 24-Feb-2001 7:27
[rebol [
title:
"proposal for passing refinements"
comment: {
hi all,
i suggest following syntax:
[ a-func/opt/:bool 123 ]
where opt and its arguments are passed if 'bool is true.
a sample implementation is presented here, which may be used
in the way
[do refined[ a-func/opt/:bool 123 ]]
note this handles passing arguments ..
an inbuild syntax would be preferable..
also i suggest using
[ a-func/'opt 123 ]
if 'opt and 'bool are the same name.
not implemented yet.
would be nice if you test a bit more, baby is 1:30 old yet :)
}
author: "volker"
]
refined: func [block
/local val in-args part-args length-part-args option
append-part count-part-args func-args rfunc options
out-path out-args in-path
] [
in-path: to block! first block
in-args: next block
out-args: copy []
out-path: reduce [first :in-path]
options: next in-path
rfunc: get first in-path
func-args: first :rfunc
;handle normal arguments
parse func-args [copy normal-args to refinement!]
append out-args copy/part in-args length? normal-args
in-args: skip in-args length? normal-args
;handle options
count-part-args: func [func-args option /part-args] [
option: to refinement! option
parse func-args [thru option copy part-args [to
refinement! | to end]]
either part-args [length? part-args] [0]
]
append-part: does [
append out-path option append out-args part-args
]
parse next :in-path [any [
set option word!
(
length-part-args: count-part-args func-args option
part-args: copy/part in-args length-part-args
in-args: skip in-args length-part-args
)
[
set val get-word! (
if get val [append-part]
)
|
(
append-part
)
]
]]
append reduce [to path! out-path] out-args
]
do example: [
a: func [p1 p2 /opt o1 /opt2 o2 /opt3] [? p1 ? p2 ? o1 ? o2]
source a
b: none
e: true
raw-call: [a/opt/:b/opt2/opt3/:e 123 234 345 456 567]
? b ? e ? raw-call
refined-call: refined raw-call
? refined-call
print "do it"
do refined-call
]
]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted