Page 1 of 1

QMENU hint (or best kept secret?)

Posted: Tue Feb 16, 2021 1:42 pm
by Silvester
When I first got QMENU I couldn't figure how you could get FILE_SELECT$ to remember the last directory the user navigated to, at least without resorting to DIR_SELECT$. But found there is a very simple way, just give full pathname of last file selected. Like OPEN_DIR it just discards file name part:

Code: Select all

100 OUTLN
110 f$='ram1_'
120 REPeat
130   f$ = FILE_SELECT$('Select file','',f$,'')
140   IF f$ ='' THEN EXIT
150   do_stuff f$
160 END REPeat
170 STOP
180 DEFine PROCedure do_stuff(f$)
190 PRINT 'You are here : ';f$
200 PAUSE 100
210 END DEFine
I only mention it in the hope it encourages some authors to offer the option (Config?), as I find it a little exasperating to navigate some tortuous route only to be cast back to default directory next time :-(

Damp cloth ready to wipe egg off face.

---
David

Re: QMENU hint (or best kept secret?)

Posted: Tue Feb 16, 2021 4:25 pm
by dilwyn
Silvester wrote:When I first got QMENU I couldn't figure how you could get FILE_SELECT$ to remember the last directory the user navigated to, at least without resorting to DIR_SELECT$. But found there is a very simple way, just give full pathname of last file selected. Like OPEN_DIR it just discards file name part:
...
I only mention it in the hope it encourages some authors to offer the option (Config?), as I find it a little exasperating to navigate some tortuous route only to be cast back to default directory next time :-(
Damp cloth ready to wipe egg off face.
---
David
All part of the QL official secrets act, Silvester! The hoops we sometimes have to jump through just to achieve something fairly basic!

Was aware of this, but as it wasn't really documented afraid to use it much with QMenu in case it varied across releases (most of my programs don't use QMenu anyhow).

As you mentioned OPEN_DIR, you can achieve a lot with TK2's FNAME$ to achieve the same thing in file handling - they probably do pretty much the same thing if you drill down deep enough. Use OPEN_DIR to open a channel to a filename and FNAME$ on that channel returns the directory name part of it on a system with directories. Useful on a filename with several separators to work out which directory it came from, to separate a filename into directory and pure filename sans directory name. Most of my programs such as Q-Trans from the last few years use this.

The other David (dden) has a small set of nice and useful routines in basic to handle this, at http://www.dilwyn.me.uk/files/dirnames.zip