B4J Question Is there a way to return a string repeated X number of times?

Status
Not open for further replies.

Jorge M A

Well-Known Member
Licensed User
I think String lacks the Replicate function. (String.Replicate, String.Repeat, String.Concat...)
It bothers me to do Loops for simple stuff.
Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
1. You need a SHORT small sub to do that. No need to get bothered...
2. you could use the library stringfunctions
https://www.b4x.com/android/help/stringfunctions.html
i guess "PAD" is the method you are searching. Note that stringfunctions is nothing more than a class (or a simple code module) with different subs to do things. all of them are written in B4A.

All of them can be done without a lib (small helper sub as i wrote above).
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
StringFunctions
I would not want to use this library, which according to several posts, is out of maintenance, and whose main functions are included in the Core. However, I found a substitute module (StringFunctions2) in case I need anything else.
Thank You.
 
Upvote 0

emexes

Expert
Licensed User
I would not want to use this library, which according to several posts, is out of maintenance, and whose main functions are included in the Core.
Fair enough, no worries :)

If writing your own routine, and at risk of me sounding like a cracked record: use StringBuilder rather than &.
 
Upvote 0
Status
Not open for further replies.
Top