[pmwiki-users] wikish example please

Peter Bowers pbowers at pobox.com
Wed May 29 14:59:24 CDT 2013


"Plants.Plant?" means any page in the Plants group which starts with the 5
characters P-l-a-n-t followed by exactly 1 single character (whatever it
is).  Thus Plants.Plant1 or Plants.PlantA would match, but Plants.Test1 or
Plants.PlantAB would NOT match.  You may want something like Plants.* in
order to match any pages in the Plants group.++

Parsing the contents of variables is limited only by your mastery of
regular expressions, wikish commands such as split, etc.  Lots of
capabilities, but the learning curve can be somewhat steep.  You may want
to check out the WikiSh tutorial I've got out there.

WikiSh doesn't officially support arrays, but you can create variables
named ${a-1}, ${a-2}, etc. and then access them via ${a-${i}} where ${i}
contains a 1 or a 2.  Not sure if that makes sense, but that's the only way
you can do arrays in WikiSh.

-Peter


On Wed, May 29, 2013 at 6:38 PM, Mark Lee <mark.lee.phd at gmail.com> wrote:

> Peter,
> I have copied your files Test.LocCode and Test.Loc1, Test.Loc2 and
> Test.Loc3 to my site. I copied the wikish command to a new page
> Plants.Plant001. I changed the grep source as shown below.
> {(wikish echo "|| border=1"; grep '\(:location.*x=.*y=' Plants.Plant? |
> sed -e 's/^/||/' -e 's/:\(:/||/' -e 's/ x=/||/' -e 's/ y=/||y=/' -e
> 's/:\).*$/||/';)}
>
> I get the error
> WikiSh.Read: Unable to read Plants.Plant?. Does not exist.
> Sorry for the newbie question, but what is the syntax error?
>
> Another question... I am able to set a single variable equal to a line
> selected with grep using the set command in wikish. Is there a way to parse
> the variable and to push results into a set of arrays. For example, each
> location line has a x= and y= value, and I would like to push x and y
> values into separate arrays like I do in php. Is this something that can be
> done with functions in wikish?
>
> -Mark
>
>
> On Tue, May 28, 2013 at 11:39 PM, Mark Lee <mark.lee.phd at gmail.com> wrote:
>
>> Thank you Peter! Amazing. That example is so helpful. I'm glad I found
>> pmwiki.
>> -Mark
>>
>>
>> On Tue, May 28, 2013 at 11:14 PM, Peter Bowers <pbowers at pobox.com> wrote:
>>
>>> On Tue, May 28, 2013 at 9:32 PM, Mark Lee <mark.lee.phd at gmail.com>
>>> wrote:
>>> >
>>> > I am new to wikish. Is it possible to do the following with wikish?
>>> >
>>> > A subset of pages in a group have this markup on the page.
>>> >
>>> > (:location x=1 y=2:)
>>> > (:location x=10 y=10:)
>>> > (:location x=20 y=5)
>>> > etc...
>>> >
>>> > 1. What is the code for listing out the locations, one per line, along
>>> with the pagenames, excluding all pages without the (:loaction:) markup.
>>> For example:
>>> >
>>> > Group:Group1
>>> > Pagename=Name1, x=1, y=2
>>> > Pagename=Name1, x=10, y=10
>>> > Pagename=Name1, x=20, y=5
>>> > Pagename=Name6, x=3, y=15
>>> > Pagename=Name82, x=5, y=70
>>> > Pagename=Name82, x=2, y=40
>>> > etc...
>>>
>>> grep '\(:location.*x=.*y=' Group1.*
>>>
>>> > 2. Is it possible to format the output as a table?
>>>
>>>  Several ways.  Here's one (approximate):
>>>
>>> grep 'location.*x=.*y=' Group1.* | sed -e 's/^/||/' -e 's/:\(:/||/' -e
>>> 's/ x=/||x=' -e 's/ y=/||y=' -e 's/:\).*$/||'
>>>
>>> See http://pmwiki.qdk.org/pmwiki.php?n=Test.LocCode for a working
>>> example with 3 pages of test data.
>>>
>>> > 3. Is it possible to pipe the result to additional wikish code or a
>>> php function?
>>>
>>> Always possible to pipe it to additional wikish.  Or put that value in a
>>> wikish variable (or pv or ptv) and then further manipulate it.  Or put it
>>> into Tmp pages (which are available for wikish access and manipulation but
>>> don't exist otherwise).  Or etc.
>>>
>>> To mess with it in a php function probably you would want to bind your
>>> function to a markup expression and then pipe data to/from wikish using
>>> standard wikish conventions.  You can look at
>>> http://www.pmwiki.org/wiki/Cookbook/MiscMX for some fairly minimalized
>>> examples to work off of.
>>>
>>> -Peter
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130529/ee99abb8/attachment.html>


More information about the pmwiki-users mailing list