Controlling DIR scrolling

Anything QL Software or Programming Related.
Post Reply
User avatar
Chr$
QL Wafer Drive
Posts: 1304
Joined: Mon May 27, 2019 10:03 am
Location: Sachsen, Germany
Contact:

Controlling DIR scrolling

Post by Chr$ »

Hello, I'm just writing a little SuperBasic prog on an original QL with TK2, to help me manage and unzip the tons of zip files downloaded from Dilwyn's site.

The program can (if you want it to) display a Dir listing of a directory but the directory in question is quite full, so it expects you to press a key to scroll the listing. Fine, but annoyingly the keys pressed to scroll during the program are also 'remembered' and they end up on screen, which sort of ruins the next input request (of a file name) as I first have to delete the entered rubbish keys that I had to press to scroll the dir!

So is there a way to do a Dir and scroll the results without the actual keys pressed being registered/recorded in any way? Like a silent stealth mode for scrolling!

Thanks.


https://QXL.WIN
Collector of QL related computers, accessories and QL games/software.
Ask me about felt pads - I can cut them to size and they have proved excellent for mdv data recovery.
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: Controlling DIR scrolling

Post by Andrew »

dummy = KEYROW(0)

When KEYROW is used any characters in the type-ahead buffer are cleared.


Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Controlling DIR scrolling

Post by Derek_Stewart »

Hi,

Two ways to do this:

1) Open a channel to a file and do a DIR to the channel to open file, then read the files back:

OPEN_NEW #3,dir_list: DIR #3,win1_: CLOSE #3

or with Toolkit 2

ch=FOP_NEW ('dir_list'): DIR #ch: CLOSE #ch

Both give a listing of the default directory.

The file dir_list holds the files of the DIRectory.

2) A more stuble way, is to open the directory and read each file in the directory.

See the online superbasic manual:

https://superbasic-manual.readthedocs.i ... n-dir.html

This gives complicated exa,ple of opening disc dirctories, the Toolkit 2 version use a fuction called FOP_DIR.

I will post an equivalent DIR cammand later, as I am not at my computer.

You need to read the Toolkit 2 manual as well, which allows yoy to use file functions like FTEST, FTYP, which allows selection of files based on the file type, FTEST can tell you if thet exist.


Regards,

Derek
EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Post by EmmBee »

Hi chr$,

I've had this problem myself. The extraneous keys are coming from TK2, and they get stored in #0's input buffer. dummy = KEYROW(0) should work a treat.

If you would like to give us your listing, that would be interesting, and we could then perhaps make some further comments.


User avatar
Chr$
QL Wafer Drive
Posts: 1304
Joined: Mon May 27, 2019 10:03 am
Location: Sachsen, Germany
Contact:

Re: Controlling DIR scrolling

Post by Chr$ »

Thanks everyone.

I'll have a play. I did include a dummy = KEYROW(0), but I suspect in the wrong place! It's my first attempt at a SuperBasic program and I'm really not good at these things, but I will share it when it's done. It certainly helps me to manage zip files and saves a lot of time.


https://QXL.WIN
Collector of QL related computers, accessories and QL games/software.
Ask me about felt pads - I can cut them to size and they have proved excellent for mdv data recovery.
EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Post by EmmBee »

It would appear that the use of KEYROW doesn't actually work. I tried the following ...

Code: Select all

100 DIR win1_
110 dummy = KEYROW(0)
120 PRINT #0,"All clear"
The typed in characters are appearing after the All clear message.
It's beginning to look like the only way would be to avoid using TK2 and do as Derek is suggesting.


EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Post by EmmBee »

Instead of using KEYROW, an INKEY$ loop could be used to suck these unwanted characters out ...

Code: Select all

DIR win1_
REPeat exhaust : IF INKEY$ = "" : EXIT exhaust
PRINT #0,"All clear"


Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Controlling DIR scrolling

Post by Derek_Stewart »

Hi,

Here is a S*Basic implementation of the DIR comand, with no screen pause:

Code: Select all

100 dir$="win1_"
110 ch=3
120 OPEN_DIR#ch,(dir$)
130 no_files=0
140 REPeat loop
150   IF EOF(#ch):EXIT loop
160   GET #ch\no_files*64+14,a$
170   IF a$<>'': PRINT a$
180   BGET #ch\no_files*64+64
190   no_files=no_files+1
200 END REPeat loop
210 CLOSE#ch
Change the variable dir$ for the required drive or directory, also you have make sure that channel 3 is not open.

An enhanced version using Toolkit 2 Functions:

Code: Select all

100 REMark Toolkit 2 style dir routine
120 REMark created 11/3/2000, D.Stewart
130 :
140 REMark File types : 0 = basic files
150 REMark File types : 1 = Exeutable files
160 REMark File types : 255 = Directory
170 :
172 REMark $$external
175 DEFine PROCedure CAT
180 dir$=DATAD$
190 dev$=dir$(1 TO 5)
195 tree$=dir$(6 TO )
200 ch=FOP_DIR(dir$)
210 COUNTA=0
220 STAT dir$
230 REPeat loop
240   IF EOF(#ch):EXIT loop
250   GET #ch\COUNTA*64+14,a$
260   IF a$<>'' THEN
270     file$=a$(LEN(tree$)+1 TO )
280     SELect ON FTYP(\dev$&tree$&file$)
290       =0   : file$ = file$
300       =1   : file$ = file$
310       =255 : file$ = file$ & " ->"
320     END SELect
325     PRINT file$
330   END IF
340   BGET #ch\COUNTA*64+64
350   COUNTA=COUNTA+1
360 END REPeat loop
370 CLOSE#ch
380 END DEFine CAT
The above procedure could be compiled with Qliberator as an external function and add the CAT keyword to SBASIC.


Regards,

Derek
User avatar
Chr$
QL Wafer Drive
Posts: 1304
Joined: Mon May 27, 2019 10:03 am
Location: Sachsen, Germany
Contact:

Re: Controlling DIR scrolling

Post by Chr$ »

EmmBee wrote:It would appear that the use of KEYROW doesn't actually work. I tried the following ...

Code: Select all

100 DIR win1_
110 dummy = KEYROW(0)
120 PRINT #0,"All clear"
The typed in characters are appearing after the All clear message.
It's beginning to look like the only way would be to avoid using TK2 and do as Derek is suggesting.
dummy = KEYROW(0) works for me on my real QL! And your little program above was also fine and didn't show the keys-entered-to-scroll either.

That seems to be the simplest way of getting it to do what I want it to do. Which is good, because using channels, loops and such like just confuses me, a lot (but thanks Derek).


https://QXL.WIN
Collector of QL related computers, accessories and QL games/software.
Ask me about felt pads - I can cut them to size and they have proved excellent for mdv data recovery.
User avatar
Cristian
Aurora
Posts: 960
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Controlling DIR scrolling

Post by Cristian »

I usually press the right arrow key


Post Reply