Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Testing against multiple elements at a time without select case
#5
That's cool too.  Someday I need to do a deep dive into all the stuff you can do with DATA and READ statements.  Here's what I ultimately decided on.  It's very similar to SMcNeill's.  I decided to move the list count outside, so I can track my position in the array regardless of how many times I call this function or others.  I made the extension string its own thing also just to keep my line widths down.  Now I just need to test the thing and see if it works.   Big Grin

Code: (Select All)

Sub LoadFromTxt( txt_file$, names_list$(), list_count& )
    ''load a list of image file names from a txt file
    Dim fp& : fp& = Freefile
    Dim tmp$
   
    Dim f_ext$
    f_ext$ = ".png.bmp.jpg.tga.psd.gif.hdr.pic.pnm.pcx.svg.ico.cur.qoi"
   
    Open txt_file$, For Input as fp&
        While Not EOF(fp&)
            Line Input fp&, tmp$
            tmp$ = _Trim$(tmp$)
            If tmp$ <> "" Then
                ''test for image suffix .*
                If InStr(f_ext$, Right$(tmp$, 4)) Then
                        list_count& = list_count& + 1
                        names_list$(list_count&) = tmp$
                Else
                    Print "Unknown file type " + tmp$
                End If
            End If
        Wend
    Close fp&
   
End Sub ''LoadFromTxt
Reply


Messages In This Thread
RE: Testing against multiple elements at a time without select case - by CMR - 04-17-2025, 02:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  question on determining time spent in area fistfullofnails 9 836 08-25-2025, 01:55 PM
Last Post: fistfullofnails
  Testing for program Install routine. Cross Platform Compatible. ahenry3068 8 1,183 05-20-2025, 11:19 AM
Last Post: SpriggsySpriggs
  how to get a file's modified date/time and size in bytes? madscijr 36 7,745 05-10-2025, 05:17 AM
Last Post: eoredson
  Hard time with hardware acceleration. Pete 8 1,029 03-21-2025, 11:29 PM
Last Post: Pete
  testing a number's quare root is an integer and casting to a value? madscijr 22 3,453 01-29-2025, 11:12 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)