Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

using "if" in CityScript

To get an idea of why CityScript's new if-statement is so great, consider the following problem. If you look around at the pages on my site, you'll notice that a sidebar appears on the right side of most articles. But only when I feel like it.

Brian St. Pierre
Friday, March 15, 2002

I wish I could do something like this:

{$ foreach x in (all) $}
    {$ if blank ( {$$} = {$.link$} ) $}
      A href="{$$}" {$x.headline$} /A
{$ next $}

Where blank = False and nonBlank = True, but CityDesk doesn't like what I'm testing for blank :(


Rod Kratochwill
Friday, March 15, 2002

I see what you're trying to do but you can't do it :(

You're overestimating the power of CityScript... it doesn't really evaluate expressions.

Joel Spolsky
Friday, March 15, 2002

Perhaps I'm really just missunderestimating the power :)

Rod Kratochwill
Friday, March 15, 2002

Whoops. Page moved (or got truncated somewhere along the way):

Brian St. Pierre
Tuesday, March 26, 2002

It would really be great if the "if" statement would have at least the power of the foreach statement.

My problem: I want a what's new page that show all the articles for the last X days from either my Articles folder or my Downloads folder. I want these sorted by the date they were posted regardless of which folder the partcular listing came from. No problem so far.

As a hint to the visitor, I'd like to have an image indicating what the link points to, a document or a file. How? Right now I'm thinking of copying the magic name for the image into one of the Extra fields but that means that every article will have the magic name in it -- God help me if I ever change the image!

Thom R
Tuesday, April 2, 2002

OK, 5 minutes later ... I guess it would save a BUNCH of work to just put the link in a variable and then put the variable in the Extra field. 

Thom R
Tuesday, April 2, 2002

*  Recent Topics

*  Fog Creek Home