[Seaside] S-Expr conditionals

Jim Benson jb@speed.net
Sat, 1 Jun 2002 13:17:04 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_02C2_01C2096E.9F272330
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

So I started building my little calendar/to do list app, and I realized I
had no clue as to how to do conditionals. After several iterations (to avoid
my further embarrassment, I won't show the mess I made :-), I'll just ask
here how to do this.

I have a calendar with all the days of the month. Some of the days have
special attributes, that I would like to show as a different color for the
background of the day. To build the calendar table, I write as my #html
method:

html
^ #(
 b '  ' '[date.monthName]' ' ' '[date.year.printString]'
 ( table width: '60' border: '0' height: '60'
 " calendar header "
 ( tr
     ( td repeat: '@nameOfDay/dayNames'
    bgcolor: '000066' ( font color: 'ffffff' '[nameOfDay]' ))
 )
" days of the month "
 ( tr repeat: '@week/weeks'
  ( td repeat: '@aDay/week'
    bgcolor: 'ffff99'
    ( div align: center (font color: '000000' '[aDay.dayOfMonth]')))
 ))
)

As an example, what I would like to do in the days of the month area [ tr
repeat: @week/weeks ] bgcolor: is to say something like

 [ Equivalent Squeak saying ]

    backgroundColor :=
            ( aDay = Date today ) ifTrue: [ 'ff0000' ] ifFalse: [
'ffff99' ].
    self bgcolor: backgroundColor.

    and set the background color of the calendar entry to match.

I thought that I could do that using
        ( if .... )
    but I couldn't figure out how to do it.

Jim Benson

PS: find attached the entire calendar subcomponent, just in case

------=_NextPart_000_02C2_01C2096E.9F272330
Content-Type: application/x-gzip;
	name="RVCalendar.st.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="RVCalendar.st.gz"

H4sIAAAAAAAAAKVU30/bMBB+9oP/h0NIc/tAmpa1g+5lExXSkBgSneABFeQm18QjsTPbBXXqH7+z
Q+hAYnvAqtyz79f33Z0jTq2pYf5rjfL+MBkVsq4lmBUMx3Am9VraDYzSdAQ3lfToPKybnIQp7H88
Gn9agNEwhLO1xtZKehiOpuNj+kFTiz3+7euJqRujUXtw62VWSefI+fLqRFaoc2k5U9p5qTO8klbJ
ZYXfZY1kI0IeqI32JQjOoudrE7pvjKlmKvPKaFJ2txn5FsZu6DRH6VSOB5eUDh/M2h3MCUcHyhFG
vreDAzX60uTu1FjylVmGzildCCCMdUNXP6slTAbDQaQbuA4pQlsSOaM/ziLuu/aUcNYyuIPz+L+i
as+idTDbg/dkT9Pp4SRm38SCcHYL+z1ivBYgzg1tP4J0jUEqaTu1tM2lF9Dn70vdEY/kiHkkt+Pa
npP350gpxyPiPXHbQhSulS9ncuPiKQpbzl5q7uDC5mgxPzFVhXE0QONj1wvOGMqsvA7+Zgo3UxlE
2AIp2HPUt4MwFh2CwPI2AHnAdodI5nmchs0i6WLu0EVlZxoMbl8Si0V7u2pKK69kpX7jgcWKZhv/
Ub4xlW/nwJnDagXtsIq/nq0A6Z6mNZbCm6KocO6l9dRIGq+E8//A8lg38QvxNprDI0JT+rriYUw5
W4L4oJeu+Qw0lTcBVRL7E2Z5ITrls26D0iaNVdrPPe3Fgp55D3z4HMCjysMYikkqYGlC3+hAcomq
KH2riNYWONAKYg4WG5RB+0VTyosVVX/QvSUR27ssMlNFfimtyURAD1aEEbrrVVwB43MIgt7vc9bn
Twl3WUKbB7HXIforCGFcolLAq9Qhw/FxC6gHuXoA6mahp5DR9wst9F4gSuMKiELEhPhcrOJrXIh+
iwv6jPF+29E/b6uezf4FAAA=

------=_NextPart_000_02C2_01C2096E.9F272330--