home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / lout2.lzh / LOUT2 / DOC / TR.LOUT / ch3.15 < prev    next >
Text File  |  1994-01-25  |  2KB  |  49 lines

  1. @Section
  2.    @Title { "@Case" }
  3.    @Tag { case }
  4. @Begin
  5. @PP
  6. case.sym @Index { @@Case symbol }
  7. yield.sym @Index { @@Yield symbol }
  8. The @@Case symbol selects its result from a list of alternatives,
  9. depending on a tag:
  10. @ID @Code {
  11. "@Day @Case {"
  12. "    { 1 21 31 }  @Yield  st"
  13. "    { 2 22 }  @Yield  nd"
  14. "    { 3 23 }  @Yield  rd"
  15. "    else  @Yield th"
  16. "}"
  17. }
  18. In this example the result will be st if @Code "@Day" is 1, 21, or 31,
  19. and nd if @Code "@Day" is 2 or 22, etc.  The effect is similar to
  20. accessing a database, though in a more compact form.  The right parameter
  21. is a sequence of @@Yield symbols, each with a left parameter whose value is
  22. a sequence of one or more juxtapositions of simple words, and a right
  23. parameter which may be any object.
  24. @PP
  25. We first describe the behaviour when the value of the left parameter of
  26. @@Case is a juxtaposition of one or more simple words.  Then the result of
  27. the @@Case is the right parameter of the first @@Yield whose left parameter
  28. contains either the value of the left parameter of the @@Case, or the special
  29. value {@Code else}.  If there is no such @@Yield it is an error.
  30. @PP
  31. When the left parameter of @@Case is not a juxtaposition of simple
  32. words, the result is the right parameter of the first @@Yield whose
  33. left parameter is {@Code else}, or an error otherwise.  This permits
  34. examples like
  35. @ID @Code {
  36. "@RunningTitle @Case {"
  37. "    dft @Yield @Title"
  38. "    else @Yield @RunningTitle"
  39. "}"
  40. }
  41. where a running title is returned unless it has the value {@Code dft}
  42. (which presumably means that no running title was supplied), in which
  43. case an ordinary title is returned instead.
  44. @PP
  45. When a receptive symbol is placed within a @@Case, it should be included
  46. in each alternative, since otherwise Basser Lout may become confused when
  47. trying to predict whether the symbol will be a part of the result or not.
  48. @End @Section
  49.