![]() |
Testing against multiple elements at a time without select case - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Testing against multiple elements at a time without select case (/showthread.php?tid=3619) |
Testing against multiple elements at a time without select case - CMR - 04-16-2025 Select Case lets you test against things like this: Case 1, 2, 3, 4, 5 Is there a way to use this kind of expression list with 'If'? I'm trying to make a little program that builds sprite sheets from a list of image files, and I'm testing to see if the file name extension matches an image files. Here's the Sub I'm working on. It just builds a list of file names from the files listed in a text file. Code: (Select All)
I just feel like it would look better with a couple of 'If' statements instead, and was wondering if you could use expression lists with If the way you could Select Case. RE: Testing against multiple elements at a time without select case - SMcNeill - 04-16-2025 Something similar to this? Code: (Select All)
RE: Testing against multiple elements at a time without select case - CMR - 04-16-2025 That's great. I didn't even think of using InStr. Thanks. RE: Testing against multiple elements at a time without select case - eoredson - 04-16-2025 You could also try: Code: (Select All) Sub LoadFromTxt (txt_file$, names_list$()) RE: Testing against multiple elements at a time without select case - CMR - 04-17-2025 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. ![]() Code: (Select All)
|