What do you guys think of a good old fashioned case statement?


case: func [
  "If condition block is true, evaluates subsequent block."
  cases [block!] "Block alternating with conditions blocks and action
blocks"
 /default
 default-case [block!] "Default case if no others found."
] [
  forskip cases 2 [
    if do first cases [
      return do first next cases
    ]
  ]
  either default [ do default-case ][ none ]
]


a: 1
b: 2
c: 3

confirm case [
  [ c = a ] [ probe "C = A" ]
  [ a = b ] [ probe "A = B" ]
  [ a = ( b + c ) ] [ probe "A = B + C" ]
  [ c = ( a + b ) ] [ probe "C = A + B" ]
]


a: 11
b: 200
c: 32

confirm case/default [
  [ c = a ] [ probe "C = A" ]
  [ a = b ] [ probe "A = B" ]
  [ a = ( b + c ) ] [ probe "A = B + C" ]
  [ c = ( a + b ) ] [ probe "C = A + B" ]
] [ probe "default" ]


--Ryan


     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


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to