Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Multiplying strings
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1221068778

Message started by Jack Baty on Sep 10th, 2008, 1:46pm

Title: Multiplying strings
Post by Jack Baty on Sep 10th, 2008, 1:46pm

I'm trying to generate nested lists in Textile format when exporting a set of notes. The idea is to preface each note's title with a number of asterisks. This number should be based on the value of OutlineDepth. So I tried this in the export template...


Code:
^value("*"*($OutlineDepth-3))


Which gives me this...


Code:
*1 My note name
*2 Nested note name


I'd like to end up with

Code:
* My note name
** Nested note name



Can strings be manipulated this way during export?

Title: Re: Multiplying strings
Post by Mark Bernstein on Sep 10th, 2008, 2:43pm

No; you can't multiply strings this way. (I can't recall seeing this syntax in any computer language, though I seem to remember discussing it a few weeks ago.  I'll check into that when I return to the office)

What you could do is a conditional.  Or, the ^indent() command might do what you need.  Alternatively, store the list prefix in an attribute, perhaps setting it with a rule (ListPrefix=$ListPrefix(parent)+"*"_

Title: Re: Multiplying strings
Post by Jack Baty on Sep 10th, 2008, 3:07pm

Thanks Mark,

I've used a conditional for now and that will work. It's a little fragile but the relevant nodes aren't moved around much.

Code:
^if($OutlineDepth=4)^* ^else^ ** ^endif^



^indent() would have worked best I think, if there was a way to set the "root", such as ^include(*, 4). That would render ** if the depth was 6. Something like that anyway.

I'll keep playing with it. I'm new to the export bits of Tinderbox so there may be a completely different solution I haven't thought of yet.

Ruby allows multiplying numbers and strings in that way....


Code:
irb(main)> "*"*5
=> "*****"


Handy!

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.