Re: [Gambas-user] Lenght of a string

2016-04-06 Thread Jose Monteiro
Thank you again.This one line solution is much more elegant. On Wednesday, April 6, 2016 11:33 AM, ML wrote: José, A side note, no need also to use a FOR-NEXT to fill X spaces. You can do it in a single step:   'for i = 1 to (115 - len(name))   '  name = name &

Re: [Gambas-user] Lenght of a string

2016-04-06 Thread ML
José, A side note, no need also to use a FOR-NEXT to fill X spaces. You can do it in a single step: 'for i = 1 to (115 - len(name)) ' name = name & Space$(1) 'next name = String.Left$(name & Space$(115), 115) If you need the spaces at the left (for example to right-align numbers), you

Re: [Gambas-user] Lenght of a string

2016-04-06 Thread José Monteiro
Thank you, Oliver. Using String.len(name) completely solves the problem. -- View this message in context: http://gambas.8142.n7.nabble.com/Lenght-of-a-string-tp55855p55858.html Sent from the gambas-user mailing list archive at Nabble.com.

Re: [Gambas-user] Lenght of a string

2016-04-06 Thread Oliver Etchebarne Bejarano
You are writing utf-8 characteres, so the 'é' and the 'ô' are two bytes long ("José Antônio" is 12 chars but 14 bytes long). I think you should either remove the tildes, or use UTF-8 string functions (like String.len() instead of len()) for the calculations, and then change the encoding to

Re: [Gambas-user] Lenght of a string

2016-04-06 Thread Oliver Etchebarne Bejarano
You are writing utf-8 characteres, so the 'é' and the 'ô' are two bytes long ("José Antônio" is 12 chars but 14 bytes long). I think you should either remove the tildes, or use UTF-8 string functions (like String.len() instead of len()) for the calculations, and then change the encoding to

[Gambas-user] Lenght of a string

2016-04-06 Thread José Monteiro
len("José Antônio") = 14 I need to fill a text file and upload it to a system in order to make an invoice. The field "name" must have lenght = 115. If shorter than that you must complement it with spaces. So: for i = 1 to (115 - len(name)) name = name & Space$(1) next The result is -->