wrong expresion do while History.Get(j).CharAt(i)<>0

sarkis

Member
Licensed User
Longtime User
Hi all,
the folowing code doesn' compiled.

do while History.Get(j).CharAt(i)<>"0"
...
loop

where History is a list ,j, i are int

You may say that History.Get(j) is an object, not a string.
If I assign History.Get(j) to a string then use charAt it works.
But
how may I build such expression in one command line?
Any ideas ?
Thanks for answers.
 

Jost aus Soest

Active Member
Licensed User
Longtime User
In such cases I like to use a VB-like CStr-function:
B4X:
Sub CStr(o As Object) As String
  Return "" & o
End Sub

Than you can modify your code to:
B4X:
Do While CStr(History.Get(j)).CharAt(i) <> "0"
  '...
Loop

BTW: Are you sure, that every object (string) in the list has a minimum length of i?
 
Upvote 0

sarkis

Member
Licensed User
Longtime User
Thank you for replaying.
I catch your idea.
Here is a solution that I make using your idea.
Do While ("" & History.Get(j)).CharAt(i) <> "0"
 
Upvote 0
Top