Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Multiplying strings (Read 6132 times)
Jack Baty
Full Member
*
Offline



Posts: 96

Multiplying strings
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?
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Multiplying strings
Reply #1 - 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)+"*"_
Back to top
 
 
WWW   IP Logged
Jack Baty
Full Member
*
Offline



Posts: 96

Re: Multiplying strings
Reply #2 - 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!
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print