QMENU hint (or best kept secret?)

Anything QL Software or Programming Related.
Post Reply
Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

QMENU hint (or best kept secret?)

Post 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


David
User avatar
dilwyn
Mr QL
Posts: 2761
Joined: Wed Dec 01, 2010 10:39 pm

Re: QMENU hint (or best kept secret?)

Post 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


Post Reply