![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Does anyone know if there is a function or how to write one that concatenates a letter to a string a specific number of times? For instance, I have letter H in a variable called $letter I want to create a string that contains H a certain number of times that is stored in another variable called $repetition. So, when $repetition is 5 my string should be HHHHH I was trying to write a custom function that uses another custom function called VariableInitialize and trying to Loop adding H to that string, but VariableInitialize seems to work only with number and not characters. PS: VariableInitialize function was obtained free from www.briandunning.com Thanks |
#3
| |||
| |||
|
|
Does anyone know if there is a function or how to write one that concatenates a letter to a string a specific number of times? |
|
For instance, I have letter H in a variable called $letter I want to create a string that contains H a certain number of times that is stored in another variable called $repetition. So, when $repetition is 5 my string should be HHHHH I was trying to write a custom function that uses another custom function called VariableInitialize and trying to Loop adding H to that string, but VariableInitialize seems to work only with number and not characters. PS: VariableInitialize function was obtained free from www.briandunning.com Thanks |
#4
| |||
| |||
|
|
if you don't have 7D or 8A you'd have to make do with a looping script to build your string. |
|
In article <1130351516.112596.101770 (AT) z14g2000cwz (DOT) googlegroups.com>, thijorge (AT) gmail (DOT) com says... Does anyone know if there is a function or how to write one that concatenates a letter to a string a specific number of times? With FM7D or FM8A you can define a recursive function: repeat (n,s) = case( n<1,"" n=1,s, n>1,s& repeat(n-1,s)) Call repeat with (4,"h") And you'll get "h"&repeat(3,"h") which expands to "h"&"h"&repeat(2,"h") ... "h"&"h"&"h"&"h" hhhh it will also work on strings (repeat(2,"xyz") = xyzxyz if you don't have 7D or 8A you'd have to make do with a looping script to build your string. For instance, I have letter H in a variable called $letter I want to create a string that contains H a certain number of times that is stored in another variable called $repetition. So, when $repetition is 5 my string should be HHHHH I was trying to write a custom function that uses another custom function called VariableInitialize and trying to Loop adding H to that string, but VariableInitialize seems to work only with number and not characters. PS: VariableInitialize function was obtained free from www.briandunning.com Thanks |
#5
| |||
| |||
|
|
if you don't have 7D or 8A you'd have to make do with a looping script to build your string. A very simple way to do it that works without Developer powers is: Left(Substitute ( "{plenty of spaces}"; " "; letter);repetition) |
![]() |
| Thread Tools | |
| Display Modes | |
| |