[pmwiki-users] wikish example please
Peter Bowers
pbowers at pobox.com
Thu May 30 06:05:44 CDT 2013
On Wed, May 29, 2013 at 11:06 PM, Mark Lee <mark.lee.phd at gmail.com> wrote:
> Although it might be easier to just log data to a temporary file, I think
> I will try the ${a-${i}} method for arrays with wikish. Can you send me
> example code that will parse a line like the following, and store x and y
> values in the arrays ${x-${i}} and ${y-${i}}?
> (:location x=111 y=222:)
>
> I have been experimenting with the form
>
> {(wikish source {$FullName}#test)}
>
> (:if false:)
> [[#test]]
> for page in Plants.*
> do
> if grep -q "(:location" ${page}
> then
> set -s dataline = "`grep "x=" ${page}`"
> echo "${dataline}"
> .......... more code goes here
> fi
> done
> [[#Test]]
> (:ifend:)
>
> I'm not sure this is the headed in the right direction. Thanks again for
> your guidance.
>
It seems like I'm missing something obvious to avoid the triple-pass
(although at least I'm only passing over the temporary page), but in any
event it works.
You can find the example at http://pmwiki.qdk.org/pmwiki.php?n=Test.LocCode,
as before. Source is below my sig.
-Peter
{(wikish source {$FullName}#test)}
(:if false:)
[[#test]]
grep '\(:location.*x=.*y=' Test.Loc? | sed -e 's/^/||/' -e 's/:\(:/||/' -e
's/ x=/||/' -e 's/ y=/||/' -e 's/:\).*$/||/' >Tmp.X
echo "!!Tmp.X"
cat Tmp.X
echo "!!page"
set i = 1
cat Tmp.X | cut -d'||' -f2 | while read foo
do
#echo "DEBUG: foo=${foo}"
set -s page_${i} = ${foo}
set i ++
done
echo "!!4"
set i = 1
cat Tmp.X | cut -d'||' -f4 | while read foo
do
#echo "DEBUG: foo=${foo}"
set -s x_${i} = ${foo}
set i ++
done
echo "!!5"
set i = 1
cat Tmp.X | cut -d'||' -f5 | while read foo
do
#echo "DEBUG: foo=${foo}"
set -s y_${i} = ${foo}
set i ++
done
for j in 1 2 3
do
echo "* page=${page_${j}}, x=${x_${j}}, y=${y_${j}}"
done
[[#endtest]]
(:if:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130530/cfc66d65/attachment.html>
More information about the pmwiki-users
mailing list