bb wrote: >I think you might find that the last character of indesejaveis.txt is a \n (as is the case for many, many > files) so in actual fact your original split did exactly what it was supposed to do. > > And your work around is correct. Although it is not actually a work around it is a very > common construct when dealing with text files.
> So, I very much doubt there is a bug in File.Load() In the beginning, I thought I File.Load() had an idiosyncratic behavior. Then I understood that's not true. It just reads everything from the file into the variable. So, it is good behavior when it brings in the last "\n". Then I thought Split() had a strange behavior since it brought in something that did not exist after the last separator, that is, an empty string. Then, I discovered I was wrong on this account: if I have a separator as the last real element, then after that what I have is an empty string. So, I can't blame Split() for bringing it in. Unless I explicitly tell Split() to drop it. Yes, in this case, the bug was in my brain. It is called lack of knowledge or faulty reasoning. Thank you bb and Tony for showing me the light. - fernando 2017-07-05 0:43 GMT-03:00 bb <adamn...@gmail.com>: > On 05/07/17 11:58, Fernando Cabral wrote: > >> I have found and worked around the problem. When you do the following: >> >> *Dim Expressions as string[] = >> Split(File.Load("/home/fernando/.config/libreoffice/4/user/ >> basic/indesejaveis.txt"), >> "\n") * >> >> The last item pushed into *Expressions* is an empty string ("") even >> though >> it DOES NOT exist >> in the file. So, the expressions are compiled one after the other til the >> last one, that is empty. Then the program crashes. >> >> So it seems there is a bug in the *load.file()*. Bug that I was able to >> compensate for by adding the option *True* in the call to the functions >> *split()*. >> >> > >> I think you might find that the last character of indesejaveis.txt is a > \n (as is the case for many, many files) so in actual fact your original > split did exactly what it was supposed to do. > > And your work around is correct. Although it is not actually a work around > it is a very common construct when dealing with text files. > > So, I very much doubt there is a bug in File.Load() > > b > -- Fernando Cabral Blogue: http://fernandocabral.org Twitter: http://twitter.com/fjcabral e-mail: fernandojosecab...@gmail.com Facebook: f...@fcabral.com.br Telegram: +55 (37) 99988-8868 Wickr ID: fernandocabral WhatsApp: +55 (37) 99988-8868 Skype: fernandojosecabral Telefone fixo: +55 (37) 3521-2183 Telefone celular: +55 (37) 99988-8868 Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos, nenhum político ou cientista poderá se gabar de nada. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user