Android Question Need help with string

Pacache

Member
Hello, i am a beginner in B4A.
I have been trying for hours to solve an issue.
I have a label containing "Colossiens 1,1,/ blablabla"
with the substring2 i extract the word "Colossiens" and put it in a string variable and with this variable&".txt" i try to open a file with the same name "Colossiens.txt". Then i get a message saying the file does not exist. When instead of using substring and a variable, i type directly the word "Colossiens", it works fine and opens the file.I noticed something: when i get the word "Colossiens" as a string its lenght is 11 but when i type it directly its lenght is 10. I have used trim but it still doesnt work. I really dont understand, can anyone help me please ! thank you
 

Pacache

Member
Check the output of Log(YourVariable.Length). You will see that it includes the space.
Thank you for your answer, Erel. What i do for the word "Colossiens" i do it with a list containing 65 other words. All of them extracted with the same process.... i put them into a Label. Yesterday I directly renamed the file named "Colossiens" to make sure there was no space inside it. I also directly went into the file containing the 65 other words and retyped the name "Colossiens"
When i lauched the programm it failed again with the same word ! I found the solution of course getting round the error just saying "If itemdeliste.indexof("lossiens") is true then the word is "Colossiens" and of course it works. I checked the output of log(myvariable.length) before, i tried with CharAt to find a space but there was none ! Anyway this will remain a mystery to me ! Thank you again for your time.
 
Upvote 0

Pacache

Member
If you can post some code maybe we could tell what the issue is!
I just found where the problem was ! Although the name of the file was "Colossiens" with no apparent space ( because the name was well aligned to the left just like the other ones when into the folder) and because i used ".trim" when i called the file, i renamed it several times to make sure. But i just noticed something, each time i named it, Google gives me the word "Colossiens" but i supect it just gives me MY word "Colossiens" with probably something wrong inside it, and thus doing the same mistake again and again yesterday for hours !!!! . So this time i named it myself and it all works fine ! So thank you both for answering.
 
  • Like
Reactions: eps
Upvote 0
Top