New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
This question about Using an extension: Answered

EXTRACT keeps grabbing my header line

I'm getting a weird behavior out of EXTRACT. The short of it is if I have a heading on my table, it always seems to grab the heading instead of the first matching value.

The long version is this: I've been looking for a way to grep rows from a table based on a query and found EXTRACT as a way to do it. I don't know whether there are any other ways that work.

I have a table of people, where the first column is their name, the second is their building and the third is their room. That table is in a topic by itself.

I needed another topic that could, given a query string with the room number, give me the names of the people in that room. I am using it with an image map of the office floor plan.

As an aside, I tried using SEARCH as a starting point, but I couldn't figure out how to do a lookup.
<pre>%SEARCH{"%ROOM%" topic="PeopleTable" format="   * $Name" multiple="on" }%</pre>
This syntax doesn't work, but I do get the right number of rows; I just don't know how to query for the column value.

What does mostly work is
<pre>%EXTRACT{topic="PeopleTable" expand="off" 
  format="   * $1$n"}%</pre>

If I have no heading, it works perfectly.

The Table:
Name Building Room
Blow, Joe ABA 3103
Blow, Moe ABA 3103
Flow, Joe ABA 3113
Blow, Zoe ABA 3113

With my search with room=3103, I got
  • Name
  • Blow, Moe
If I use skip=1, i just get
  • Blow, Moe
If I get rid of the table heading, I get
  • Blow, Joe
  • Blow, Moe
-- MatthewKoundakjian - 27 Oct 2010

OH NO, I'm wrong. I am always getting the first row in my results.

With my search the table without a heading with room=3103, I get
  • Blow, Joe
  • Blow, Moe
With my search the table without a heading with room=3113, I get
  • Blow, Joe
  • Blow, Zoe
-- MatthewKoundakjian - 27 Oct 2010

I found something that works, though I can't figure out why the previous does not. The regex seems to behave just fine.

Interactive lookup

   * Set ROOM = %URLPARAM{"room" default="3103"}%
%EXTRACT{topic="%TOPIC%" expand="off" 
 format="   * $1$n" 

Test cases: The result:
  • Blow, Joe
  • Blow, Moe

I'm considering this one answered.

-- MatthewKoundakjian - 05 Nov 2010

QuestionForm edit

Subject Using an extension
Extension FilterPlugin
Version Foswiki 1.1.0
Status Answered
Topic revision: r2 - 05 Nov 2010, MatthewKoundakjian - This page was cached on 23 Mar 2018 - 06:28.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License