File selection with file name containing a wildcard

Discussions related to database technologies, file handling, directories and storage
Edja
Posts: 69
Joined: Tue 03 Apr 2018, 12:07
Location: Belgium

File selection with file name containing a wildcard

Post by Edja »

I've stumbled on an issue I hope someone can help me with.
I have several files Car11.xlsx, Car75.xlsx, Car8456.xlsx and so on ...
After I OPENUP a file with a name containing a wildcard (Car*.xlsx as shown in the snippet) the dialogue opens and I choose one of the files. From that point on I need to know the filename in the rest of my program (even if the file handle allows me to access the file)

The following simple code snippet illustrates that the filename returned is still Car*.xlsx
I was hoping -naively- that FileName$ would be set to the actual filename selected in the dialogue.
Is there a way to make FN_Open_File return the filename selected?

Code: Select all

      Name$ = FN_Open_File("C:\Users\Erik\Downloads\Car*.xlsx")
      PRINT Name$
      END

      DEFFN_Open_File(FileName$)
      A=OPENUP FileName$ CLOSE#A
      =FileName$
Regards,
Edja
Richard Russell
Posts: 714
Joined: Tue 18 Jun 2024, 09:32

Re: File selection with file name containing a wildcard

Post by Richard Russell »

Edja wrote: Tue 28 Jul 2026, 17:37 The following simple code snippet illustrates that the filename returned is still Car*.xlsx
Of course. The variable FileName$ is never modified in the code you listed, it is only passed as the parameter of an OPENUP function.
I was hoping that FileName$ would be set to the actual filename selected in the dialogue.
If that's what you want to happen, it's up to you to code FN_Open_File( so that it does; the Wiki lists two methods of achieving that.

But I don't recommend passing a wildcard to OPENIN/OUT/UP in the first place because that is a feature unique to BB4W (not even BBCSDL has it) and hence is completely non-portable between platforms
Edja
Posts: 69
Joined: Tue 03 Apr 2018, 12:07
Location: Belgium

Re: File selection with file name containing a wildcard

Post by Edja »

Hi Richard,

Even if the information is extremely well documented, I manage to ignore what is so easy to find. My apologies !
So I've changed the final line and it now does the job.

Code: Select all

      Name$ = FN_Open_File("C:\Users\Erik\Downloads\Car*.xlsx")
      PRINT Name$
      END
      DEFFN_Open_File(FileName$)
      A=OPENUP FileName$ CLOSE#A
      = $$!420e$
I don't recommend passing a wildcard to OPENIN/OUT/UP in the first place because that is a feature unique to BB4W (not even BBCSDL has it) and hence is completely non-portable between platforms
I fully appreciate your point about portability. The need to know the FileName$ only came up to improve a program I've used over the last 10-15 years. From time to time I enjoy revisiting the code and make minor improvements that don't touch the overall logic and flow of my program. If/When Microsoft decides to make steps that would make it impossible to use the COMLIB Library (in BB4W only) then I will have no choice then to rewriting my code.

Thank you for your support !
Edja
Edja
Posts: 69
Joined: Tue 03 Apr 2018, 12:07
Location: Belgium

Re: File selection with file name containing a wildcard

Post by Edja »

Sorry, typing error. Pls. replace the code line

Code: Select all

= $$!420e$
with

Code: Select all

= $$!420
Edja
Richard Russell
Posts: 714
Joined: Tue 18 Jun 2024, 09:32

Re: File selection with file name containing a wildcard

Post by Richard Russell »

Edja wrote: Wed 29 Jul 2026, 09:31 If/When Microsoft decides to make steps that would make it impossible to use the COMLIB Library (in BB4W only) then I will have no choice then to rewriting my code.
I can't remember who it was or when, but I'm sure somebody showed that COMLIB does work (either with no modification or a trivial one) in BBCSDL, on Windows. So if what you're concerned about is Windows dropping support for 32-bit apps, that provides a way forwards. If you're worried that Windows might disappear altogether you're stuck, but that seems unlikely. :D

So long as Windows continues to support SDL2 (or SDL3 via sdl2-compat, which I've demonstrated does work with BBCSDL) and OpenGL you should be able to run BBC BASIC and probably COMLIB. I know OpenGL is deprecated in MacOS, but I've seen no rumours to suggest that it won't continue to be supported indefinitely in Windows.