[Gambas-user] Mystery with file.load and regexp

bb adamnt42 at ...626...
Wed Jul 5 05:43:15 CEST 2017


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




More information about the User mailing list