[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-08 Thread Tobias

Hi Måns...

I guess, above all, slices allow you to put any context around them,
without influencing your ability to list them.
So you're not constrained to a well-formed hr-separated list.

Tobias.

On Sep 8, 12:20 am, Måns humam...@gmail.com wrote:
 Thanks for the hint Tobias - I haven't used sections and slices very
 much yet.
 I've been using fields, tags and fETs to retrieve information for use
 in tables.
 If you think it's a good idea in this context - I will try to learn
 how ..

 YS Måns Mårtensson

 On 7 Sep., 23:48, Tobias beertob...@googlemail.com wrote:



  Thanks for the detailed information.

  So, I understand that, just as tables, those hr separated lists are
  a concise way to structure information which you just don't want to go
  down some one tiddler for each item approach.

  As for that, maybe slices and sections in combination with scripting
  and listMacros are interesting to you as 
  well:http://tiddlywiki.org/wiki/Transclusion#Partial_Transclusion
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-08 Thread Eric Shulman

 I guess, above all, slices allow you to put any context around them,
 without influencing your ability to list them.
 So you're not constrained to a well-formed hr-separated list.

Slices *are* very useful.  However, there are some limitations that
you should be aware of:

You need to know what the slice names are in order to access the
values, and each slice has to have a unique name within the tiddler.
In addition, slices cannot contain multiple lines of text, nor can
they use the | symbol (assuming the slices are defined using TW
table format).

In contrast, HR-separated lists are simple sequences of *unnamed*
items, and can contain multiple lines consisting of any sequence of
characters except, of course, for a line containing just an HR (),
as this would signal the end of one item and the start of the next.

-e



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-08 Thread Eric Shulman

 I tried to implement these line in the first script like this:
 script
 var out=;
 var txt=store.getTiddlerText($1,);
 var items=txt.split(\n\n); {
 if (!items[1]) items=txt.split(\n); // start a new row
 out += |+items[i]; // add item to row

 }
 out += |\n; // end last row
 return out;
 /script

Well, it would help if you hadn't *removed* the part of the code that
actually *loops* over the entire list of items.  Go back to my first
post in this thread that contained the complete script.  You should
just replace the original line that fetches the 'items' array with the
3 lines that fetches it using either format, and leave the for (...)
loop statement as-is, so that each retrieved item can be processed and
added to the output.

-e

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-08 Thread Måns

Eric

 Alternatively, here's some general-purpose code that first tries to
 split the text on the HR separator... and if only one item results
 (i.e., there are *no* HR separators in the text), then tries splitting
 on just a simple newline, allowing either format to be used, as
 appropriate:

    var txt=store.getTiddlerText($1,);
    var items=txt.split(\n\n);
    if (!items[1]) items=txt.split(\n);

I tried to implement these line in the first script like this:
script
var out=;
var txt=store.getTiddlerText($1,);
var items=txt.split(\n\n); {
if (!items[1]) items=txt.split(\n); // start a new row
out += |+items[i]; // add item to row
}

out += |\n; // end last row
return out;
/script

But I only get the first line/first cell of the table.
What would the working script look like?

YS Måns Mårtensson

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-08 Thread Måns

Eric - is it somehow possible to make the script work on a
lineseperated list produced by a fET?
This would give infinite possibilites for producing tables with data
fetched from tiddlers - and sorted by the fET..

I know how to make a single multicolumned table in a fET already - but
it would add the ability to make overflow on *long* tables from very
simple fETs -

If a fET could actually write a real textlist - then this script
could format the list to a table..

Am I dreaming?

YS Måns Mårtensson

On 9 Sep., 01:59, Måns humam...@gmail.com wrote:
 Ok - Thanks for explaining...
 I've got it working now - and I am happy to say that it works on a
 simple lineseperated list as well as on a hr-seperated list.
 That's great - thanks a lot!

 YS Måns Mårtensson

 On 9 Sep., 01:21, Eric Shulman elsdes...@gmail.com wrote:



   I tried to implement these line in the first script like this:
   script
   var out=;
   var txt=store.getTiddlerText($1,);
   var items=txt.split(\n\n); {
   if (!items[1]) items=txt.split(\n); // start a new row
   out += |+items[i]; // add item to row

   }
   out += |\n; // end last row
   return out;
   /script

  Well, it would help if you hadn't *removed* the part of the code that
  actually *loops* over the entire list of items.  Go back to my first
  post in this thread that contained the complete script.  You should
  just replace the original line that fetches the 'items' array with the
  3 lines that fetches it using either format, and leave the for (...)
  loop statement as-is, so that each retrieved item can be processed and
  added to the output.

  -e
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-06 Thread AlanBCohen

First question, I m not familiar with the term hr-seperated list..
Do you mean a list which has each item separated by a 'hard return' or
CarriageReturnLineFeed combination?  Or is there some other
character string separating the items?  If this is a one-time
occurrence to take this list and change it,I'd suggest copying the
body of the list into an external text file.  Then use the text editor
(of your choice) to insert a pipe character | as a replacement for
the deliminator.  Then, manually insert a carriage return after every
fifth entry to break the list up into columns. You will probably need
to insert several other pipes to finish the task.
Another possibility would be to use a language like 'awk' to process
the list, but I don't think the learning curve justifies a one-time
use.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-06 Thread Eric Shulman

 First question, I m not familiar with the term hr-seperated list..

An 'HR-separated list' is a text-based syntax that I've developed and
used in numerous TiddlyTools plugins and inline scripts.  Basically,
it's a tiddler containing lines of text, divided up into 'items' of
one or more lines, where each item is separated by a line containing a
TW HR (horizontal rule) syntax: newline-4 dashes-newline (i.e.,
\n\n).

Two examples of HR-separated lists:
http://www.TiddlyTools.com/#Quotations
and
http://www.TiddlyTools.com/#MiniBrowserList

If the first case, each item is a text entry (a quotation) that can be
randomly selected and displayed by QuoteOfTheDayPlugin.  In the second
case, each item consists of two lines: the first line contains
descriptive text, the second line contains a URL.  This information is
then used by MiniBrowserPlugin to populate the 'bookmarks' list.

To parse an HR-separated list in javascript code (plugin or inline
script) is easy:

var items=store.getTiddlerText(SomeTiddler,).split(\n\n);

This creates an array of strings, one for each item in the list.
Then, loop over those items to process each one.  If each item has
multiple lines, you can further split the text into separate lines
(i.e., using .split('\n')). For example, to fill the 'bookmarks...'
droplist in MiniBrowser:

for (var i=0; iitems.length; i++) {
   var lines=items[i].split(\n); // 1st line=description, 2nd
line=URL
   list.options[list.length] = new Option(lines[0],lines[1]);
}

where 'list' is an HTML select element (i.e., a droplist/listbox)

For Mans' specific use case, you could write something like this using
   http://www.TiddlyTools.com/#InlineJavascriptPlugin

script
var out=;
var items=store.getTiddlerText(SomeTiddler,).split(\n\n);
for (var i=0; iitems.length; i++) {
   if (i0  i/5==Math.floor(i/5)) out += |\n; // start a new row
   out += |+items[i]; // add item to row
}
out += |\n; // end last row
return out;
/script

The script constructs the desired TW table syntax into a string
variable (out), and then returns that string.  InlineJavascriptPlugin
then automatically passes that returned text to the core's wikify()
function to render the table into your output.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-06 Thread Måns

Hi Eric - this is true magic : - )
Of course *you* would say that it's easy -
I only had a hunch - that it ought to be easy - considering what I've
seen uptill now!!

