Vinians2006 Active Member Licensed User Longtime User Sep 20, 2014 #1 Hi, guys! I need format a string using a sintax like printf or something equivalent. In Delphi I used to use Format function like: Code: str = format('%-32.32s | 10.10s |', "Vinicius", "223"); How can I do that in Basic4Android? This is good because is easy to pad strings...
Hi, guys! I need format a string using a sintax like printf or something equivalent. In Delphi I used to use Format function like: Code: str = format('%-32.32s | 10.10s |', "Vinicius", "223"); How can I do that in Basic4Android? This is good because is easy to pad strings...
LucaMs Expert Licensed User Longtime User Sep 20, 2014 #2 By default, B4A has only NumberFormat, as far as I know (AFAIK? I just learned a new "word") You can search on the site, there are some string functions (but I do not think they are sufficient for you). You could develop a nice function with placeholders and then... publish it in the "Snippets" Last edited: Sep 20, 2014 Upvote 0
By default, B4A has only NumberFormat, as far as I know (AFAIK? I just learned a new "word") You can search on the site, there are some string functions (but I do not think they are sufficient for you). You could develop a nice function with placeholders and then... publish it in the "Snippets"
Vinians2006 Active Member Licensed User Longtime User Sep 20, 2014 #3 Friend, I found a "Snippet" here http://www.b4x.com/android/forum/threads/sprintf.10860/ Thanks to canalrun. Upvote 0
Friend, I found a "Snippet" here http://www.b4x.com/android/forum/threads/sprintf.10860/ Thanks to canalrun.
canalrun Well-Known Member Licensed User Longtime User Sep 20, 2014 #4 I'm glad you found that. I've been using this function essentially unmodified since writing it in 2011. As agraham stated it could be done much more efficiently and is fairly incomplete when compared to the "C" function. I've also learned a lot more about variable type conversions – some of the conversions that I do are simply unnecessary. But, it has worked for for me, so far. I hope it works for you. Barry. Upvote 0
I'm glad you found that. I've been using this function essentially unmodified since writing it in 2011. As agraham stated it could be done much more efficiently and is fairly incomplete when compared to the "C" function. I've also learned a lot more about variable type conversions – some of the conversions that I do are simply unnecessary. But, it has worked for for me, so far. I hope it works for you. Barry.