Thank you again.This one line solution is much more elegant. On Wednesday, April 6, 2016 11:33 AM, ML <d4t4f...@gmail.com> 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 & 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 do the opposite: numberString = String.Right$(Space$(places) & Str$(number), places) 'The number will be right-aligned to "places" spaces and returned in numberString. As Oliver pointed, you should use the UTF-8 versions of the calls; otherwise you will have less than the expected characters in the resulting string. Regards, zxMarce. On 2016-04-06 11:00, Oliver Etchebarne Bejarano wrote: > 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 something like latin-1. And hope that your > system can understand the new encoding well... > > > El 06/04/16 a las 07:48, José Monteiro escribió: >> 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 --> "José Antônio" + 101 spaces >> >> But, in the text file, "José Antônio" + 101 spaces is considered as having >> lenght = 113, not 115. >> The text file, then, is rejected by the system, because the following fields >> are not being correctly interpreted. >> Any sugestions? >> Thanks in advance >> >> >> >> -- >> View this message in context: >> http://gambas.8142.n7.nabble.com/Lenght-of-a-string-tp55855.html >> Sent from the gambas-user mailing list archive at Nabble.com. >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Gambas-user mailing list >> Gambas-user@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user