I am trying to use .indexof and substring2 etc. in my b4i code and it keeps telling me theres an error. This is based on examples from the forum. Is there a special library I need to include to use these terms?
Have you tried to explicitly define test2 as string?
IndexOf, Contains, etc are STRING functions!
When you are doing Teste2 = teste you are changing its definition from string into double, which is the Test definition
change the line to teste2 = teste.As(String) and see if it works
It’s saying that indexof and substring are undefined words. I will put the code up tomorrow. I am doing this in activity start in b4i, load a text file over the web and parse it out Into fields. Maybe it’s a problem being in that routine?
Also, it would be Very helpful for others, searching for help, or with the will to help, to have a much more significant title than "Maybe a simple question "... that says nothing about the type of issue you are facing
Here is a section of the code, it works perfectly in B4A
Load a file and parse it:
Dim cnt As Int
Dim toggle As Int
Dim data(2000) As String
Dim data2(2000) As String
Dim cnt2 As Int
Dim test As Double
Dim test2 As String
Dim Stream(1000) As String
Dim Name(1000) As String
Dim manifest As String
Dim SelectTotal As Int
' load available streams
Dim Job As HttpJob
Job.Initialize("manifest", Me)
Job.Download("http://www.yourwebsite.com/yourtestfile.txt")
Wait For (Job) JobDone(Job As HttpJob)
Log (Job.JobName & " Was Downloaded")
Log(Job.Response.ContentLength)
total = Job.Response.ContentLength
If Job.Success Then
manifest = Job.GetString
End If
Job.Release
' split into arrays
data = Regex.split(CRLF, manifest)
cnt = data.length
cnt = cnt - 1
toggle = 0
cnt2 = 0
' parse out to stream() and Name()
cnt2 = 0
For i = 0 To cnt
test = i/2
test2 = test
' b4i doesnt like .contains
' i tried "indexof" even "substring2"
' both when compiled come back as error
If test2.Contains(".") Then
toggle = 1
cnt2 = cnt2 + 1
Else
toggle = 2
End If
If toggle = 2 Then Name(cnt2) = data(i)
If toggle = 1 Then Stream(cnt2) = data(i)
Next
Stream(cnt2) = data(i - 1)
Name(cnt2) = data(i - 2)
SelectTotal = cnt2
Have you tried to explicitly define test2 as string?
IndexOf, Contains, etc are STRING functions!
When you are doing Teste2 = teste you are changing its definition from string into double, which is the Test definition
change the line to teste2 = teste.As(String) and see if it works
I copied your into one of my test programs, and the IDE nor the compiler are complaining about IndexOf nor Contains.
In what condition do you get the error ?
There’s A line under the line with .contains says something about an object as. When I compile it says .contains is a wrong word. What libraries did you enable?
Have you tried to explicitly define test2 as string?
IndexOf, Contains, etc are STRING functions!
When you are doing Teste2 = teste you are changing its definition from string into double, which is the Test definition
change the line to teste2 = teste.As(String) and see if it works
Ah ha! Yes that fixed it. I am porting the code from my b4A project and must have defined Test2 as Int by mistake in the header. Thank you (and everyone else) very much for your help, couldn't see for looking.
Ah ha! Yes that fixed it. I am porting the code from my b4A project and must have defined Test2 as Int by mistake in the header. Thank you (and everyone else) very much for your help, couldn't see for looking.
Under each posted answer, if you're using a mobile to see the forum, or on the right side, there should be 2 options like in the image, and one of them is "mark as solution "
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.