S sarkis Member Licensed User Longtime User Mar 27, 2012 #1 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.
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.
margret Well-Known Member Licensed User Longtime User Mar 27, 2012 #2 Try this code: B4X: Do While History.Get(j).CharAt(i) & "" <> "0" ... loop Upvote 0
J Jost aus Soest Active Member Licensed User Longtime User Mar 27, 2012 #3 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
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?
S sarkis Member Licensed User Longtime User Mar 27, 2012 #4 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
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"