|★ APPLICATIONS ★ UTILITAIRES RSX/LIGNE DE COMMANDE ★ Page Utility ★|
|Page Utility|Computing with the Amstrad)||Applications Utilitaires Rsx/ligne De Commande|
IF you flick through the pages of Computing with the Amstrad you'll see that most of the program listings are quite short. With around 40k of RAM free it means that very little of your Amstrad's memory is being used at any one time.
Wouldn't it be useful if we could store several Basic programs in the memory at once, and be able to switch between them and run any one?
You could then have all Pete Bibby's example programs from this month's beginners article in memory at the same time, for instance. You would be able to select one, run it, select another, run that, then compare the results. It would save a lot of typing or accessing the disc or tape.
That's just one of many uses once you have this ability. It opens up a whole new range of possibilities.
For instance one program could be used to modify another. It wouldn't be difficult to write a utility to compact a program, taking out the REMs. You could also have a search and replace utility so that you could change variable names, and so on.
These are just a few ideas. I'm sure you can think of many more.
The program accompanying this article will enable you to store and run Basic programs at any address in the memory. This means that you coutd load one program at &1000 say, then another at &2000 and a third at &3000. Any of the programs can be selected and run.
You don't have to use nice round figures like & 1000, though it's easier to keep track of where you've put all your programs if you do. It's quite easy to lose track of where your programs are! Also it's up to you to make sure that the program you put at one address doesn't overwrite the program at another. However with so much RAM free it's not difficult to find a bit of space.
Program I is a Basic listing of the utility and Program II is an assembly listing. When it is run several new commands are added to Basic. They are listed in Table I.
The first SPRINT.PAGE, prints the value of a system variable I've called PAGE. This is at &AE64 if you have Basic 1.1 or &AE81 if you have Basic 1.0. The second command, |SET.PAGE, as you've probably already guessed, sets the value of PAGE.
When you type a program in or load it from tape or disc Basic stores it at PAGE. Then when you type SAVE Basic saves the program stored at PAGE and when RUN is entered the program at PAGE is run.
If we alter the value of PAGE we can enter or load another program without affecting the first, providing, of course, that we don't overwrite it.
It's not just a matter of altering one system variable though. If we want to go back to our original program and we alter PAGE to its previous value, the program won't be magically restored. We have to do that ourselves.
As well as keeping track of where a program starts, Basic also needs to know where it ends. This address is stored in another system variable which I'll call TOP.
The end of a Basic program is marked by a couple of zero bytes. So to find TOP we search through the program line by line until we come to them. The address is then stored in TOP.
Basic needs to know TOP since this is where the Basic variables are stored when the program is run.
Several other pointers need to be set to the same value, the ones that tell Basic where the variables end. The variables are placed at the end of the program starting at TOP.
By restoring all these pointers we restore the original program, which can be run again. The variables will be lost though, and it's always best to enter CLEAR when changing PAGE.
All this is carried out automatically by the utility. So if PAGE is changed the routine looks to see if a program is stored at the new address. If there's nothing there, or if it can't follow the program because it's been corrupted, |NEW.PROGRAM is executed.
This command will delete the program at PAGE without destroying any other programs in the memory. The normal Basic command NEW destroys everything in the memory, so use it with caution.
A program may need to know what PAGE, TOP and LOMEM are -LOMEM is the lowest point in the memory which is free. The commands |GET.PAGE, |GET.TOP and |GET.LOMEM look up the relevant system variable and place its value in one of Basic's integer variables.
will set a% to the current value of PAGE.
Page is an extremely useful utility and a great help when programming. It enables you to take full advantage of the generous amount of RAM in your Amstrad.
CWTA L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!
L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!