Categories > TinyButStrong general >

Repeat a string N times

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Aldoir
Date: 2004-09-04
Time: 21:25

Repeat a string N times

I have a numeric variable var.indent and I must loop thru this variable repeating some string

Ex
$indent = 3
[var.indent;some code here;'-']

and the output must be
---
any ideas ?
By: Skrol29
Date: 2004-09-06
Time: 00:11

Re: Repeat a string N times

Use MergeBlock() with 'num' for the type of data.
By: Aldoir
Date: 2004-09-06
Time: 05:38

Re: Repeat a string N times

Skrol, thanks in advance, but I think the solution is not so simple

I have a folder listing, each item have a level of indentation, ex.

Home
- Subfolder (Level 1)
- Subfolder (Level 1)
-- Subfolder (Level 2)

So my variable is a column of a block, can I have a children block inside another block ?

Thanks again, I'm trying to use your template engine in my webmail (UebiMiau) to replace Smarty, but somethings are breaking me, this is one, other is the [var.value; if [val] = [another.value]] limitation, I'm a bit confused :/

regards

Aldoir
By: Skrol29
Date: 2004-09-07
Time: 00:34

Re: Repeat a string N times

Hi,

You have quite the same indentation in the thread frame of the tbsForum (this forum). The best way I've found is to have the indentation made by MySQL itself. Yes MySQL:
SELECT REPEAT('-',msg_level) AS lev ...

Otherwise, you can use parameters 'onformat' or 'onsection'. They enables you to use a usr PHP function to format a value or a record.

>somethings are breaking me, this is one,
> other is the [var.value; if [val] = [another.value]] limitation

What do you mean?

By: Aldoir
Date: 2004-09-07
Time: 06:08

Re: Repeat a string N times

> You have quite the same indentation in the thread frame of the
> tbsForum (this forum). The best way I've found is to have the
> indentation made by MySQL itself. Yes MySQL:

by this way, the indentation will be hardcoded, and the designer cannot change.. imagine that one will choose to use spaces, other minus '-' to indent, and so on

I understant your idea is not to use conventional programming in the template, but without features like that, the template will be very limited


> What do you mean?

works:
[var.value; if [val] = 1]

not work:
[var.value; if [val] = [var.value]]
where var.value values 1 too

this problem is commented in the faq, and is another limitation I found

Aldoir
By: Skrol29
Date: 2004-09-08
Time: 01:14

Re: Repeat a string N times

> by this way, the indentation will be hardcoded, and the
> designer cannot change.. imagine that one will choose
> to use spaces, other minus '-' to indent, and so on

You're right. I can't see a way to define the character inside the template and to multiply it.
It will be possible with next version using template variables.

> I understant your idea is not to use conventional programming
> in the template, but without features like that, the template
> will be very limited

The idea of my issue was to get a fast and simple solution.

> not work:
> [var.value; if [val] = [var.value]]

This could be made possible. The only trouble is about time optimisation.