List to String array

KashMalaga

Member
Licensed User
Longtime User
B4X:
 For n = 0 To fileList.Size-1
    file1 = fileList.Get(n)
   If file1.EndsWith(".jpg") Then
      ListView1.AddSingleLine(file1)
      asd.Append(file1) ' asd (whatever adds file1 to the array)
      End If
 Next
' Example of a fully Array that i would like to have
 'asd = Array As String("IMG-20130112-WA0004.jpg", "IMG-20130112-WA0003.jpg", "IMG-20130112-WA0002.jpg", "IMG-20130112-WA0000.jpg")
Hello dear,

I would like to find the best way to put all name in the array asd, right now i have all of them in a List. So List to String array.

Thanks
 
Last edited:

mangojack

Expert
Licensed User
Longtime User
Hi ... Must the found .jpg files be in an array. ? you already have them listed in your ListView1 , you could just loop thru the listview.

If this does not suit you then you could write the located .jpg files in another list, I did read somewhere this is preferable over an Array

B4X:
Sub GetJPGFiles

    Dim n As Int
    Dim File1 As String
   
    Dim  lstJPGfiles As List
    lstJPGfiles.Initialize
   
    For n = 0 To FileList.Size-1
        File1  = FileList.Get(n)
   
       If File1.EndsWith(".jpg") Then
           ListView1.AddSingleLine(File1)
          lstJPGfiles.Add(File1)      
      
          'asd.Append(File1) ' asd (whatever adds file1 to the array)
         End If
     Next
     
     'Example of a fully Array that i would like to have
     'asd = Array As String("IMG-20130112-WA0004.jpg", "IMG-20130112-WA0003.jpg", "IMG-20130112-WA0002.jpg", "IMG-20130112-WA0000.jpg")

    Msgbox ("The number of jpg files is .. " & lstJPGfiles.Size,"JPG Files")

End Sub

Cheers mj
 
Last edited:
Upvote 0

KashMalaga

Member
Licensed User
Longtime User
Hi ... Must the found .jpg files be in an array. ? you already have them listed in your ListView1 , you could just loop thru the listview.

If this does not suit you then you could write the located .jpg files in another list, I did read somewhere this is preferable over an Array

B4X:
Sub GetJPGFiles

    Dim n As Int
    Dim File1 As String
   
    Dim  lstJPGfiles As List
    lstJPGfiles.Initialize
   
    For n = 0 To FileList.Size-1
        File1  = FileList.Get(n)
   
       If File1.EndsWith(".jpg") Then
           ListView1.AddSingleLine(File1)
          lstJPGfiles.Add(File1)      
      
          'asd.Append(File1) ' asd (whatever adds file1 to the array)
         End If
     Next
     
     'Example of a fully Array that i would like to have
     'asd = Array As String("IMG-20130112-WA0004.jpg", "IMG-20130112-WA0003.jpg", "IMG-20130112-WA0002.jpg", "IMG-20130112-WA0000.jpg")

    Msgbox ("The number of jpg files is .. " & lstJPGfiles.Size,"JPG Files")

End Sub

Cheers mj
Thanks for your answer, but doesnt need another list.Must to be done with a String[]
 
Upvote 0

KashMalaga

Member
Licensed User
Longtime User
In that case after you have the list you can create an array and copy the items from the list to the array.

I already tried all diferent ways, this is why im asking here...

string, stringbuilder, instead i dont wanna have an actual size, so the array must to be unlimited
 
Upvote 0
Top