[pmwiki-users] WikiSh - check string length

Peter & Melodye Bowers pbowers at pobox.com
Sun Jun 8 09:00:14 CDT 2008


This is an easy mistake to make and one I make often as well.

 

The "if" construct expects a valid MX command which in this case should be
"test".  Thus {(wikish if ${#word} -gt 10.)} should be {(wikish if test
${#word} -gt 10.)}.

 

I've placed on the development roadmap to give a helpful error message if a
non-MX token is found immediately after if.

 

-Peter

 

  _____  

From: adam overton [mailto:a at plus1plus1plus.org] 
Sent: Sunday, June 08, 2008 11:46 AM
To: pmwiki-users
Cc: Peter & Melodye Bowers
Subject: WikiSh - check string length

 

 

and one more WikiSh question while we're at it:

 

and again, i'm not understanding why this won't work - i want to check the
length of a string, and if it's too long, i'd like to print something
different out... this is what i had hoped would work:

 

          {(set -s word = "blammo")}

          result: {(wikish if ${#word} -gt 10; then; echo "string too big";
else; echo "string just right"; fi)}

 

however, the result i get is

 

          result = {#word} -gt 10)

          string too big

 

 

any ideas on how i can get the string length to be treated like a number and
then successfully pushed thru the if statement?

 

thanks

adam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20080608/c65db034/attachment.html 


More information about the pmwiki-users mailing list