APPLICATIONSDIVERS ★ FILTER ★

Filter|Amstrad Computer User)Applications Divers
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Operation clean-up

Mrs Mop meets the program listing — a program for the CPC in Basic and machine code by Paul S. Jenkins.

Let us suppose that you have been given a Basic program and think it might be interesting or instructive to list it to your printer. It looks fine on the screen, apart from one or two strange characters, so you switch on the trusty Epson compatible printer and type LIST#8. Then you nip off to make a cup of tea while you wait for the completed listing.

But something's wrong, what are those gaps in the printout? Why is some of the listing printed in condensed typeface and some in double width, and where did all those blank lines come from?

The reason for the twisted listing is a problem known as embedded control characters. To save time and memory some programmers use these codes for screen formatting, PEN, PAPER and INK changes.

Here is a simple example of how it's done. Type PRINT" on your Amstrad, and before pressing the Enter key hold down the letter X, then press Enter. If you have done this correctly you should find that the pen and paper inks have been swapped.

What you have just typed is the equivalent of PRINT CHR$(24), and if you look in the User Instructions for your CPC you will find a list of Basic control characters to enable many different effects to be obtained using the PRINT CHR$() command. All these characters can be entered directly into print statements using the control key.

Try typing PRINT" and then Control G. If the volume control is turned up you should hear a beep from the internal speaker. A Basic program which includes embedded control characters will work as expected, but when it is listed on the screen the computer will translate the characters into those strange symbols.

Worse, when you attempt to list the program on paper, the printer interprets the symbols as printer control codes and changes its typeface, prints a form feed, turns on underlining, or one of a number of unwanted features.

All the foregoing is a very strong argument against using embedded control characters in your programs. It is certainly something which will cause your listing to be rejected by ACU's Liz Ting. A problem which cannot be solved by good practice involves the use of the PRINT USING command. Refer again to the user instructions and you will see that to print formatted numbers with a preceding pound sign the PRINT USING template must consist of a combination of hash and pound signs. This will print correctly on the screen, but not on an Epson compatible printer.

Depending on whether your printer has the English or American character set in operation, the print using template will appear as all pound signs or all hashes. It is impossible to tell which is which if what you see is:

PRINT_to-

tal_1/2__USING__########,. ##_; t

An Epson compatible printer can be switched between American and English character sets by means of the aforementioned printer control codes. The Basic program listed here provides a way of switching between character sets during printing.

The program will also filter out all embedded control characters and convert them into a pair of square brackets enclosing an up-arrow (") and a key character. This means that the two examples given above would appear as [^X] (Control - x), and f [^G] (Control - G).

Any graphics characters or other codes whose Ascii value is more than 127 will also be converted, to square brackets enclosing a g- and the Ascii value of the character which might otherwise cause the printer to go haywire.

The only restriction on the use of the Filter utility is that the program to be listed must be in Ascii format. If the name of your program is YOURPROG, then before using Filter type: LOAD"YOURPROG" and then SAVE "YOURPROG",A. This will create a version of your program in Ascii format. Then you can run Filter.

You will be asked for the name of your program and whether you want the listing sent to the screen, the printer, cassette or disc. If you select either of the last two you will be asked for the name of your program and whether you want to give the filtered listing. If you select the disc when no disc drive is present you will be asked again.

The program is quite simple in operation, and meaningful variable names have been used so that it can be adapted as necessary for a non-Epson standard printer. Error trapping is included for all disc and tape operations, so although the program was written on a CPC6128 it should work on a 664 and 464 with or without disc drive.

The screen dump of DEMO1 in Figure I shows how a program contains embedded control characters, a pound sign, a hash sign, and graphics characters appear on the screen. Don't list this program directly to your printer unless you want to waste a lot of paper.

If you want to enter DEMO1 into your CPC so that you can test the Filter program then refer to the Filtered listing of Demo 1, which was produced using the Filter program.

Whenever control codes appear in the filtered listing you should hold down the Control key and press the character shown after the up arrow (don't type in the square brackets).

To type in the graphics characters you first need to re-define some keys. For instance, to re-define the 7 key as the character whose code is 135 type KEY 128 + 7,CHR$(135) and press Enter. Now when you press 7 an inverted L shape will be printed.

When you have typed in the complete DEMO1 listing it should look like the screen dump shown in Figure I. When run, DEMO1 produces a simple demonstration title screen in Mode 0 and waits for you to press the spacebar.

Save the program by typing SAVE"DEMO1",A and press Enter. The A will cause the program to be saved in Ascii. Filter will only work with programs saved in this way. If you try to use Filter with a normally saved program it will not accept the file name and will ask for another.

It is a good idea to save the program in normal format as well as the Ascii; it will load faster and a control Z in the Ascii listing will stop it from loading.

It is best to avoid using embedded control characters, but at least Filter makes your programs readable.

ACU #8707

★ PUBLISHER: Amstrad Computer User
★ YEAR: 1987
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LICENCE: LISTING
★ AUTHOR: Paul S. Jenkins

★ AMSTRAD CPC ★ DOWNLOAD ★

Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)
★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Raindown (CPC Amstrad International)
» Applications » Etoiles et Constelations (Amstar&CPC)
» Applications » Din A4 - Hardcopy Fuer Nlq 401 (CPC Amstrad International)
» Applications » Elipses
» Applications » Newcastle Database (The Amstrad User)
» Applications » Gestion de Peripherique (AM-Mag)

QUE DIT LA LOI FRANÇAISE:

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!

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 785 millisecondes et consultée 751 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.