Controlling DIR scrolling

Anything QL Software or Programming Related.
User avatar
Chr$
Chuggy Microdrive
Posts: 58
Joined: Mon May 27, 2019 10:03 am

Controlling DIR scrolling

Postby Chr$ » Tue Jun 11, 2019 9:01 pm

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.


I'm Chris, a Brit in the far East of Germany.
User avatar
Andrew
Gold Card
Posts: 268
Joined: Tue Jul 17, 2018 9:10 pm

Re: Controlling DIR scrolling

Postby Andrew » Tue Jun 11, 2019 10:01 pm

dummy = KEYROW(0)

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


Derek_Stewart
QL Wafer Drive
Posts: 1500
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: Controlling DIR scrolling

Postby Derek_Stewart » Tue Jun 11, 2019 10:13 pm

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.io/en/latest/O/open-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
Brittle Membrane
Posts: 101
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Postby EmmBee » Tue Jun 11, 2019 10:44 pm

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$
Chuggy Microdrive
Posts: 58
Joined: Mon May 27, 2019 10:03 am

Re: Controlling DIR scrolling

Postby Chr$ » Tue Jun 11, 2019 11:01 pm

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.


I'm Chris, a Brit in the far East of Germany.
EmmBee
Brittle Membrane
Posts: 101
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Postby EmmBee » Wed Jun 12, 2019 8:13 am

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
Brittle Membrane
Posts: 101
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Controlling DIR scrolling

Postby EmmBee » Wed Jun 12, 2019 8:42 am

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
QL Wafer Drive
Posts: 1500
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: Controlling DIR scrolling

Postby Derek_Stewart » Wed Jun 12, 2019 9:33 am

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$
Chuggy Microdrive
Posts: 58
Joined: Mon May 27, 2019 10:03 am

Re: Controlling DIR scrolling

Postby Chr$ » Wed Jun 12, 2019 9:37 am

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).


I'm Chris, a Brit in the far East of Germany.
User avatar
Cristian
Super Gold Card
Posts: 653
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Controlling DIR scrolling

Postby Cristian » Wed Jun 12, 2019 12:22 pm

I usually press the right arrow key



Who is online

Users browsing this forum: No registered users and 5 guests