ahhh something I got a long time to "GET"

someone with more academic qualities (and more time) will be able to explain better, 
but quickly, you must put any computed values AFTER the operator, or 'IF (and 'EITHER) 
will use the words after the operator as the block to execute.

example:

if length? TEST-BLOCK < 4 [
     print "block too short"
 ]

becomes (in non rebol syntax):

 if (lenght? test-block) == true then do 4


in other words, the operator is not part of the expression being evaluated.

you have to do this instead:

if 4 >= length? TEST-BLOCK [
     print "block too short"
 ]


OR use parenthesis to properly encapsulate the complete expression:

if (length? TEST-BLOCK < 4) [
     print "block too short"
 ]


the first method is prefered, because I have read that grouping expressions in 
parenthesis slows down evaluation (but I have never tested this myself).

but if a microscopic speed difference is not a problem, then the second fix is usually 
more readable.


HTH

-MAx
---
"You can either be part of the problem or part of the solution, but in the end, being 
part of the problem is much more fun."
 

> -----Original Message-----
> From: Steven White [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 20, 2003 12:28 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Apparent newbie question
> 
> 
> 
> This must be something dumb, but I want to test the length of a block
> and can't seem to do it, yet I can print the length of the 
> block.  What
> am I missing?
> 
> Thank you.
> 
> *_*_*_*_* Sample script *_*_*_*_*
> 
> REBOL [ ]
> 
> TEST-BLOCK: [ XXXXXXXX  YYYYYYYYY  100  200 ]
> 
> print ["Length of TEST-BLOCK is " length? TEST-BLOCK]
> 
> if length? TEST-BLOCK < 4 [
>     print "block too short"
> ]
> 
> *_*_*_*_*_ Result of running test script *_*_*_*_*
> 
> >> do %lentest.r
> Length of TEST-BLOCK is  4
> ** Script Error: Expected one of: block! - not: integer!
> ** Where: halt-view
> ** Near: if length? TEST-BLOCK < 4
> >>
> 
> *_*_*_*_* End of test results *_*_*_*_
> 
> 
> 
> Steven White
> City of Bloomington
> 1800 W Old Shakopee Rd
> Bloomington MN 55431-3096
> USA
> 952-563-4882 (voice)
> 952-563-4672 (fax)
> [EMAIL PROTECTED]
> -- 
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.
> 
> 

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to