Jump to content
Sign in to follow this  
gnosis3d

Removing parts of an Array

Recommended Posts

Not new to AutoIt, but new to arrays...

I am doing an FTP file list via array. This is outputted to a GUI List. However, I only want to display certain files in this list (basically, only lines w/ particular file extensions).

I am not fully understanding how to actually REMOVE lines, or the opposite... pull particular lines OUT of the array and put them to a new array.

Reference material would be nice. I can't find anything thusfar that fits this description (although the Search Forums brings up waaaay too much).

This is what I've found in the forums and modified for my own usage:

$ListPDF = _FTPFilesListToArray($Conn,2)
    If (Not IsArray($ListPDF)) Or (@error = 1) Then
        sleep(2)
        Return
    EndIf
    For $y = 1 To $ListPDF[0]
        GUICtrlSetData($inprogressGUIListPDF, $ListPDF[$y] & "|", 1)

The $ListPDF is the array. How would I remove lines based on, for instance, ".jpg" or ".iso"? Again, the opposite would work as well. Extracting just ".pdf" extensions to a new array to output to the GUI List.

Thanks in advance.

Share this post


Link to post
Share on other sites

$ListPDF = _FTPFilesListToArray($Conn,2)
    If (Not IsArray($ListPDF)) Or (@error = 1) Then
        sleep(2)
        Return
    EndIf
    For $y = 1 To $ListPDF[0]
    If StringInStr($ListPDF[$y], '.pdf') then
        GUICtrlSetData($inprogressGUIListPDF, $ListPDF[$y] & "|", 1)
    Endif

Lookup StringInStr in the help

Share this post


Link to post
Share on other sites

If StringRight($ListPDF[$y], 4) = '.pdf' Then GUICtrlSetData($inprogressGUIListPDF, $ListPDF[$y] & "|", 1)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...