MAY-JUN 9 1 VOL. 9 NO.3

SINCLNK

VOL. 9 NO.3

MAY-vJUN '91

SINC-LIMC IS A PUBLICATION OF THE TORONTO TIMEX -SINCLAIR USERS CLUB AND IS ISSUED 6 TIMES A YEAR. COPIES OF THE NEWSLETTER ARE Si. SO EACH FOR NON-MEMBERS. CLUB MEMBERS RECEIVE FREE COPIES AS PART OF THE 920.00 ANNUAL MEMBERSHIP FEE. A NEWSLETTER SUBSCRIPTION ONLY IS AVAILABLE FOR Si 2. 00.

NEWSLETTERS ARE EXCHANGED, FREE OF CHARGE , WITH OTHER TIMEX-SINCLAIR USERS GROUPS.

PLEASE CREDIT THIS PUBLICATION AND THE AUTHOR IF YOU COPY MATERIAL.

THE CLUB MEETS ON THE FIRST WEDNESDAY OF EACH MONTH AT FOREST HILLS COLLEGIATE INSTITUTE, 730 EGLINTON AVE. W. , TORONTO. START TIME: 7:00 PM.

SEND CORRESPQNOANCE TO:

Attmnttam SING-LINK EDITOR TORONTO TIMEX-SINCLAIR USERS CLUB, 14 RICHOME COURT, SCARBOROUGH, ONTARIO, CANADA M1K 2Y1

EXECUTIVE OFFICERS:

TORONTO TlttEX-SINCLflm USERS CLUB

PRESIDENT TREASURER SECRETARY

ACTIVITIES:

TAPE LIBRARIAN ZX81:

TAPE LIBRARIAN 2066:

TAPE/DISK LIBRARIAN QL;

PAPSl LIBRARIAN:

NEWSLETTER:

LIAISON OFFICER:

( Out-of-town members )

(Area Code 416) RENE BRUNEAU ( 531-9749 ) BILL LAWSON ( 444-8772 ) GEORGE CHAMBERS ( 731-7339 ) RENE BRUNEAU ( 531-9749 ) LYMAN PAQUETTE ( 482-4479 ) RENATQ ZANNESE ( 635-6336 ) HUGH HOWIE ( 634-4929 ) JUT TAYLOR ( 244-8583 ) JEFF TAYLOR ( 244-8583 ) GEORGE CHAMBERS. 14 RICHOME COURT. SCARBOROUGH. ONTARIO. M1K 2Y1 ( 416-751-7559 )

S I

2

SINC-LINK

Editorial

I really must thank a few of the club members for their kind words about my third anniversary as newsletter editor. It's very gratifying to hear from our brothers and sisters within the T/S community and I can assure you that your letters and cards have certainly bolstered my resolve to continue to try to put out a quality product for you.

So, to Joan K. , Les C, Donald L. , Larry C. and all the members who were so complimentary, my heartfelt thanks.

I can't take all the praise for Sine-Link's success, though. While I do the assembling, the cover and occasionally an article, it is the continual high-quality writing of you active members that makes this newsletter the fine publication it is today. All you members who have contributed over the last three years and all you writers whose work we have culled from other newsletters because we felt it was worth repeating, take a bow. Alright, enough mushy stuff.

MSCRIPT 5.5 & TASWORD 22M

I recently received the MSCRIPT update from Jack Dohany (no E) and a TASWORD 2 variation from Larry Crawford and am now trying to learn all the features these two prolific programmers have built into their versions. This editorial is a combination of both programs. Can you spot where they start and stop?

More TPS Info

In the last couple of issues I'd written about my exploits in repairing one of our TOS/ZEBRA/Engl ish Micro Disk sytems and a request for information on this disk system. Well, I'd like to thank Joan Kealy for offering to send me her backup and in particular I'd also like to send my thanks to James Wilson who took it upon himself to assemble and send me a great package of material on this subject. If more material comes in I'd be glad to exchange what I've received with interested members. Drop me a line and let's keep supporting another T/S utility.

ZX81/TS1000 Hi-Res

Last issue I wrote about the newest additions to the ZX81 library, namely two tapes full of hi-res programs courtesy of Greg Harder. The demand for these tapes has been quite surprising. Members that we didn't even know had ZX81s have been asking for copies. Bear with us and we'll get those tapes and manuals to you. It just takes time to make good quality copies.

Digitised Pictures

In last issue there were a few digitised pictures of yours truly. I am now running a closed circuit tv camera through my SMUG digitiser and using John Mcmichael's VIDEOTEX software. Watch for a review of his updated program and more digitised pictures next issue. That ' s all for now. . .

J.T.

