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 &
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
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.
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
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
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 -->