B4J Question Cannot return a list

B4JExplorer

Active Member
Licensed User
Longtime User
...
...

Dim lst_This As List

'*****************
'THIS returns an 'array expected' error:
lst_This = GetThisList()
'*****************


...
...

End Sub


Sub GetThisList() As List
Dim lst_ThisList As List
lst_ThisList.AddAll( Array As String( "a", "b", "c", "d", "e" ))

Return lst_ThisList
End Sub


(Sorry, I forgot how to format code snippets on the forum, again)
 

giga

Well-Known Member
Licensed User
Longtime User
This is how you insert code:
upload_2015-8-10_15-34-56.png
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
try this

B4X:
Dim lst_Audits As List


lst_Audits = GetThisList

...
...
End Sub

Sub GetThisList As List
Dim lst_ThisList As List
lst_ThisList.Initialize
lst_ThisList.AddAll( Array As String( "a", "b", "c", "d", "e" ))

Return lst_ThisList
End Sub
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
try this

B4X:
Dim lst_Audits As List


lst_Audits = GetThisList

...
...
End Sub

Sub GetThisList As List
Dim lst_ThisList As List
lst_ThisList.Initialize
lst_ThisList.AddAll( Array As String( "a", "b", "c", "d", "e" ))

Return lst_ThisList
End Sub
try this

B4X:
Dim lst_Audits As List


lst_Audits = GetThisList

...
...
End Sub

Sub GetThisList As List
Dim lst_ThisList As List
lst_ThisList.Initialize
lst_ThisList.AddAll( Array As String( "a", "b", "c", "d", "e" ))

Return lst_ThisList
End Sub
Yep, I remove the parentheses, works fine, thanks.
 
Upvote 0

giga

Well-Known Member
Licensed User
Longtime User
I don't see that top formatting bar.


What browser are you using? Try a different browser like Internet Explorer or Mozilla Firefox.

alternately you could use code before and after like below example.

use[word code] before and at the end of you code [/word code] " remove the word (word) from this example"

B4X:
Sub Globals
...
End Sub
 
Last edited:
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
What browser are you using? Try a different browser like Internet Explorer or Mozilla Firefox.

alternately you could use code before and after like below example.

use[word code] before and at the end of you code [/word code] " remove the word (word) from this example"

B4X:
Sub Globals
...
End Sub
Yep, I got it, Giga, thanks. The CODE syntax, was what I used before, and couldn't recall.
 
Upvote 0
Top