CODINGLISTINGS ★ ALL SORTED OUT|POPULAR COMPUTING WEEKLY) ★

All sorted out|Popular Computing Weekly)Coding Listings
 ★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se le presenta en su versión original ★ 
 ★ Dieser Text wird in seiner ursprünglichen Fassung Ihnen präsentiert ★ 

R Halsall presents modifications to Peter Patton's Data File program to give it a sort routine and print formatter

Microprofile written by Peter Patton (PCW, Volume 3, issues 46-47) is a remarkably useful data file for which I have found several applications.

When I acquired a printer the need to print out selected fields from previously sorted records soon arose and this entailed the addition of two routines - one to sort the records and one to organise the format of the printout.

Sorting the records

As 1 wanted to keep things simple I decided to sort on one field only. The sort procedure chosen is the 'bubble' sort which is easy to implement This entails comparing element n of the array dat(x,y) (where y is the selected field) with element n + 1 and either swapping n with n+ 1 if n > n+ 1 or leaving the order unchanged.

This is repeated until a complete pass is made with no changes. Lines 6000-6110 of the listing carry out this task. Line numbers less than 6000 are in the original program.

  • 6000 Displays the field numbers and names and asks for the field number to sort by. The sub-routine calls are to subroutines in the original program.
  • 6010 Tests the entered field number for validity.
  • 6020 Initialises the flag that is set to ' 1' if a swap takes place.
  • 6030-6050 Tests element x of array dat(x,y) and calls the swap routine at 6500 if dat(x,y) > dat(x+l,y). The variable 'j' holds the number of records in the file.
  • 6060 The flag is tested to see if a swap has been made. If the flag is '0' the sort routine is exited.
  • 6070-6110 This routine swaps element n with element n+1. The flag is set in this routine before exit.

The printout

Each of my data files have different field parameters (le, the number of fields and number of characters per field). I wanted to be able to set up a format on A4 pages with left and right hand margins of five characters (leaving 70 characters to play with). As records wrapped over two or more lines of print looked messy and made it difficult to identify columns, I decided on one line per record. With most of my files this meant that I could not print complete records but only selected fields.

Some of my names are longer than the field they describe so, as I wanted to make best use of the available line length. I decided to simply number the columns and to add a reference table to the top of the printout together with the name of the source file. Finally, as I wanted to head each new page with these column numbers, I arranged for the routine to keep a count of the number of lines printed in order to drive to a new page when the set page length is exceeded. Lines 6120-6550 deal with all of this.

  • 6120-6240 The field list is displayed, the prompt asks for the field number(s) to be entered. These are held in the array column().
    As each field number is entered a check is made on the total line length used - if this exceeds 70. a message is given and the entry procedure is restarted. A display of the selected field numbers is maintained below the prompt line. Enter the field numbers in the order required on the printout - enter 'O' when finished.
  • 8250 Asks for the page length to be entered.
  • 6260 Sets the line count to 5. This is where my printer head starts a page relative to the tear-off bar.
  • 6280 Prints the file name - sub-routine 6550 centres it.
  • 6290 This calls in turn the sub-routines to print the column reference table, the column heading numbers, and the data lines.
  • 6300 's' is the parameter passed to the function which centres text (defined in line 20 of the original program). Here it is set to a string containing the column number (yyy) and the field name from the array f$().
  • 6360-6420 This sub-routine prints the column numbers. It looks complicated because they have to be spaced suffciently apart to suit the field lengths.
  • 6430-6500 The sub-routine that prints the data lines - be careful when entering line 6470!
  • 6510-6540 Adds five blank lines to the bottom of the page and five to the top of the next one.

Modifications to the original program:

These two new options need to be added to the main option menu. Listing 2 shows the four new lines needed to do this and these follow the pattern of the original program.

Finally change line 840 to the new one shown.

PopularComputingWeekly850620

★ PUBLISHER: POPULAR COMPUTING WEEKLY
★ YEAR: 1985
★ LANGUAGE:
★ AUTHOR: R.Halsall

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» All  sorted  out    (Popular  Computing  Weekly)    ENGLISH    LISTINGDATE: 2017-05-07
DL: 1 fois
TYPE: PDF
SIZE: 204Ko
NOTE: Uploaded by hERMOL ; 2 pages/PDFlib v1.6

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):
» Coding Src's » Restore Utility (Computing With the Amstrad)
» Coding Src's » Ramdisc (Popular Computing Weekly)
» Coding Src's » Revolving Message (The Amstrad User)
» Coding Src's » Graphic - Symphonie Zoom (CPC Revue)
» Coding Src's » Dump anything off the screen (Computing With the Amstrad)
» Coding Src's » RSX Super-CLS

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.75-desktop/c
Page créée en 076 millisecondes et consultée 88 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.