Micromail

Volume 1

Number 10

December 1983

No plaudits for handwriting...

THREE cheers for Christopher Hester, who in October's Micromail exposed the naked king of over-precious structured programming!

What in the world is so sacrosanct about a PROC? Why the lumbering PROC ... DEFPROC ... ENDPROC when a plain honest GOSUB ... RETURN does the job in half the time, is easily traceable and is just as readily debug-gable?

Your program structure shouldn't suffer a whit by a GOSUB: GOSUBs are quick and nimble, whereas PROCs are heavy, fat and sanctimonious.

The only advantage in using PROCs lies in their control variable facility, and if you don't want a control variable (as most people don't) then why leave the nippy GOSUB languishing, discredited, in the wings?

And while we're on the subject, why all this pious claptrap about using TRUE and FALSE, when a simple 1 or 0 flag is far more easy to use?

Or at least it would be if the Acorn compilers were not so waywardly silly as to insist on a - 1 value for TRUE, thus denying us the quick and easy IF x ... and IF NOT x ... clauses.

These poor brainwashed Beeb programmers have been misled into considering it a point of honour not to include a single GOTO or GOSUB in their listings.

What a pathetically self-righteous and hypocritical attitude! We are interested in what programs DO, not in delivering pats on the head for the handwriting. - David Bye, Saffron Walden, Essex.

Squaring things up

I HAVE bought your magazine since it first appeared, and have found it very helpful. So perhaps I can help some of your readers with the problem of "NO ROOM" in the King Kong and Deathwatch programs. I also fell into the trap of creating unwanted spaces that took up memory. I then obtained the following short program that will list all extra spaces including the essential ones.

First list your program to screen and then type the following:

MODE6:VDU19,0,1,0,0,0:VDU23, 32,255,255,255,255,255,255,255,255

Then press Return. The listing starting at the beginning will now appear with squares making the spaces and all unwanted ones can be removed by the aid of the copy key.

You will be amazed at the number of spaces that creep in and are not required. - S.H. Gereham, Romford.

Lost programs

I HAVE several enquiries which I hope you may be able to answer. They are all intriguing and could well be of interest to other readers.

The first problem arose when I bought for my school a piece of software which I spent the whole weekend trying to list. It loaded all right and then ran. (I typed LOAD, etc rather than CHAIN.)

When I typed LIST, the screen went blank. I used an assembly language retrieval program - nothing.

I tried to list only certain sections - nothing. I tried to delete certain lines - nothing. Eventually the program was lost and I reloaded it.

After abortive attempts to list, anything I pressed gave "Bad Program". What intrigues me is how they do it? I want to learn rather than infringe copyright!

Secondly, I have heard that transferring programs from cassette to disc can be awkward. I should think that for long programs, needing to be loaded at &EOO, it would prove rather difficult. So how is it done?

Thirdly, I read often that certain memory locations contain certain information. How can I find out what's where?

For example, in the November issue, one of your correspondents writes that information on which mode one is in is contained in location &367. How can you find out these things?

Lastly, could you explain what VDU23 does - apart from turning the cursor on and off and re-programming display characters.

Then again, what about VDU23,9;16;0;0; or whatever?

Could we have a comprehensive list of all possible VDU23 commands?

Oh yes - what about an article on GCOL1, 2 &3!

Needless to say, an excellent magazine. - Graham Conridge, London.

• The software protection method you describe is caused by entering control codes into REM statements. For obvious reasons we cannot give more details.

The problems of transferring cassette to disc were fully covered in Peter Walker's article in the August issue of Micro User.

I suggest the Advanced User Guide and our back issues as sources of information on memory locations, and also on VDU23.

This command can be used in two ways to create user defined characters, or to directly program the 6845 - details of which we shall be giving in forthcoming articles.

We're also going to feature soon the uses of GCOL 1, 2 and 3.

rqForth