SINC-LINK

3

BOB'S NOTEBOOK- Programing Tips

Here is an example of how to use a rather obscure LKDOS Extended BRSIC Command. It concerns that pesky line of dots that appear at bottom of the screen whenever the NMI push button is pressed. Those dots, which actually represent the registers and stack pointers involved, clutter any graphics copies which print the bottom two lines. However, close reading of the LKDOS Operating Manual turns up an interesting item: Advanced machine code programmers can add an extra command to LKDOS by using the PRINT 1*4: DATA a , b , c ... command. Moreover, more reading reveals another clue from the manual: LKDOS address 8214 User ad holds the address of the user NMI function Oft tf*& <94*<**~&ss &f Os**r cr&mm&nei (£WT/3> .

If this could be used to trigger a graphics-copy machine-code routine without pressing the NMI button and the F key, then it should be possible to make an uncluttered copy on a wide printer, that is, without those dots. Graphics 24 is one such routine which copies all 24 lines of a SCREEN* and is found in the Omnibus Collection where it loads into the LKDOS at address 16100. Thus, it ought to be possible to substitute the LKDOS DATA command for the NMI button. On investigation, this turned out to be the case. The following lines, which appear in the Omnibus program, were involved in making the DATA command work:

1020 INPUT AT oo, oo; (uS' "drive? <0-4> ")jdrv: PRINT ttod: GO TO drvi RETURN

1050 PRINT #od: POKE oz, 16100: LET b=USR oy : RETURN 2578 PRINT AT 00,00; "Standby ..." : GO SUB 1050: IF b<>205 THEN FOR i =24685 TO 24788: PRINT #od : POKE i-8505,PEEK i: NEXT i 258© PRINT Hod: POKE 8214,16100

2590 CLS : PRINT AT 00, 00; "CHECK Printhead at left each time.": PAUSE 100 : RETURN

538© GO SUB 5410: ON ERR GO TO 5390: INPUT AT 00,00;" C0PV SCREENS "'" name? (<=9> ' LINE s*: GO SUB 1020: GO SUB 5500 : PRINT ttod: LOAD s$SCREEN$: PRINT ttod: DATA 0 5390 ON ERR RESET: GO TO m3

5410 CLS: GO SUB 1050: IF b<>205 THEN GO SUB 2570: RETURN 5420 RETURN

Exp Sanations :

Line 1820 is a sub routine to choose the drive. < u* is used throughout the program to hold the name of a chosen option) . Line 1050 does a double poke into LKDOS RAM 8200 (variable oz) to get the value in LKDOS address 16100.

Lines 2570 to 2590 check that value and if it is not 205 then it reloads the contents of system variables free space 24605 to 24788 into the LKDOS RAM at address 16180 (24605 minus 8505>; 2588 puts the value 16100 into LKDOS address 16180 and finally 2590 puts a reminder on-screen before returning.

Line 5380 checks that all is ready via 5410; if there is an ERR message (see below) , the action jumps to line 5398 and thence back to the menu. Don't leave out 5420.

The crux of all this is the part at the end of line 5388: PRINT ttod: DATA 8. Not knowing what to add after the DATA token, I stuck in the zero. However, no matter what was put in there, an error message resulted each time so ON ERR commands were added to overcome the error. Result: the routine worked and the line of dots was history. By the way, the NMI button F still does its job when these changes are made, so it's always there as an alternative.

One postscript to this story: I later had a go at making the autoboot code, stored at 16308, work in a similar fashion. During a lot of experimenting a funny thing came to light: the command line had to be <PRINT H4 : DATA 0 > ; the computer crashed (locked up) if < RANDOMIZE USR 100: DATA 0> was used. (I haven't the foggiest notion why. Can anyone help explain this?) So this means that to quit any program and get back to Omnibus, the PRINT #4 switch has to be operative in that program.

§®K1S Dfl®(3@ PK®@l30!?flKlSK]© IFSPS

SINC-LINK

PROFILE: When altering the BASIC program* be careful not to declare any variable ahead of dS . This string must be the first variable in the UARS area or the program simply will not work.

PRINTER CONTROL CODES: There are two distinct methods of sending these to your printer. The FIRST one often used in programming, uses OUT commands to do the job. For example, to switch to ELITE typeface requires OUT 127,27: OUT 127,77. BUT, there must be a check on printer readiness before the commands and this can vary from printer to printer and even from one TS2868 to another. Thus it is necessary to make the f o 1 1 owi ng : < GO SUB lme#> prior to each OUT command. The 1 ine# is the line containing a routine such as <IF IN 1270237 THEN GO TO line#ft>; line* +1 must be < RETURN > .

The SECOND one, perhaps not much used, is really more straight forward: This assumes you are using the LKDOS printer driver and depends on first switching off the detokenizing and filtering Cby POKING PPAS at LKDOS RAM address 16693 to 32> which then causes all subsequent characters to be sent directly to the printer. PPflS is POKEd with a zero at the close of sending these printer commands to return to detokenizing and filtering. Thus the subroutine to turn on ELITE typeface becomes:

RANDOMIZE USR 188: POKE 16893,32

LPRINT CHRS 27; CHRS 77

RANDOMIZE USR 188: POKE 16893,8

RANDOMIZE USR 188: POKE 16894, marg: LPRINT: RETURN No printer ready check is needed but note that the margin setting must be repoked since the double poke to 16893 upsets it. So if you find some of the first style printer commands cause you problems with your printer and/or TS2868, switch to the second kind.

MORE ON PRINTER CONTROL CODES

I've recently added the following to both my Tasword and Mscript 1 ists .

First trsuord : This assumes you have Graphics editing capabilities in your copy of Tasword. British Font ON <27 82 2> OFF (27 82 8): these could be different for your printer; check your manual. I put these on key 6 <137 and 134 respectively). The main use for this font is to get the pound sign to print instead of a # sign. But the application has other

possibilities: If you write in French or Spanish and these fonts are included in your printer's memory, substitute them to get the necessary accented letters.

Another addition <this time on the 5 key 138 and 133>> was a quick switch from standard line spacing to narrow line spacing and vice versa. The commands will vary from printer to printer but for the Fastext 88 they were Narrow ON <27 65 8> OFF C27 58 >. This allows for packing more text into a page or part of a page .

Now MSCRIPT: Vou will need instructions for LCODES provided with Mscript version 505 to do this. The codes above or your equivalents will be added to the LCODE text. I put the line spacing against capital A for ON and small a for OFF. British font ON against capital B and OFF against small b. I see that the French font could go into capital F and small f. Mscript has lots of spare letters available for additional commands whereas Tasword is quite limited.

KEYBOARD IDIOSYNCRASIES

Using INKEV* for keyboard input to any program invites some troubles since the ROM Debounce and Error Detection routines are not used. Debouncing is the conversion of mechanical contact bounce into a clean transition between two logic states. It involves the disabling of the software's ability to accept a character for a few milliseconds after receiving one. This prevents false input or extra signals from a keyboard due the bouncing of the keys. Keys sometimes tend to bounce due to inherent design or the keyboard being old or heavily used.

If you have trouble with INKEV*, it may be wise to substitute some BASIC lines that call on the ROM LAST K routine which does

SINC-LINK

5

u.. the ROM flounce and error deyction^outinjs. These^i 1 lp# inline." ike ttlf ol iZviZV <f ound in 0MHIBU8> , 3148 PAUSE oo: LET lk=PEEK 23568

3158 IF lk=13 THEN 60 TO 3128 drv-lk-481 rR!STI#4?kG04?0Rdr^kr5inTTS!H18!59frFLHlH 1{

Uri !? ?R<?!»25^b>ii?.ISEH 60 T0 3148

3188 GO TO 3188+< lk-96>*18

explain:

ur.r<»s IS^tiS: SKiS;%f tnesBEE?ber

JCKSSftS.^?*1?!- K ou?,!a.#tn. SaTues'for k,SS a to z. then

^If^he input f-rvlv.. -II tJJJK conditions, then go to the line number indicated by the formula.

There's more to be read about this subject in Update Apr 89 P . i: and Apr 88 page 28.

Bob Mitchell Willowdale Ont Dated: 918223

•000 118 1113 C0MP0TIIS

i in 30FTM8U mua in

gjgK : ft paarful aceoatiag progra for the QL $75.00 a 2 disks

ajSOi is a MCHITI based accounting progra for «t ad 11 Sdaa parable. receivable, ad gaerai ledger adala lateaxated nth a addrea databae progra. DMddra. gLIRR ba cheek anting andinwicing Milt in. It aa keep Irak of year IMU Mister Charge or other charge Sds. sank balaciag is e«f nth QUlK's help-Ia am display ill |«r checks ad deposits ad eoapare tha nth jeer oak stataats. da t ua to a 8 predefined tccoat ceding system Ton a. tha one yon m*. Iba yea rw the gaerai ledger, each aeeeafc is indmdue ly tallied alia ioeoM U& tia i aa. It ales a gaaral ledger eiport file for IBK3S.

I baa developed QLBK aer tha pat 3 jtus arking nth several baiaessa. I baa nr,»T hadreds of boars of dwelopaat ark in this progra. baa bea careful aot to releae it too soa bat aa fal it is ready. *t $71.86 QUBE is a pretty eipasite piece of softnarn bat these .ha ant to keep track of their fiaaca it has a eaal a tha QL and .ill gnckly ar for itself. It ba any fatara that are eapeaire PC sweating «rft«a» like Peacbtra and OftC lay fail to inelade like adding aa fenders, ca oars accaaS .Tprodats on ch. fly. Tha addraa database fatura ar. ^ZT\ [a oaa for bung able to target subgroups for nailing labels or other parpaa. 1 PC Tenia of QLBa using PC Main is also ui the arks.

0«'t send aaey for QLUK. To order QLHW first send a revest for a are detailed dacriptioa and special order fora that nil ask for iafaratia. Eaeh purchaser of QLZRK till at a cata copy of the softeare 1 .ith their boa or baiaess eabedded is the code.

ft Bill Cable : 113 Sos !2 : Cornish, II 83745

V H3 67S 2218

SINC-LINK

Q L I P S

By Hugh H Howie

GARBAGE: GETTING RID OF IT

One night recently I had a phone call from a QL'er, and during the process of yakking, he mentioned he was having a small problem with loading some programs with long names. The problem was not so much that he could not load the program, but that he hated having to type in all those letters in front of the File Name,

I was able to tell him there was a program in the QL Library called DIRJEDIT_BAS, by Howard Clase, that would do an excellent job for him, I also said I could remember giving him that program some time back. Later that week my friend said the program was really wonderful, and had saved him a lot of time in getting rid of a lot of garbage.

I had a couple disks given to me some weeks ago but had never done much with them, as each and every title started off with 'Listl' or fList2' so that every time I started to work with them I had to type in those extra letters. Too much work. So last night I thought of trying this program on them, but the thought came to me that perhaps there could be an even easier way to my job. There is! Most of us have it right at our fingertips. TK2.

Section 5 of TK2 tells you how it is done. But is somewhat obscured as it is tagged on at the end of the section, tucked into half-a-dozen lines at the very end. All it says is that "Renaming is a process similar to COPYing a file" So I went after the COPY. And those extra bits tagged on at the front of a file name, can be swept away in the blink of an eye. I mean that. Very quickly. Like FAST man!

Say you have a disk on which every title starts off with "LIST1". It will look like this:- Listl_Garbage

Listl_MoreGarbage.

Listl_etc

Put the disk in shall we say, FLP1, and type:- WREN FLPl.LISTl^FLPl

(note comma) Just look at that and remember it, as one day you are going to use it.

Press [ENTER], and watch the "LIST1" go.

§

TURTLE-GRAPHICS (TERRAPIN?)

I keep looking for little things for you to punch in for yourselves, to give you something to do, and also give an insight into the various aspects of programming.

This time it is a small fancy little snippet of a Turtle Graphic. Not quite as slow as a turtle, but it sure has more twists aad turns than a turtle. A bit faster too, but the patterns are interesting. So why not sit down with me and have bit of a rest from all that hard stuff.

This came to me with a lot of other stuff, some good, some not so good. Some I don't know whether it is good or bad as it does not work for me. I recently got Minerva, and I understand that some of the earlier material does not work on it. I still am trying to learn about Minerva. But she sure is one COOL lady. The QL really is a lot cooler.

Here is the little listing for you to type in. I can send it to you, but it is cheaper this way.

100 REMark Turtle graphics

110 WINDOW 512,256,0,0

120 PAPER 0:CLS

130 PENDOWN

140 RE Peat logo

150 IF RND>.68 THEN CLS

160 note=RND

170 POINT 60,60

180 INK RND(1 TO 7)

190 turtle=RND(3 TO 70)

200 terrapin=RND(25 TO 340)

210 FOR k=l TO turtle

220 MOVE k/.7

230 TURN terrapin

240 BEEP 3200,k/note

250 END FOR k

260 IF INKEY$<>"" THEN STOP

270 END REPeat logo

Now was that not fun? Would you like another? Well space is getting a wee bit short so we will leave it off for another time.

In the meantime, 'night all, and have pleasant dreams of circles flashing round in front of your eyes. 'Bye §

SINC-LINK

7

MORE ZX81/TS1000 HI-RES PICTURES

NOTE: YOU MUST HAVE NON- VOLATILE MEMORY LIKE THE MODIFIED HUNTER BOARD, THE SCRAM BOARD OR THE ON -BOARD STATIC RAM BOARD PLUS EXTENDED MEMORY TO RUN THESE PROGRAMS. CONTACT THE CLUB FOR MORE INFO.

8

SINC-LINK

PUBLIC NOTICE REVISED

It's true that I'm trying to get away from the retail business side of things, but my intention is to make things EASIER for folks, not harder! When it comes to filling orders, I'm often the slowest of the slow. In theory at least, a dealer has nothing to do except fill orders, whereas there are often long periods of time when I cannot fill orders due to the press of other things. However, if a person is unable or unwilling to get something from a dealer, that person is welcome to try me. Here's what I'd like:

1. Please state clearly what it is that you want.

2. Please describe your hardware completely.

3. Please include SASE with your order.

4. Please write concisely and don't ask a lot of questions.

5. Send no money. I will include bill with shipment.

6. Be prepared to wait; I am sometimes VERY slow.

I will use your SASE to acknowledge your order. I'll let you know if your order will take longer than 30 days, or if I'm unable to fill your order. If you don't like what you get, or find the price too high, you can return it. Returns are always welcome. If what you ordered exceeds your budget limits, you can pay for it over a period of time to suit your budget.

Here's what I'm currently working on:

1. A dealer price list... very complex, trying to simplify.

2. A CONFIG program which will enable the user to easily configure WORD MASTER and TYPELINER for just about any dot-matrix printer. Adaptable to other software which is fussy about printers.

3. TECH DRAW V3 (now completed) for any disk system. For mouse, trackball, joystick or keyboard.

4. MOUSE DRIVER for use with Zebra A/D + Radio Shack Color Mouse. Nearly done. Will be quite nifty.

5. A LOADME program which will enable the user to easily load and print documentation files on disk in Mscript or Word Master format, without owning or knowing either word processor. Will be provided free on all disks containing docs in MS/WM format.

6. DEVPAC documentation, long overdue.

7. An improved version of SPECTERM64 which will include support for the AERCO dual-channel RS232 interface.

8. A new and improved version of the AERCO RS232 interface.

Jack Dohany 390 Rutherford

Redwood City, CA 94061 April 5, 1991

SINC-LINK

SuperBasic Tutorial Part 2 Printing in Columns

In the first episode of this exciting serial I showed you how to structure a simple program so that it could easily be expanded and improved without loosing track of where you are. All we have to do is to consider a statement, think how it might be improved, write the improvement as a FuNction or PROCedure and call it by name from the original statement. The program was one to print the directory of a storage device (disk or mdv cartridge) onto paper that had appeared in an earlier issue of Sine-Link. The first modification we made was to give the user the option of either accepting program's suggestion for the source of the directory or putting in one of your own without having to stop the program and EDIT a line«

I left you with the problem of altering the program so that the default offered doesn't always revert to the one built into the program in the PROCedure "Set_up", but uses whatever device you used last time. There are two ways to do this, one is to modify line 220 (not 210 - my mistake) as follows:

220 dev$=Get_dev$(dev$) :DIR#3,dev$

The first statement can change the value of the global variable dev$, which couldn't happen in the earlier version. The other way would be to change the dv$ variable to df$ throughout the FuNction GetJDev$, this means that df$, an alias (formal variable) for dev$ within the function, could be altered and dev$ along with it. But I don't favour this way of doing it, it's a bit too mysterious!

Another point struck me while re-reading what I wrote last time: some beginners might be puzzled about the use of CHR$(10) and CHR(12) in the program. These are ASCII control codes which cannot usually be typed in from the keyboard; CHR$(10) is an exception, it's the <ENTER> key, also known as line feed (LF), since that's what it does both on the screen and on the printer. (You can also generate it with <CTRL J> - try it!). CHR$(12) is form feed (FF) and does nothing on the QL screen, but has a

noticeable effect on the printer - it moves to a new sheet of paper at the end of the run. (On some micros it clef the screen - but not this one!) One other code worth mentioning here is CHR$(13), carriage return (CR) , which on the QL screen is implied in the LF, and probably on your printer if you have set the DIP switches to their most useful settings.

If you have tried our program as it stands you will probably have noticed that it only prints one name on each line, and since file names are generally rather short this is a shocking waste of trees. Wouldn't it be nice to print it in several columns across the page, like, for example, Quill does on the screen when you ask for a list of your _docs? That is what we are going to look at in this episode. The first thing we have to do is to identify the line that we need to alter, i0e. the one that actually instructs the computer to send the directory from the mdv tape or floppy to the printer. We have to look no further than line 220; it is the DIR#3 command that does it. We have intercept the stream of file names tha . this command spews straight down the serial port. This is where the QL's flexible handling of channels come in handy.

Aside on channels.

A computer would be useless unless you could put information into it and get something back out - it needs to be able to communicate. Information can be put into the computer from the keyboard, from a file on tape or disk, via the net etc. Output can be obtained on the screen, on a printer or it can be put into a file. Some computers have different commands for dealing with different kinds of devices (e.g. PRINT to the screen, but LPRINT to a printer) s but to the QL they are all just numbered channels. The commands you use are the same irrespective of the device at the other end of the channel. (Although some are inappropriate - like CLS to a printer channel.) When you open a channel you have to tell QDOS what kiri of input/output device it is, and it

10

SINC-LINK

Super Basic Tutorial Part 2 Printing in Columns

sets up the appropriate "driver" to look after the details for you.

Back to our columns.

The DIR command directs the list of file names to a numbered channel, so we can intercept it if we make the channel a file rather the printer. Then we can read it back from the file into an array, and get full control of the list of file names as we print them out. Printing them out at regular intervals across the page is easy, but proper printing in columns involves going down each columns in turn from left to right; and that is what we shall do - phone book order is what I am aiming at.

The listing contains all the lines you will have to alter or add to Prt_dir2 to upgrade it to Prt_dir3. It is not a complete program in itself; it will not run by itself. Type in the listing, and save it under some temporary name (e.g. mdvl_Prt_dir_UG) . Then load Prt_dir2 and MERGE in the upgrade. You must do it in this order since lines with the same line number are overwritten during a MERGEr, and we want the later versions to stand. This assumes you have the same line numbers as the listing published in part one; if you have RENUMbered, then you will have to be very careful and make the alterations by hand.

Upgrade Listing

When merged with Prt_dir2 these lines convert it to version 3, do not try to RUN them on their own!

100 nm$ = "Prt__dir3"

110 REMark hjc 1991.03.13 Ver 0.33

162 temp$= ' raml_temp_dir '

164 chars%=80: REMark output line

166 cols%=4

220 Col_dir 3,Get_Dev$(dev$)

630 REMark * *****

640 DEFine PROCedure Col_dir(ch£,dv$) 650 LOCal a$,nl%,i,n%,st$(2,30),rows% 660 n%=0: nl%=chars% DIV cols^-1

670 Make_array dv$

680 PRINT#ch&,st$

690 PRINT#ch2>: FOR i=l TO rows%

700 FOR j=0TO cols^-1

710 a$=ddir$(i+j*rows%)

720 PRINT#ch%, !Procrust$(a$,nl%) ;

730 END FOR j: PRINT#ch%: END FOR i

740 END DEFine

750 REMark ***

760 DEFine PROCedure Make_array(dv$)

770 LOCal a$,c$,i: c5fc=ch%+l

780 REMark Put directory into file

790 DELETE temp$: OPEN_NEW#c%, temp$

800 DIR#c%,dv$: CLOSE#c%

810 n%=Line__count(c%,temp$)-2

820 rows%=nVcols%+.499

830 n$=cols%*rows%

840 DIM ddir$(n%,nl%)

850 OPEN_IN#c%,temp$

860 FOR i =l,2:INPUT#c*,st$(i)

870 FOR i=l TO n%

880 IF E0F(#c5fc): EXIT i

890 INPUT#c5fc,ddir$(i)

900 END FOR i

910 CLOSE#c$: DELETE temp$

920 END DEFine

930 REMark *

940 DEFine FuNction Line_count(ch%,f $)

950 LOCal a$,ct,n&:n5fc=0

960 REMark Count no. of lines in file

970 OPEN_IN#ch%,f$

980 REPeat ct

990 IF EOF(#ch%): EXIT ct

1000 INPUT#ch&,a$: i&-n%+l

1010 END REPeat ct

1020 CLOSE#ch%

1030 RETurn n%: END DEFine

1040 REMark * **

1050 DEFine FuNction Procrust$(r$,p%)

1060 LOCal 1%: l$=LEN(r$)

1070 IF \%>p%

1080 r$=r$(lTO p%)

1090 ELSE r$=r$&FILL$(" " ,p%-l%)

1100 END IF

1110 RETurn r$: END DEFine

(This series will be continued in the

next issue)

(c) 1991 H.J.Clase

Howard Clase

(709) 753-6415

Box 9947, Station B,

St John's, Nfld, A1A 4L4

email hclase@munucs.ucs.mun.ca (Note

SINC-LINK

11

SuperBasic Tutorial Part 2 (Continued) Printing in Columns

First we need to bring the version info up to date (100 & 110). Before we get to the main additions it is necessary to define a few more global variables, and the best place to put these is into the PROCedure Set_up (lines 162, 164 & 166) .

Temp$ is the temporary file we shall have to set up to hold the directory* If you have ramdisk use it here, if not replace raml_ with any device (flp or mdv) that will have a bit of space on it. Using a variable in this way means that you only have to alter the name once to change it thoughout the program.

Chars% is the number of characters in the line of the output device; this is normally 80, but to save paper while I am testing the program I use a screen for channel #3 which is only 37 characters wide. (This is an example of the usefulness of the QL's channels; all I have to do is to alter the definition of channel #3 in line 160 to switch from screen to printer.) ColsSS is the number of columns required, you can set it to whatever suits you. Later we might add a procedure to enable the user to chose the number required while the program is running.

I've designed my new PROCedure to look as much like the QDOS PROCedure it replaces as possible, so it requires the same two parameters, a channel number and a device name (or, in this case, a function that returns one). (You cannot use the # notation for your own superbasic PROCedures; it has to be replaced with a space.) The main change to the original listing occurs in line 220. (You can use either version -see above) This change leads into the sequence of two new PROCedures and two new FuNctions that follows.

Col_dir is the PROCedure that deals with printing in columns, but there are a few preliminaries to go through first. Make_array puts the directory into an array, ddir$. Lines 790 & 800 OPEN a new file as channel #c%, and puts the directory of your chosen device into it. Not surprisingly QDOS objects if you try to OPEN_NEW a file with a name that alredy exists, and the program would stop with a QDOS error message if it were not for the protective DELETE

statement - luckily QDOS does not object to deleting a file that doesn't exist! DIR produces a series of ASCII text 'lines' each followed by a LF charactei (CHR$(10)), so that is what the temporary file consists of. The first two lines of the directory of a formated device are always the device name and the sector statistics. (Well not quite always, I have a version (2.02) of Toolkit 2 with a bug in it so that it fails to produce these two lines from an empty mdv tape, and the program as written stops here if there are no files on the tape. It will, of course always stop if the tape is not formatted.) The rest of the file is a list of the names of the files on the tape or disk* Since there may be anything from 0 to about 450 we have to count them. This is done at line 810, n% is the actual number of files - two less than the number of lines found by function Line__count, which I'll explain later .

Then follows a bit of fudging. Since I want to print in proper columns the array has to be exactly the product of the numbers of rows and columns. Suppose there were 98 files and we ask..-, for four columns, we can only print rows, so the first line would have to consist of files number 1,26,51 and 76 and so on, but when we get to the last row but one we should run out in the last column if we had only dimensioned our array to 98, generating an "out of range" error. Line 820 calculates the number of rows - the .499 makes sure it rounds up not down - 830 adjusts the value of n%, and 840 dimensions the array ddir$() to n% strings of maximum length nl%. This length was calculated at line 660 - the -1 ensuring at least one space between the columns.

Dimensioning Arrays

Because of the way it was dimensioned ddir$ is a global array. I should have preferred to make it LOCal to Col_dir, but this couldn't be done since we don't know how big it has to be when we enter the procedure. Variable arrays have to be dimensioned to help QDOS organise t memory. Since it is a string array yd. have to tell it how many elements (file

SINC-LINK

SuperBasic Tutorial Part 2 (Continued) Printing in Columns

names) and the maximum number of characters you want in each - if you try to assign a longer name then only the first nl% will go into the array. A LOCal array is declared by putting the dimensions in brackets after the variable name in the LOCal statement, which must be the first line in the array or function. The variable st$ declared in line 650 is an example of a LOCal array, this is to hold the device name and the sector statistics. Since we know in advance what size this has to be there is no problem, but we cannot dimension ddir$ until we know how many file names there are, and it has to be done with a DIM statement. SuperBASIC is more flexible than most BASICs in that you can re-dimension an array to be larger than it was before, so there is no problem with the fact that it will be re-dimensioned each time you print a directory.

Having dimensioned our array we have to fill it with the file names. Line 850 re-OPENs our file for INPUT to the computer as channel #c% again. (The OPEN command also allows you to alter or add to the file, but we don't need to do that.) The short form FOR loop at line 860 puts the drive name and stats into st$. I could have just used the first two elements of ddir$, but I didn't want them to be truncated. Note that the INPUT command - with the appropriate channel number - is used, the same command you use to get input from the keyboard. Then we move to a long FOR, loop which reads the file names from the temporary file and puts them into the array. Because we may have increased the value of n% to be greater than the actual number of names we have to allow for getting to the end of the file before we get to the end of the loop; this is done at line 880. The last few arrayelements may remain empty. Then we've finished with the file and can dispose of it (910).

We now return to line 680, which demonstrates a useful trick. If you want to print a whole array you do not have to write your own loops, PRINT array_name will print out the whole thing. If you follow the array_name

with one of the formatting "punctuation marks" (, ; !) it is printed as though each printed element is followed by the mark; a comma will tab each element - try the effect of the others for yourself. Since there is nothing in line 680 the two entries are printed as separate lines. Then we move to the main double loop (690 - 720). The outer (i) loop controls the rows and the inner (j) loop picks out the entry for each column as we go across the row. The ! puts a space before each column except the first, and the procrustean FuNction ensures that each is exactly the right length. (The formatting mark ! is not used often enough by amateur programmers, as well as the above role it will not print at the end of a line if there is not enough room for the whole string, but starts a new line - no split words.) The PRINT statement between the two END FORs makes sure that there is a new line after each row, it is redundant if you have got the characters per line right in Set__up, but helps keep things tidy if you haven't.

There are still two FuNctions left unexplained. Line_count just returns the number of lines in an ASCII text file, you can use it, for example on a basic file - try:

PRINT Line_count ( 4 , "mdv2_Pr t_di r 3 " ) (you must have prt_dir3 loaded at the time - or Line_count at least, and don't forget the quotes!. It won't work on a Quill file they are not ASCII.) Note in particular line 990* Whenever you use a loop to run through a file, since you do not usually know the length in advance you have to use a REPeat loop rather than a FOR loop, and you must test for end-of-file right at the beginning - it might be an empty file. Nothing happens to a$ here, it's just somewhere to put each line while you count it. You could easily adapt this FuNction to find the length of the longest file name in the list as well as count them couldn't you? (This month's assignment, you might also try to adapt it to find the length of a file in bytes - hint use INKEY$) . The other FuNction, Procrust$, either truncates (1070/80) or pads out with spaces (1090)

SINC-LINK

13

SuperBasic Tutorial Part 2 (Continued) Printing in Columns

the string r$ to make its length exactly

If there is anything I have not explained in enough detail please write to me. Next time Afferbeck Lauder.

(c) 1991 H.J.Clase

Howard Clase

(709) 753-6415

Box 9947, Station B,

St John's, Nfld, A1A 4L4

email hclasei&iunucs.ucs.mun.ca (Note change. )

Put some punch in your PRINT FACTORY© graphics!!

wmtrafetmrne

Collection© 1 Colleetion#2

Miscellaneous

Men/Boys Women/Girls Digitized Misc.

Animals

Sports Transportation Computers Food Holidays Xmas

Over i SO targm & small graphic* in maoH ooltmotioix!

Only $1 2.93 pod. each or both collections for $1 933 ppd. [Chock or money order,] Available on tape or S 1/4 DSDD LAHKEN or OLXGER disk - please specify. Send order tm John McMlchael, 1710 Palmer Dr, Laramie, WY 82070

UPDATE MBG8ZINE 513 E. Main Street Pera, IN 46970

New

Products

14

SINC-LINK

■■■*>• laaaaa ■•*•■• ••••••

aaaaaa ■■■■■a *■■••■ aaaaaa

■■•■*• aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaaaaa aaa

Bug Alerts & Updates

by Richard Hurd

■••■•■i

■aaaaaa

aaaaaa aaaaaa ■aaaaaa iiiiiii •aaaaaa aaaaaa aaaaaa aaaaaa ami

aaaaaa aaaaaa isaaaaa

aaaaaa aaaaaa ■asanas aaaaaa •■■■•■ mil ami aaaaaa

aiaaaaaaaaaaaaaaaaaaai san i ■■■

•■•••■■••iiiii ■iiaaaiiiaeei

aaaaaaaaaaaaai isiiaaaaaaaaai laaaaaaaaaaac

■aaaaaaaai

"

liiaiaiinsilllii •■■■■■•■I iiiiiii

■iiiiiii ■iiiiiii ■■■■•■••> •■•■■••

■>•••••••

maaaaai

IIIIIII! •■>■■■■<

laaaaaaaa ■■■■■■■I inaaaaaa

laaaaa

MM!

aaaaaa

aim

■mi aim ••■•■■ aaaaaa ■■•■■■ iaim

mi ■■•ma

an mini/

Here are a few updates and corrections to some of my articles and programs,

NEC 1035 Disk Drive Overview

From SINC-UNK VoL7 No6 NEC 1035 3J5" floppy disk drive overview.

In the article I mentioned having problems with formatting disks from MEI/Micro Center. After moving the drives power supply further away from the drive, the problem vanished. The no-name disks have held up as well as the name brand Maxell, 3M, and FUJI disks Pve also tried, The price of the no-name disks has gone down to $39 ea. in lots of 25. See their ad in Computer Shopper magazine.

LARKEN Disk Utility Updates.

An update