[pmwiki-users] ZAP conditional syntax

The Editor editor at fast.st
Thu Mar 8 13:30:28 CST 2007

On 3/8/07, Ben Stallings <ben at interdependentweb.com> wrote:
> Dan wrote,
> I had previously suggested using standard ?: syntax, like so:
> (:zap field="condition ? true value : false value":)
> with spaces surrounding the ? and : to distinguish them from punctuation.

Ah!  Hadn't thought about the spaces.  That would work!

Of course if I did the following I might be able to get it to work
with existing markups also.  Not sure how necessary that is to
maintain downward compatibility...

(:zap if="condition||field=value , field=value , field=value":)

> But now that you're talking about assigning multiple fields on a single
> condition, I suggest something more like
> (:zap if="condition ? field1=value1, field2=value2 : field1=value3
> field2=value4":)

This is quite good.  The one before the : is the true and the one
after is the false.  Wow!  love it.  Think I'm sold.

> or even
> (:zap condition="condition" fields="field1,field2" true="value1,value2"
> false="value3,value4":)

This is more problematic as the current markup only allows one string
to be passed in connected with the if field, unless I develop a whole
new markup...  Not preferable.

> In any case I think it's important to keep the meanings of punctuation
> clear in users' heads: = means assignment, comma separates items in a
> list, || means or (or a table boundary), and | means a label.

Yes I'm convinced.  I tried to consistently use |'s to separate
parameters in ZAP which is how they got slipped into the conditionals,
but there are enough problems with them in this case, I need to do
something different.

> (And then there's what :) means to 99% of the Internet-using public.
> Some of my users insist on calling PmWiki directives "smileys."  Maybe
> we should call them that, too.)
> The ?: syntax is common among dozens of programming languages, and it
> can be distinguished from punctuation just by putting a space before
> each symbol.  So I would much rather see that standard adopted by ZAP
> than yet another quirky system I'll have to look up in the documentation
> every time I want to use it.

Yes it makes good sense to me.  Enough to break existing conditional
markups.  As for spaces around the punctuation, there could still be
potential glitches with user input, but I'm thinking perhaps this can
be further sorted out by checking to see that the content after the
punctuation up to the equal sign accurately matches an existing field,
if not giving some error message at least...

> Thanks for asking for feedback, Dan!  --Ben

Thanks for the great ideas!!!

More information about the pmwiki-users mailing list