I WAS delighted to find Chris Martin's lengthy review of Level 9's rqForth in your November issue and was glad that he seems to like it (once I'd tracked down his opinions among the inevitable paragraphs on Forth history, etc!).

Readers may be interested to learn that all copies of rqForth sold since Easter have included versions for both cassette and disc (with a free 30 page disc supplement in addition to the normal manual). - Pete Austin, High Wycombe.

Skeleton unearthed

AFTER reading about Acorn's most generous advice to its rival software houses about indirectly addressing the screen and how this programming activity will lead to incompatibility with the second processor (if it ever arrives, that is), I was wondering how Acornsoft managed to obtain the speed required for their Super Invaders.

After many long nights bent over a hot (well, warm at least) computer typing my flngers to the bone using the brilliant (so Acorn would have us believe) OS calls in my programs, I still could not get the speed I required for my Invaders game.

Finally, in desperation an evil thought crossed my mind, "Why not address the screen directly?"

Quickly I shook the abhorrent thought from my ungrateful head and decided to find out how the experts used the OS calls to such magnificent effect.

After much hair pulling and late nights while examining the innermost secrets of Super Invaders, I finally discovered Acornsoft's skeleton in the cupboard (or should it be bug in the OS) - they address the screen directly!

So it appears that after all Acorn's ranting about unprofessional programming practices, they forgot to send an internal memo to their own subsidiary company, Acornsoft, about the perils of direct screen addressing.

Or is there a way of direct screen addressing and still making it compatible with the second processor which friendly old Acorn forgot to tell us about? It will be interesting to find out if this programming practice is possible and if not I hope Acorn will be as quick in reprimanding Acornsoft as it has been in the past in attacking magazines which try to help their readers to become more experienced programmers. - David Young, Michael Young, Derby.

Applesoft Forth tips

NEWCOMERS like myself to Acornsoft Forth might find the following tips useful.

After loading the system, including the editor and assembler, type in 9 KEY' (Return) as this will clear the f9 key and avoid carrying out a COLD restart by accident.

7 KEY' V7 M (Return) will define f7 to give mode 7 and the OK prompt and avoids any risk of a basic program line 7 being entered as could happen if the key was defined in the obvious way, using 7 MODE.

HERE FENCE! (Return) avoids FORGETting any words by mistake.

It is possible to use a screen dump from within Forth by doing the following:

Press BREAK and *load the dump code in memory so as not to conflict with the Forth system (in my case at &900).

Define SCREEN-DUMP as follows:

HEX
CODE SCREEN-DUMP
XSAVE STX,
xxx JSR,
XSAVE LDX,
NEXT JMP,
END-CODE
DECIMAL

(xxx is execution address of dump routine)

Typing SCREEN-DUMP (Return) will then call the dump routine. You can define a function key to call the screen-dump transparently by entering

x KEY' ¦\¦@¦@¦@¦@¦X¦@¦@¦@¦@¦@¦@¦@¦@¦E SCREEN-DUMP ¦M¦Z¦D

which sets up text and graphics windows of zero co-ordinates, joins text and graphics cursors, calls the screen dump without SCREEN-DUMP appearing on the screen and then restores the cursor and windows to default values.

Repeated copies of the screen can be made, all identical and unblemished.

I hope these tips save other novices the hours of confusion that I went through. - Paul F. Tolson, Dewsbury, Yorkshire.

Suppressing display

WITH reference, to the problem of suppressing the screen display during output to the printer, as discussed on page 58 of the October Micro User, unfortunately the solution suggested does not always work as expected, particularly if printing graphics as well as text.

I have found that a program which previously worked perfectly gave a very strange printout.

The solution I have adopted avoids any interference with the VDU drivers or channel *FX calls, and a listing is enclosed.

As you can see I have simply defined a zero text window after printing a message on the screen, and also switched off the cursor. All that is seen of the printing is an occasional slight flicker in the top left hand corner of the screen.

To use the procedures,

l0DEFPROCpron
20CLS
30FORA=11T012
40PRINTTAB(12,A)CHR$l41CH R$134CHR$l36"Printing"
50NEXT
60VDU28,0;0;:REM Zero Text Window
70VDU2
80VDU23,1,0;0;0;0;:REM Switch off cursor
90ENDPROC
120DEFPROCproff
130VDU3
140VDU26:REM Restore Text Window
150VDU23,l,l;0;0;0;:REM Restore cursor
160CLS
170ENDPROC
Listing I

simply enter PROCpron or PROCproff instead of VDU2 or VDU3. (Listing I.)

For anyone who already has a large program and does not wish to edit all the VDU2 and VDU3 calls, I also enclose a

10A%=?&20E+256*?&20F
20FORA=0T01
30P%=&D01
40[OPTA
50CMP£2
60BNEnext
70LDA£12:JSRA%
80LDA£28:JSRA%
90LDA£0:JSRA%:JSRA%:JSRA% :JSRA%
100LDA£2:JSRA%
110.next
120CMP£3
130BNEnone
140LDA£3:JSRA%
150LDA£26
160.none
170JMPA%
180]
190NEXT
Listing II

machine code patch which will detect any VDU2 call, clear the screen and set up a zero text window. (Listing II.)

A VDU3 call will reset the text window to the default. The patch is presently assembled at &D01.

Anyone with a disc drive will need to use another section of RAM. To activate the patch use ?&20E =1 : ?&20F=&D. In this case the cursor remains, although it could be removed with extra lines of code if required.

BREAK will deactivate the patch, as will POKEing the original contents back into &20E and &20F. These values may vary for different operating systems, and should be determined for individual machines. Incidentally, if storing the program anywhere other than &D01, the activation addresses should be changed accordingly. - Peter Vasey, South Shields.

Tiny Problem

HERE is our computer game idea: The computer is the dog and you are the frog.

The dog chases the frog, but you can get away by jumping over the dog and score points by jumping on a lily pad — about 100 points. You have four lives.

It has three screens and on each screen there gets less and less lily pads. On the third lot you have three lily pads — two green and one red which is home and scores 500 points.

You have 1000 units of energy to get through each lot.

We do not know how to write this game in Basic. Please could someone do it for us? - Sharon King, age 8 1/2, Paul King, age 6 1/2.

• Is there anyone out there who could program Sharon and Paul's idea for them? If so, get in touch with Micro User!

Structure strictures

MAY I reply to Christopher Hester's points and questions about structured programming (Micro User, October, 1983).

First, a general point. BBC Basic is not fully structured and it is true that complete adherence to the rules of good structure produces more procedures than one would choose.

I can give details of methods for getting the procedures in a reasonable order, perhaps soon in this journal. But at least when searching for a procedure one is searching for a properly named chunk of code with a beginning and end.

Most of Mr Hester's problems arise because of faults in BBC Basic which one hopes are just part of the long history of the development of languages.

A change of graphics mode should be possible in a procedure. It is a problem the software writers did not solve properly. The same comment applies to any other action command. They should work in procedures or in the main program equally well.

The reasons why GOTO and GOSUB are still included are complex and different. GOSUB is there for compatibility with old practices and possibly as a cover for technical shortcomings.

No modern language would be designed with GOSUB included for its own sake.

GOTO has the same justifications and one more. There are certain complex situations, such as the need to cope with an error discovered at a deeply nested point in a program, when a GOTO is the simplest way to cope. Used carefully by an expert there is no problem.

But as a teacher I know from bitter experience the trouble which GOTO causes.

For students and beginners it should be completely avoided and even Mr Hester need not use it for the input routine he mentions. A standard structure for handling keyboard input is:

REPEAT
(get the data)
UNTIL (data is correct)

It would be easy for people to list their personal preferences but the concepts of SP are the result of wide consensus and more than a decade of hard won progress.

BBC Basic is good enough (only just) to enable its users to work in a sensible modern conceptual framework within which problems can be solved and tasks completed in efficient, readable ways.

Any reader is free to reject or accept this philosophy, but I do get upset when I see the old discredited methods being taught to unsuspecting children or other newcomers to computing. Why does Mr Hester think SP was invented? - Roy Atherton, Director, Bulmershe Computer Education Centre, Reading.

Answer in stereo

READING of the continuing interest in tape loading problems I thought that some readers might benefit if I related my own experiences in this troublesome area.

For my first attempts at tape loading I used my "quality" mains powered stereo tape deck with built in amplifier (output impedance 10kohms, input 560 kohms).

Acorn's letter in the October issue of Micro User showed that I had no chance of success. I then bought a cheap portable and now, being as wise as the Beeb Owl, asked for a demo to be sure that it worked.

The dealer promptly loaded up Planetoids - no problem.

On my return home however I discovered that there was no record level control and the auto level was too high. Programs unloaded to tape could not be loaded back onto the computer.

My way round that one was to re-record onto my mains recorder adjusting the record level appropriately.

Well, as you might guess all this infuriated my wife. The tape deck went back to the dealer and we bought a pair of disc drives.

If you promise to keep a secret from more understanding wives I have now discovered that if I record onto the stereo deck via the microphone input (low impedance) and carefully output via the speaker channels (6w) there's no trouble at all!

It's just as well Acorn were a little slow in writing to you. - Lex Harrison, Edinburgh.

Missing

THANKS for a great magazine but in your listing for your date of birth program in the October issue you missed a line out and the program would not run. There should have been a line number 35 PROCinit. - Matthew Searle, age 11. • Quite correct Matthew — the missing line is on the floor somewhere in our art room!

Mystery

CAN you help me with two problems?

Why does shift and break produce the message:

BBC Computer
Searching
File not Found
BASIC
>_

While disassembling the Basic I ROM I found the command LINE. Could you please tell me what this does ? - Ben Dessau, Rottingdean.

• On machines fitted with a DFS, pressing break and shift, then releasing break while maintaining shift causes the micro to *EXEC a file on the disc with the title !BOOT (provided the disc has been prepared with *OPT 4 3).

Often !BOOT simply chains in a menu program.

If you haven't got a DFS, you obtain the message you described on OS 1.2. On OS0.l you simply obtain a normal break.

*LINE and *CODE allow you to jump to your own machine code routine pointed at by a vector at &200,&201 (the user vector USERV).

*CODE is followed by two parameters which are placed in the X and Y registers. It is entered with the accumulator equal to zero.

*LINE is followed by a string, the start of which is vectored by X and Y. It is entered with the accumulator equal to 1.

Crash catcher

TO make your BBC Microprint the line at which an error occurs when it crashes, the following can be used (with OS 1.0 or later):

10 ON ERROR REPORT:PRINT" at line";ERL: PROCinsert("L IST"+STR$(ERL)+CHR$13):STOP 10000 DEFPROCinsert(I$):REPE AT:A%138:X%=0:Y%=ASC(LEFT$( I$,1)):CALL&FFF4:I$=RIGHT$(I $,LEN(I$)-1):UNTIL I$="":END PROC

- David Stonebanks, Stevenage.

IF you're a Prestell subscriber you can now write to Micromail by Electronic Mail. Our Mailbox number is 614568383. These were the first messages we received:

HELLO, nice to see you published my letter and also your Mailbox number for all to see. This is coming to you via the offline Mailbox editor.

While I'm on I have a couple of questions for you. Is the light pen article in your November issue complete?

I'm asking because I can't get it to work with my homemade light pen. I have other programs, so I know it works.

The pallet appears but the pen doesn't respond. - James T.A. Wilkins.

• The light pen you mentioned doesn't have the special circuit which is incorporated into the light pen available through The Micro User and which senses whether it is pointing at the screen. The article describes the Procedure to change to get around this shortcoming.

* * *

JUST a message to say I'm glad to see you on Micronet. Electronic mail has so many advantages for those like myself who if they manage to organise pen, paper, envelope and stamp then forget to post the letter!

On the subject of an adventure page - a nice idea, but how do you avoid getting hints when you don't want them? - H. Hanley, Norwich.

* * *

I HAVE just received my November issue of The Micro User and I'm still convinced that next to my Beeb this is the best buy I've made!

I particularly appreciate the down to earth approach which you adopt and find Mike Cook's pages of especial interest.

Do you think he could come up with some (polite) suggestions for those of us who have graduated from Atom to Beeb?

Is there any way the Atom can be linked to the Beeb? Extra memory? Second processor? - J.G. Swift.

• Mike Cook says it can be done, but he really doesn't think there's a lot to gain from it.

And finally, with tongue firmly in cheek . . .

Trevor's micro finally makes the grade

Dear Trev,

I've finally done it. I've summoned up the nerve to take my micro down to the Nice Byte and get my new ROM fitted. So, instead of being just a 0.1 plebian, I am now the proud owner of a 1.2 Operating System.

Mind you, it was a nerve wracking experience. First of all I had to get my Beeb downstairs to the car. This entailed a half hour struggle with the tangle of wires and flexes that had built up over the past six months. It was while I was doing this that I came across a plug that actually didn't do anything! I've no idea how it got there or what it was supposed to do.

Andrea was nice enough to drive me and my Beeb down to the shop though she couldn't help showing her nature. By habit I sat in the front of the car.

"Shouldn't you be sitting in the back, dear?" she asked with an air of innocence. "I mean didn't they just change the law or something?"

I ignored the remark and she referred to my British Broadcasting Micro as "the little bundle" all day.

When I got to the Nice Byte she came in with me and demanded that the salesman explain exactly what was going to happen. He waxed eloquent and made it sound like a brain transplant.

"Never mind the micro", she said pointing at me, "give him a new ROM".

The salesman gave me a fellow sufferer kind of look and told me that if I waited it would be "all over" in 10 minutes.

Well, it was the longest ten minutes of my life. I swear that as soon as my micro disappeared into the back of the shop I started having withdrawal symptoms. You know, anxiety, blurred vision, sweating. Without thinking about it I started pacing up and down.

"Don't worry, dear, I'm sure that they'll use an anaesthetic", Andrea murmured, working her way through the books, complaining about the prices.

It was a relief when my micro arrived back on the counter.

"Is it a boy or a girl?" Andrea asked the confused assistant.

"It's an OS 1.2 and that'll be £11", he replied.

At this point Andrea, who hadn't realised that I was going to have to pay, started to become a cross between M. Thatcher and H. Ogden, both at their best (or do I mean worst). I can't remember exactly what it was that she said (I was in a corner pretending to look at some software).

I do, however, distinctly remember her mentioning the "Sale of Goods Act, 1893" and Esther Ransom in the same breath.

Anyway, it did no good. I took out my cheque book and paid. As I walked out of the door the salesman grinned wickedly and yelled out: "See you when you get Basic Two".

Andrea's still asking me just what Basic Two is and I'm running out of lies. I wish that I'd stayed with my 0.1 ROM. I enjoyed playing the cassette bugs fix!

Yours in adversity,

Bob