[pmwiki-devel] Testing empty string (was:php logic question)

christian.ridderstrom at gmail.com christian.ridderstrom at gmail.com
Wed Mar 14 07:46:32 CDT 2007


On Wed, 14 Mar 2007, Patrick R. Michaud wrote:

>>> (:if "" :)
>>> (:if !"" :)
>>>
>>> are both TRUE
>>>
>>> (:if equal !"" true:)
>>> (:if equal !"" false:)
>>>
>>> are both FALSE

> It's not a bug... or at least, it's working as designed.
> The format of the (:if:) conditional is always
>
>     (:if <condname> <params>:)
>     (:if ! <condname> <params>:)

Oh, you're right of course.

> and since the "" in (:if "" :) isn't a recognized condition, PmWiki 
> always treats it as true.

>> 	(:if "" :)
>
> In general PmWiki doesn't report "syntax errors", if only because I'm 
> not sure of a good way to do so.  I suppose I could always insert text 
> into the markup in such cases.

How about treating it the same as all other markup that isn't recognized, 
i.e. letting

 	(:if "" :)
 	bla
 	(:ifend:)

render as

 	(:if "" :)
 	bla
 	(:ifend:)

instead of treating the condition as true.

Here's another thought regarding syntax errors and warnings.

What if each error/warning was appended to some variable, e.g. 
$PmWikiErrors and $PmWikiWarnings, which you could then optionally show at 
the end of the page if you so desire.

The difficult part is specifying the equivalent of a line number, but 
maybe it's enough if $PmWikiError contained something like:

 	* The markup
 	--> [@
 	(:if "" :)
 	@]
 	  in the page <page> (line <nnn>) is not a recognized syntax.

Just a thought.

>    (:if equal "{$Variable}" "":)
>
> I don't have any plans to create an (:if "{$Variable}") shortcut, if 
> only because it's completely irregular to the normal (:if:) syntax.

I don't think it's needed either... the whole thing got sidetracked 
because the first question was about PHP syntax.

/C

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr


More information about the pmwiki-devel mailing list