Re: Correct syntax for case?

Subject: Re: Correct syntax for case?
From: Heiko Kirschke <Heiko.Kirschke@xxxxxxx>
Date: Tue, 28 Apr 1998 12:25:41 +0200
Georg,

  > I have a couple of (if ...)s in a DSSSL script to trigger different
  > styles for different values of an attribute, looks like this:
  > 
  > (element paragraph
  >         (if (equal? (attribute-string "FKT") "P")
  >           (make element gi: "P")
  >           (if (equal? (attribute-string "FKT") "H1")
  >             (make element gi: "H1" attributes: *heading-style*)
  >             (if (equal? (attribute-string "FKT") "H2")
  >               (make element gi: "H2" attributes: *heading-style*)
  >               (if (equal? (attribute-string "FKT") "H3")
  > 		[...]

  > Of course, this code is a pain in the neck and the only reason for
  > not using "case" is that I wasn't able to figure out what the correct
  > syntax for "case" is. So, can someone provide me with a rough blueprint
  > of the above code in "case"-style?

(case (attribute-string "FKT")
  (("P") (make element gi: "P"))
  (("H1") (make element gi: "H1" attributes: *heading-style*))
  (("H2") (make element gi: "H2" attributes: *heading-style*))
  (else ...))

In this special case, I would prefer:

(let ((attr (attribute-string "FKT")))
  (case attr
    (("P") (make element gi: "P"))
    (("H1" "H2" "H3") (make element gi: attr attributes: *heading-style*))
    (else (error "Unexpected value for FKT attribute"))))

Viele Gruesse, Heiko
--
Heiko Kirschke             EMail: Heiko.Kirschke@xxxxxxx
POET Software GmbH         Web:   http://www.poet.de/
Fossredder 12              Tel:   +49 40 60990-263
D-22359 Hamburg            Fax:   +49 40 60990-115


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • Correct syntax for case?
    • Georg Rehm - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id FAA10714Tue, 28 Apr 1998 05:45:45 -0400 (EDT)
      • Heiko Kirschke - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id GAA11198Tue, 28 Apr 1998 06:34:16 -0400 (EDT) <=