2 questions:

1)
If I could make it work with any hr-seperated lists like this:

tiddler TiddlerContainingScript with SomeTiddlerName 
It would be even better...
I presume it's a matter of changing (SomeTiddler,) to ('$1','') ??

Am I on the right track?

2)
My next action with the hr-seperated list would be to add toggletag A
and toggletag B to each item - referring to the tiddlerLink -
Will it work in the table?

YS Måns Mårtensson

On 6 Sep., 20:20, Eric Shulman elsdes...@gmail.com wrote:
  First question, I m not familiar with the term hr-seperated list..

 An 'HR-separated list' is a text-based syntax that I've developed and
 used in numerous TiddlyTools plugins and inline scripts.  Basically,
 it's a tiddler containing lines of text, divided up into 'items' of
 one or more lines, where each item is separated by a line containing a
 TW HR (horizontal rule) syntax: newline-4 dashes-newline (i.e.,
 \n\n).

 Two examples of HR-separated lists:
    http://www.TiddlyTools.com/#Quotations
 and
    http://www.TiddlyTools.com/#MiniBrowserList

 If the first case, each item is a text entry (a quotation) that can be
 randomly selected and displayed by QuoteOfTheDayPlugin.  In the second
 case, each item consists of two lines: the first line contains
 descriptive text, the second line contains a URL.  This information is
 then used by MiniBrowserPlugin to populate the 'bookmarks' list.

 To parse an HR-separated list in javascript code (plugin or inline
 script) is easy:

 var items=store.getTiddlerText(SomeTiddler,).split(\n\n);

 This creates an array of strings, one for each item in the list.
 Then, loop over those items to process each one.  If each item has
 multiple lines, you can further split the text into separate lines
 (i.e., using .split('\n')). For example, to fill the 'bookmarks...'
 droplist in MiniBrowser:

 for (var i=0; iitems.length; i++) {
    var lines=items[i].split(\n); // 1st line=description, 2nd
 line=URL
    list.options[list.length] = new Option(lines[0],lines[1]);

 }

 where 'list' is an HTML select element (i.e., a droplist/listbox)

 For Mans' specific use case, you could write something like this using
    http://www.TiddlyTools.com/#InlineJavascriptPlugin

 script
 var out=;
 var items=store.getTiddlerText(SomeTiddler,).split(\n\n);
 for (var i=0; iitems.length; i++) {
    if (i0  i/5==Math.floor(i/5)) out += |\n; // start a new row
    out += |+items[i]; // add item to row}

 out += |\n; // end last row
 return out;
 /script

 The script constructs the desired TW table syntax into a string
 variable (out), and then returns that string.  InlineJavascriptPlugin
 then automatically passes that returned text to the core's wikify()
 function to render the table into your output.

 enjoy,
 -e
 Eric Shulman
 TiddlyTools / ELS Design Studios
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-06 Thread Eric Shulman

 tiddler TiddlerContainingScript with SomeTiddlerName 
 I presume it's a matter of changing (SomeTiddler,) to ('$1','') ??
 Am I on the right track?

Yup.  That will work.  (note: the with: param above needs to have a
: on the end of it)

 My next action with the hr-seperated list would be to add toggletag A
 and toggletag B to each item - referring to the tiddlerLink -
 Will it work in the table?

The script output is processed as TW wiki syntax, so any macros, etc.
that occur in the list items should be handled when the output is
rendered.

enjoy,
-e
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---



[tw] Re: How to turn a hr-seperated list into a table with several columns?

2009-09-06 Thread Eric Shulman

 Can I automake a hr-seperated list from a normal lineseperated list
 with quickeditplugin in some way?

If the tiddler contains single lines, you could use it as is, by
changing the script from
   var items=store.getTiddlerText($1,).split(\n\n)
to just
   var items=store.getTiddlerText($1,).split(\n);

Alternatively, here's some general-purpose code that first tries to
split the text on the HR separator... and if only one item results
(i.e., there are *no* HR separators in the text), then tries splitting
on just a simple newline, allowing either format to be used, as
appropriate:

   var txt=store.getTiddlerText($1,);
   var items=txt.split(\n\n);
   if (!items[1]) items=txt.split(\n);

enjoy,
-e

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TiddlyWiki group.
To post to this group, send email to tiddlywiki@googlegroups.com
To unsubscribe from this group, send email to 
tiddlywiki+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~--~~~~--~~--~--~---